- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
<?php
$i = -1;
while ($i == $i)
{
$i = $i + (1);
echo($i + "," + " ");
}
?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
<?php
$i = -1;
while ($i == $i)
{
$i = $i + (1);
echo($i + "," + " ");
}
?>
KEK
0
// https://github.com/ghc/ghc/blob/e204431e5a5e2fd16da52b04bda2798f16c51344/rts/Interpreter.c#L1184
case bci_PUSH8: {
int off = BCO_NEXT;
Sp_subB(1);
*(StgWord8*)Sp = *(StgWord8*)(Sp_plusB(off+1));
goto nextInsn;
}
case bci_PUSH16: {
int off = BCO_NEXT;
Sp_subB(2);
*(StgWord16*)Sp = *(StgWord16*)(Sp_plusB(off+2));
goto nextInsn;
}
case bci_PUSH32: {
int off = BCO_NEXT;
Sp_subB(4);
*(StgWord32*)Sp = *(StgWord32*)(Sp_plusB(off+4));
goto nextInsn;
}
case bci_PUSH8_W: {
int off = BCO_NEXT;
*(StgWord*)(Sp_minusW(1)) = *(StgWord8*)(Sp_plusB(off));
Sp_subW(1);
goto nextInsn;
}
case bci_PUSH16_W: {
int off = BCO_NEXT;
*(StgWord*)(Sp_minusW(1)) = *(StgWord16*)(Sp_plusB(off));
Sp_subW(1);
goto nextInsn;
}
case bci_PUSH32_W: {
int off = BCO_NEXT;
*(StgWord*)(Sp_minusW(1)) = *(StgWord32*)(Sp_plusB(off));
Sp_subW(1);
goto nextInsn;
}
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Interpreter
> The linker lives in rts/Linker.c and is responsible for handling runtime loading of code into a Haskell process. This is something of a big blob of unpleasant code, and see DynamicGhcPrograms for information about efforts to reduce our dependence on this linker.
Итак, тут у нас стековая машина из хачкеля, которая вродекак отвечает за динамическую загрузку какого-то говна.
+1
Прыщи
0
// https://github.com/alpertron/calculators/blob/15607feafb0ddb1c075bb326dc6ea2224a4c50bb/siqs.c#L3720
switch (NumberLengthA)
{
case 7:
dRem = (double)*(piDividend + 6) * (double)rowPrimeTrialDivisionData->exp6 +
(double)*(piDividend + 5) * (double)rowPrimeTrialDivisionData->exp5 +
(double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
(double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
(double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
(double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
break;
case 6:
dRem = (double)*(piDividend + 5) * (double)rowPrimeTrialDivisionData->exp5 +
(double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
(double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
(double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
(double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
break;
case 5:
dRem = (double)*(piDividend + 4) * (double)rowPrimeTrialDivisionData->exp4 +
(double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
(double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
(double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
break;
case 4:
dRem = (double)*(piDividend + 3) * (double)rowPrimeTrialDivisionData->exp3 +
(double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
(double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
break;
default:
dRem = (double)*(piDividend + 2) * (double)rowPrimeTrialDivisionData->exp2 +
(double)*(piDividend + 1) * (double)rowPrimeTrialDivisionData->exp1;
break;
}
Generic two integer variable equation solver
This calculator can solve equations of the form ax² + bxy + cy² + dx + ey + f = 0 where the unknowns x and y are integer numbers.
0
Хостинг
+1
// https://github.com/CVC4/CVC4/blob/14b9dbaa0c9e8dce52d1a28595dc1cc80756abed/src/expr/pickler.cpp
static Block mkBlockBody4Chars(char a, char b, char c, char d) {
Block newBody;
newBody.d_body.d_data = (a << 24) | (b << 16) | (c << 8) | d;
return newBody;
}
static char getCharBlockBody(BlockBody body, int i) {
Assert(0 <= i && i <= 3);
switch(i) {
case 0: return (body.d_data & 0xff000000) >> 24;
case 1: return (body.d_data & 0x00ff0000) >> 16;
case 2: return (body.d_data & 0x0000ff00) >> 8;
case 3: return (body.d_data & 0x000000ff);
default:
Unreachable();
}
return '\0';
}
// ...
void PicklerPrivate::toCaseString(Kind k, const std::string& s) {
d_current << mkConstantHeader(k, s.size());
unsigned size = s.size();
unsigned i;
for(i = 0; i + 4 <= size; i += 4) {
d_current << mkBlockBody4Chars(s[i + 0], s[i + 1],s[i + 2], s[i + 3]);
}
switch(size % 4) {
case 0: break;
case 1: d_current << mkBlockBody4Chars(s[i + 0], '\0','\0', '\0'); break;
case 2: d_current << mkBlockBody4Chars(s[i + 0], s[i + 1], '\0', '\0'); break;
case 3: d_current << mkBlockBody4Chars(s[i + 0], s[i + 1],s[i + 2], '\0'); break;
default:
Unreachable();
}
}
Очередное переизобретение какой-то байтоебской поеботы типа ntohl(). И вообще, тут UB.
0
private fun GetDeviceInfo(request: HttpServerRequest): HashMap<String, Info>
{
val deviceInfo = request.getParam(NAME_ID)?.let { id ->
(Ports.ById(id) ?: Ports.ByDeviceId(id))?.let(DeviceInfo.Companion::Create)
?: Files.FromPath(id)?.let { file ->
FileInfo.GetInfo(file)
} ?: (Core.GetTask(id) as? Scenario)?.SourceFile?.let(::FileInfo)
}
return deviceInfo?.let { hashMapOf(REQUEST_RESULT to it) } ?: hashMapOf()
}
+1
sub addleft
for i = 1 to 4
for j = 1 to 3
if a(i,j)<>0 and a(i,j) = a(i,j+1) then
moved = true
a(i,j) = a(i,j)+1
a(i,j+1) = 0
score = score + integer ( 2**a(i,j) )
end if
end for
end for
end sub
sub left
for i = 1 to 4
for k = 1 to 3
for j = 1 to 3
if a(i,j) = 0 and a(i,j+1) <> 0 then
moved = true
a(i,j) = a(i,j+1)
a(i,j+1) = 0
end if
end for
end for
end for
end sub
rem addright, addup, adddown, right, up, down в том же духе
rem . . .
rem главный суслик
while true
xy = touchdown()
if xy <> -1 then
x = xy/65536&0x0000ffff
y = xy&0x0000ffff
repeat
sleep 10
xy = touchup()
until xy <> -1
x = x - (xy/65536&0x0000ffff)
y = y - (xy&0x0000ffff)
if (abs(x)>100) <> (abs(y)>100) then
moved = false
if abs(x) > 100 then
if x > 0 then
left
addleft
left
else
right
addright
right
end if
else
if y > 0 then
up
addup
up
else
down
adddown
down
end if
end if
if moved then
rand
end if
end if
else
sleep 10
end if
draw
sleep 50
end while
Не визуальный, но всё-таки барсик (могильный).
+3
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 4890726
@summary Check the correctness of KOI8_U by comparing to KOI8_R
*/
import java.util.*;
import static java.lang.Character.UnicodeBlock;
public class UkrainianIsNotRussian {
private static String decode(byte[] bytes, String encoding) throws Throwable {
String s = new String(bytes, encoding);
equal(s.length(), 1);
check(Arrays.equals(s.getBytes(encoding), bytes));
return s;
}
private static void realMain(String[] args) throws Throwable {
final byte[] bytes = new byte[1];
int differences = 0;
for (int i = 0; i < 0xff; i++) {
bytes[0] = (byte) i;
final String r = decode(bytes, "KOI8_R");
final String u = decode(bytes, "KOI8_U");
if (! r.equals(u)) {
differences++;
final char rc = r.charAt(0);
final char uc = u.charAt(0);
final UnicodeBlock rcb = UnicodeBlock.of(rc);
final UnicodeBlock ucb = UnicodeBlock.of(uc);
System.out.printf("%02x => %04x %s, %04x %s%n",
i, (int) rc, rcb, (int) uc, ucb);
check(rcb == UnicodeBlock.BOX_DRAWING &&
ucb == UnicodeBlock.CYRILLIC);
}
}
equal(differences, 8);
}
//--------------------- Infrastructure ---------------------------
static volatile int passed = 0, failed = 0;
static void pass() {passed++;}
static void fail() {failed++; Thread.dumpStack();}
static void fail(String msg) {System.out.println(msg); fail();}
static void unexpected(Throwable t) {failed++; t.printStackTrace();}
static void check(boolean cond) {if (cond) pass(); else fail();}
static void equal(Object x, Object y) {
if (x == null ? y == null : x.equals(y)) pass();
else fail(x + " not equal to " + y);}
public static void main(String[] args) throws Throwable {
try {realMain(args);} catch (Throwable t) {unexpected(t);}
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
if (failed > 0) throw new AssertionError("Some tests failed");}
}
https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/test/jdk/sun/nio/cs/UkrainianIsNotRussian.java
0
$(`.js-filter-panel__radio__pre-tuned-up-settings`).find(`.js-filter-reg-date-radio-item:not(#${$input.attr(this._preTunedSelectedPeriod)})`).prop('checked', false);