- 1
- 2
<?php
while((!isset($i) ? $i = 1 : $i++ < rand(5, 10)) && $res = implode('-', $i%2==0 ? range($i, 1) : range(1, $i)) . "\n") echo $res;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
<?php
while((!isset($i) ? $i = 1 : $i++ < rand(5, 10)) && $res = implode('-', $i%2==0 ? range($i, 1) : range(1, $i)) . "\n") echo $res;
Прочитав статью https://habrahabr.ru/post/116842/, решил поговнокодидь
Выводит:
1
2-1
1-2-3
4-3-2-1
1-2-3-4-5
6-5-4-3-2-1
Это очень странно но я ухитрился засунуть все вычисления в условие цикла))
0
if (!($('.check-silver').css('display') == 'none' ))
0
(* We open this module at the top of module generating rules, to make sure they don't do
Io manually *)
module No_io = struct
module Io = struct end
end
https://github.com/janestreet/jbuilder/blob/0c2228e7bc7f5667a4ca2c982feb76130156ec99/src/import.ml#L524
0
function numeral($s, $t1, $t3, $t5)
{
$s = intval($s) % 100;
$z2 = intval($s / 10);
$z3 = $s % 10;
return ($z3 == 0) || ($z3 > 4) || ($z2 == 1)
? $t5
: (($z3 > 1) && ($z3 < 5) ? $t3 : $t1);
}
function fileSizeInKB($size)
{
if ($size < 1024) {
return intval($size) . ' ' . numeral($size, 'байт', 'байта', 'байтов');
} else {
$size /= 1024;
if ($size < 1024)
return intval($size) . ' КБ';
else
return intval($size / 1024) . ' МБ';
}
}
high top pluralization method
+1
...
private enum CSPTitle {
CONTENT_SECURITY_POLICY, X_CONTENT_SECURITY_POLICY, X_WEBKIT_CSP;
public String getName() {
return WordUtils.capitalizeFully(this.name(), new char[] { '_' }).replace('_', '-');
}
}
...
public Map<String, String> getHeaders(boolean disableXWebkitCspHeader, StringBuilder cspHeaderBodyBuilder){
Map<String, String> cspHeaders = new HashMap<>();
for (CSPTitle cspTitle : CSPTitle.values()) {
if (disableXWebkitCspHeader && CSPTitle.X_WEBKIT_CSP.equals(cspTitle)) {
continue;
}
String cspHeaderBody = cspHeaderBodyBuilder.toString();
if (CSPTitle.X_CONTENT_SECURITY_POLICY.equals(cspTitle)) {
cspHeaderBody = processXCSPHeader(cspHeaderBody);
}
cspHeaders.put(cspTitle.getName(), cspHeaderBody.trim());
}
return cspHeaders;
}
....
0
public ReadFile(string path)
{
byte[] BinFile = File.ReadAllBytes(path);
if (((IEnumerable<byte>) BinFile).Count<byte>() <= 25)
return;
this._Version = BinFile[0].ToString() + "." + BinFile[1].ToString() + "." + BinFile[2].ToString();
}
Я вам тут израильского инжиниринга принёс. Читаем файл, читаем версию.
В этом коде прекрасно всё...
−2
PHP - самое большое говно которое я встречал. Стив Джобс
−6
#include <stdio.h>
//аналог стрингбилдеру который есть в java!!!
#define NUM 1000 //максимальный размер строки
typedef struct {
char str[NUM];
} StringBuilder;
void append(StringBuilder *sb, char *str) //добавление строки
{
sprintf(sb->str, "%s%s", sb->str, str); //гениально и просто хули
}
void setLength(StringBuilder *sb, int s)
{
if(s > NUM || s < 0) return; //жуть
sb->str[s]='\0'; //гениальнетибл!
}
int main()
{
StringBuilder sb;
sprintf(sb.str, "Привет америкосам");
printf("%s\n", sb.str);
append(&sb, ", я вас уделаю!");
printf("%s\n", sb.str);
setLength(&sb, 2);
printf("%s\n", sb.str);
setLength(&sb, 0);
printf("%s\n", sb.str);
return 0;
}
понос или не понос вот в чем вопрос
+2
import os
import argparse
import sys
parser = argparse.ArgumentParser(description='tree')
parser.add_argument('path',type=str,)
parser.add_argument('-fo','--folders_only',action='store_true',)
parser.add_argument('-i','--include',type=str,action='store',)
parser.add_argument('-e','--exclude',type=str,action='store',)
parser.add_argument('-a','--all',action='store_true',)
parser.add_argument('-f','--full_name',action='store_true',)
args = parser.parse_args()
print(sys.argv[1])
if args.include:
itext = args.include
if args.exclude:
etext = args.exclude
def divine_crutch(path, n):
dir = os.listdir(path)
for i in range(len(dir)):
if os.path.isfile(path + '\\' + dir[i]):
if not(args.folders_only):
if not(args.include and itext not in dir[i]):
if not(args.exclude and etext in dir[i]):
if not(not(args.all) and dir[i][0] == '.') and not(args.full_name):
print(n*' ', dir[i])
elif args.full_name and not(not(args.all) and dir[i][0] == '.'):
print(n*' ' ,path + '\\' + dir[i])
if os.path.isdir(path + '\\' + dir[i]):
if not(not(args.all) and dir[i][0] == '.') and not(args.full_name):
print(n*' ', dir[i])
elif args.full_name and not(not(args.all) and dir[i][0] == '.'):
print(n*' ' ,path + '\\' + dir[i])
n += 4
divine_crutch(path + '\\' + dir[i], n)
n -= 4
divine_crutch(sys.argv[1], 4)
Рекурсивный велосипед на костыльной тяге. Сей экземпляр является "аналогом системной утилиты tree под линукс". При подходящей фазе луны и выполнении условий ритуала чёрной магии, способен захавать 16 гигов оперативки и крашнуть систему. Прекрасный способ выстрелить в ногу на питоне. Достойное место в моей кунсткамере.
+1
def with_batched_ids(count, ids)
if ids.is_a? Array
if ids.length > 1
ids.each_slice(count) do |ids|
yield(ids)
end
else
yield(ids)
end
else
yield(ids)
end
end
Заshitное программирование и просто красивая портянка из yield - end - else. Как на ровном месте придумать целый метод.