- 1
http://lab.madscience.nl/oo.sh.txt
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−113
http://lab.madscience.nl/oo.sh.txt
ООП-фаги, набигайте!
+121
#Creates an array with the frequencies from C2 to C5, 37 notes in all
for j from 1 to 37
if j = 1
notes [j] = 65.41 # лёгкие пути не нужны
endif
if j = 2
notes [j] = 69.30
endif
# ...дальше понятно...
endfor
# <...>
#Determining whether or not the scale contains C
#This determines how many notes of the 37 possible must be included.
noCList [1] = 3 # опа, а вот тут уже научились числовые индексы использовать
noCList [2] = 5
noCList [3] = 7
noCList [4] = 10
noCList [5] = 12
noC = 0
for n from 1 to 5
if 'starter' = noCList['n']
noC = 1
endif
endfor
#If there is a C...
if noC = 0
#The for loop mathematically selects the scale notes to use
for m from 1 to 22
if 'm' = 1
noteind = 'starter'
endif
if 'm' = 2
noteind = 'starter' + 2
if 'noteind' > 37
noteind = 'noteind' - 36
endif
endif
# ...ага-ага...
scalenotes ['m'] = notes['noteind']
endfor
#If there is not a C...
else
for m from 1 to 21
if 'm' = 1
noteind = 'starter'
endif
if 'm' = 2
noteind = 'starter' + 2
if 'noteind' > 37
noteind = 'noteind' - 36
endif
endif
# ...так точно...
scalenotes ['m'] = notes['noteind']
endfor
endif
# <...>
#Add new pitch information
#For each point, we move the freq to the closest scale note
for q from 1 to 'numPoints'
#The original freq of pitch
currentfreq = pitches['q']
#A starting threhold for difference between original and a musical note
diff = 50
#If there is C in the scale, making 22 possible notes to tune to...
if 'noC' = 0
#For loop finds the lowest difference between original pitch and a musical note
for c from 1 to 22
diff2 = abs('currentfreq' - scalenotes['c'])
if 'diff2' < 'diff'
diff = 'diff2'
noteindex = 'c'
endif
endfor
#Otherwise if there is not a C...
else
for c from 1 to 21
diff2 = abs('currentfreq' - scalenotes['c'])
if 'diff2' < 'diff'
diff = 'diff2'
noteindex = 'c'
endif
endfor
endif
#Add point at the original time with the new pitch
Add point... times['q'] scalenotes['noteindex']
endfor
http://schyzm.wordpress.com/2012/12/05/fun-with-praat-a-script-for-auto-tune/
Скрипт питч-коррекции для речевого анализатора Praat на встроенном языке сценариев. Не знаю, это афтар так жжот или язык располагает к черезжопию, но что-то тут воняет однозначно.
+12
int n, a[n]; //n - количество элементов
void qs(int* s_arr, int first, int last) {
int i = first, j = last, x = s_arr[(first + last) / 2];
do {
while (s_arr[i] < x) i++;
while (s_arr[j] > x) j--;
if(i <= j) {
if (i < j) swap(s_arr[i], s_arr[j]);
i++;
j--; }}
while (i <= j);
if (i < last) {
qs(s_arr, i, last); }
if (first < j) {
qs(s_arr, first,j); }}
Оттуда
+42
function test($method)
{
$picfile = 'pic1.png';
$bgfile = 'output.png';
$background = 'pic2.png';
$foreground = 'pic3.png';
if ($method == 'Imagick') {
$img = new Imagick($picfile);
$mask = new Imagick($background);
$img->compositeImage($mask, imagick::COMPOSITE_COPYOPACITY, 0, 0);
$mask->destroy();
$overlay = new Imagick($foreground);
$img->compositeImage($overlay, imagick::COMPOSITE_OVER, 0, 0);
$overlay->destroy();
$img->setImageFormat('png');
file_put_contents($bgfile, $img->getImageBlob()); // $img->writeImage($bgfile) работает медленнее
$img->destroy();
} else if ($method == 'Wand') {
$img = NewMagickWand();
MagickReadImage($img, $picfile);
$mask = NewMagickWand();
MagickReadImage($mask, $background);
MagickCompositeImage($img, $mask, MW_CopyOpacityCompositeOp, 0, 0);
DestroyMagickWand($mask);
$overlay = NewMagickWand();
MagickReadImage($overlay, $foreground);
MagickCompositeImage($img, $overlay, MW_OverlayCompositeOp , 0, 0);
DestroyMagickWand($overlay);
MagickSetImageFormat($img, 'png');
file_put_contents($bgfile, MagickGetImagesBlob($img)); // ditto
DestroyMagickWand($img);
} else {
$cmdline = 'convert -compose copy-opacity ' . $picfile . ' ' . $background . ' -composite';
$cmdline .= ' -compose src-over ' . $foreground . ' -composite ' . $bgfile;
exec($cmdline);
}
}
$methods = array('Imagick', 'Wand', 'Command line');
foreach ($methods as $m) {
$start_time = microtime(true);
for ($i = 0; $i < 4; $i++) {
test($m);
}
$elapsed_time = microtime(true) - $start_time;
echo 'Method: ' . $m . '; elapsed ' . strval($elapsed_time) . PHP_EOL;
}
Результаты выполнения на локальной машине:
Method: Imagick; elapsed 0.45...
Method: Wand; elapsed 0.82...
Method: Command line; elapsed 0.87...
Результаты выполнения на VPS:
Method: Imagick; elapsed 79.64...
Method: Wand; elapsed 151.64...
Method: Command line; elapsed 46.49...
Что-то тут не так...
+163
type = ~~(Math.random()*5);
if (type == 0) type = 1;
else type = 0;
Кручу-верчу, вобщем, как обычно.
+54
// sys
if ($flag==1) {
$rr = implode("</B>, <B>",$nks1)."</B> и <B>".implode("</B>, <B>",$nks2);
} elseif ($flag==2) {
$rr = implode("</B>, <B>",$nks1)."</B> и <B>".implode("</B>, <B>",$nks2)."";
} else {
$rr = implode("</B>, <B>",$nks1)."</B> и <B>".implode("</B>, <B>",$nks2)."";
}
Это нашел в движке одной онлайн игры... Три проверки, но 1 и то же действие... Логика, мать её...
+116
public const string Checked = "☑";
public const string Unchecked = "☐";
Чекбокс
+55
<?php
// ... много строк до этого
echo "<table width=100% border=0>";
if ($row = mysql_fetch_array($result))
for ($i = 0; $i < mysql_num_fields($result); $i++):
if (mysql_field_name($result, $i) == "ID" || (mysql_field_name($result, $i) == "info") ||
mysql_field_name($result, $i) == "state" || (mysql_field_name($result, $i) == "date_st") ||
mysql_field_name($result, $i) == "date" || (mysql_field_name($result, $i) == "email") ||
mysql_field_name($result, $i) == "flag" || (mysql_field_name($result, $i) == "limit_time") ||
mysql_field_name($result, $i) == "cr_time" || mysql_field_name($result, $i) == "cr_money" ||
mysql_field_name($result, $i) == "flag" || (mysql_field_name($result, $i) == "info") ||
mysql_field_name($result, $i) == "attention" || mysql_field_name($result, $i) == "location" ||
mysql_field_name($result, $i) == "mailflag" || (mysql_field_name($result, $i) == "radio") ||
mysql_field_name($result, $i) == "radio30" || (mysql_field_name($result, $i) == "date_num") ||
mysql_field_name($result, $i) == "number" || mysql_field_name($result, $i) == "login_i"
|| mysql_field_name($result, $i) == "is_juridical")
{
if (mysql_field_name($result, $i) == "state")
{
echo "<select name=state style=\"background-color:red;color:white\"><option value=OPEN";
if ($row[$i] == "OPEN")
echo " selected ";
echo ">" . trans("OPEN") . "</option>\n";
echo "<option value=CLOSE";
if ($row[$i] == "CLOSE")
echo " selected ";
echo ">" . trans("CLOSE") . "</option></select\n";
}
elseif (mysql_field_name($result, $i) == "location")
{
genLeased($row[$i]);
}
elseif (mysql_field_name($result, $i) == "radio30" || mysql_field_name($result, $i) == "radio" ||
mysql_field_name($result, $i) == "mailflag" )
{
}
elseif (mysql_field_name($result, $i) == "date_st")
{
$ar = explode("-", $row[$i]);
echo "<b id=red>" . $ar[2] . "." . $ar[1] . "." . $ar[0] . "</b></td></tr>\n";
}
elseif (mysql_field_name($result, $i) == "date_num")
{
$ar = explode("-", $row[$i]);
$dnum = $ar[2] . "." . $ar[1] . "." . $ar[0];
echo "<b>" . $dnum . "</b></td></tr><tr><td><a href=\"contracts/index.php?user_id=" . $row['ID'] . "\">контракти</a></td></tr><tr><td colspan=2><hr noshade></td></tr>\n";
}
elseif (mysql_field_name($result, $i) == "date")
{
$ar = explode("-", $row[$i]);
$row[$i] = $ar[2] . "." . $ar[1] . "." . $ar[0];
echo "<input type=text name=date value=\"" . $row[$i] . "\"</td></tr>\n";
}
elseif (mysql_field_name($result, $i) == "info")
{
echo "<textarea rows=3 name=" . mysql_field_name($result, $i) . " >" . $row[$i] . "</textarea></td></tr>\n";
}
elseif (mysql_field_name($result, $i) == "attention")
{
echo "<textarea id=warn rows=3 name=" . mysql_field_name($result, $i) . " >" . $row[$i] . "</textarea></td></tr>\n";
}
// ... и так обрабатываем далее все поля
Разработчик сначала запросил результат с помощью mysql_fetch_array,
потом ищет название каждого поля с помощью mysql_field_name, функцией trans()
читает файлик со словарем и переводит название каждого поле.
Писалось не индусами, вариант "для количества" не прокатывает.
Поэтому я не могу даже предположить, что сподвигло автора на создание сего творения.
Файл содержит около 1400 строчек.
−90
def python_3():
try:
exec("print ''")
return False
except:
return True
Python 2: http://ideone.com/z4NADC
Python 3: http://ideone.com/IcpTUr
−139
CREATE TABLE `forums_list`(
`forum_id` int unsigned NOT NULL AUTO_INCREMENT,
...
`created` datetime NOT NULL DEFAULT NULL,
`updated` datetime NOT NULL DEFAULT NULL,