- 1
Хостинг
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
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);
0
protected function validateArguments(array $argv = null)
{
$argc = count($argv);
if (1 == $argc && is_array($argv[0])) {
return $argv[0];
}
if (2 == $argc) {
if (is_array($argv[0]) && (is_numeric($argv[1]) || is_null($argv[1]) || is_string($argv[1]))) {
$argv[0][] = $argv[1];
return $argv[0];
}
if ((is_numeric($argv[0]) || is_string($argv[0])) && (is_numeric($argv[1]) || is_string($argv[1]))) {
return $argv;
}
}
if (3 == $argc) {
if ((is_numeric($argv[0]) || is_string($argv[0])) && (is_numeric($argv[1]) || is_string($argv[1])) && (is_numeric($argv[2]) || is_null($argv[2]) || is_string($argv[2]))) {
return $argv;
}
}
array_walk($argv, function (&$value) {
if (is_array($value)) {
$value = 'Array';
} else {
$value = sprintf('"%s"', $value);
}
});
throw new InvalidValueException(sprintf('Invalid parameters passed to %s::%s: %s', get_class($this), '__construct', implode(', ', $argv)));
}
0
this._hideDataLabels = this._filter._accordionSettings._children[0]._children[0]._value;
+3
Мес = ?(Месяц(ДатаДок) > 9 ,Строка(Месяц(ДатаДок)) ,"0"+ Строка(Месяц(ДатаДок)));
Формат(ДатаДок, "ДФ=MM") придуман для неудачников!
0
<?php
require_once("JavaScriptPacker.php");
function pack_js($input){
return (new \JavaScriptPacker($input, 62, TRUE, FALSE))->pack();
}
?>
<script>
<?php ob_start("pack_js"); ?>
//awal penulisan javascript
alert('Hello world');
//akhir penulisan javascript
<?php ob_end_flush(); ?>
</script>
Нужно угадать для чего нужен JavaScriptPacker