-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+94
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
/**
* Interface for string cleaners. Defines method that takes a string to perform cleaning and returns
* cleaned string.
*
* @author Король Абстракций.
* @version 1.0 29.04.2011
*
*/
public interface StringCleaner {
//---------------------------------------------------------------------------------------------
/**
* Cleans given string. Returns cleaned string.
* @param string String to clean
* @return Cleaned string
* @throws NullPointerException <code>If string == null</code>
* @since 1.0
*/
public String clean(String string);
//---------------------------------------------------------------------------------------------
}
// Далее реализации.
public abstract class SymbolStringCleaner implements StringCleaner { ... }
public final class AllSymbolStringCleaner extends SymbolStringCleaner { ... }
public final class RepeatedSymbolStringCleaner extends SymbolStringCleaner { ... }
public class TrimStringCleaner extends SymbolStringCleaner { ... }
public final class CombinedStringCleaner implements StringCleaner { ... }
// Пример использования.
public class StringCleanerFactory {
private static final char END_OF_LINE_SYMBOL = '\n';
public static synchronized StringCleaner createCommonStringCleaner() {
char[] symbolsToExclude = new char[] {' ', END_OF_LINE_SYMBOL};
StringCleaner repeatedSymbolsCleaner = new RepeatedSymbolStringCleaner(symbolsToExclude);
StringCleaner trimCleaner = new TrimStringCleaner(symbolsToExclude, true, true);
CombinedStringCleaner resultCleaner = new CombinedStringCleaner();
resultCleaner.add(repeatedSymbolsCleaner);
resultCleaner.add(trimCleaner);
return resultCleaner;
}
}
// В реале выходит что-то вроде
return str.trim().replace(" \n", '');
Очистка строк огнем инквизиции еше никогда не была настолько абстрактной.
P.S.
Я удалял этот StringCleaner API 3 раза, и каждый раз наши адепты стринг клинеров под любым
предлогом поднимали это г***о из анналов ада (svn history). Последний раз я сдался и этот
ёжик теперь живет с нами.
enikey,
21 Октября 2011
-
+164
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
function trim(s)
{
var i,j;
for (i = 0; i < s.length && s.charAt(i) == " "; i++);
for (j = s.length-1; j >= 0 && s.charAt(j) == " "; j--);
if (i<=j)
return s.substring(i, j+1);
else
return '';
}
opzab,
19 Октября 2011
-
+158
- 1
- 2
- 3
- 4
- 5
$f=file('[путь к файлу]');
shuffle($f);
$f[0] - первая случайная строка
$f[1] - вторая случайная строка
$f[2] - третья случайная строка
вот PHP еще. если например несколько строк надо. ну и оптимальнее чем предложено выше.
http://megaobzor.com/forum-top-77608.html
Наверху было классическое
$quote=file('words.txt');
echo $quote[rand(0,count($quote)-1)];
Несомненно, оптимальнее. Особенно, если строчек эдак тыщ сто.
Кстати, предлагаю начать очередной холивар по поводу того, как с самыми меньшими затратами вынуть из файла рандомную строчку :)
7ion,
02 Февраля 2011
-
+154
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
function openSQLConnection($data)
{
$db_host = $data["host"];
$db_user = $data["login"];
$db_pass = $data["pass"];
$db_name = $data["db"];
mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
}
Суровый SQL-коннектор, взято из скриптов платежной системы nextpay[ru]
zenn,
20 Января 2011
-
−79
- 1
- 2
- 3
- 4
- 5
- 6
ga = {} --gay/pure lua style
GA = ga --1337 men style
GlobalAdmin = ga --Java style
GlObAlAdMiN = ga --xxx asked :D
globalAdmin = ga --C style
globaladmin = ga --other plain lua style
Долго не могли решить как назвать глобальную таблицу в lua... лучшего решения не нашли.
Alexsey,
10 Сентября 2010
-
+217
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
mov ebx, [sKey]
mov ecx, 31
l9:
;----------loop------------
fprem
shr ebx,1
jnc if9
.......
if9:
fmul st0,st0
;----------loop------------
loop l9
реабилитируюсь за пост несвежего, но смешного говна немного раньше
3.14159265,
07 Мая 2010
-
+144.9
- 1
<a href="javascript:void(0)" onclick="this.parentNode.submit(); return false;">Добавить</a>
в ответ на http://govnokod.ru/1994 и длинный флуд в коментах.
говнокод или нормально?
tinimi,
20 Октября 2009
-
0
#192: https://govnokod.ru/28886 https://govnokod.xyz/_28886
#193: https://govnokod.ru/28911 https://govnokod.xyz/_28911
#194: https://govnokod.ru/28914 https://govnokod.xyz/_28914
#195: https://govnokod.ru/28917 https://govnokod.xyz/_28917
#196: https://govnokod.ru/28925 https://govnokod.xyz/_28925
#197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
#198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
#199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
#200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
#201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
#202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
#203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
#204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
#205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
#206: https://govnokod.ru/28991 https://govnokod.xyz/_28991
#207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
#208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
#209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
#210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
#211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
#212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
#213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
#214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
#215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
#216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
#217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
#218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
#219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
#220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
#221: https://govnokod.ru/29185 https://govnokod.xyz/_29185
nepeKamHblu_nemyx,
22 Октября 2025
-
−8
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
class C
{
val: number;
constructor()
{
this.val = 2;
}
}
function o(val? : C)
{
print(val?.val);
}
function main()
{
o(new C());
o(null);
o();
}
Новый говнокод подоспел.... а как тебе такое слабый ужасный С/C++ ... ты так умеешь?
Результат работы:
C:\temp>C:\dev\TypeScriptCompiler\__build\tsc\bin\tsc.exe --emit=jit --opt --shared-libs=C:\dev\TypeScriptCompiler\__build\tsc\bin\TypeScriptRuntime.dll C:\temp\1.ts
2
0
0
ASD_77,
20 Декабря 2021
-
+3
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
// https://deadlockempire.github.io/
// Игра, где надо играть за планировщик чтоб вызвать дедлок
// https://deadlockempire.github.io/#2-flags
// First Army
while (true) {
while (flag != false) {
;
}
flag = true;
critical_section();
flag = false;
}
// Second Army
while (true) {
while (flag != false) {
;
}
flag = true;
critical_section();
flag = false;
}
The day finally came. The Deadlock Empire opened its gates and from them surged massive amounts of soldiers, loyal servants of the evil Parallel Wizard. The Wizard has many strengths - his armies are fast, and he can do a lot of stuff that we can't. But now he set out to conquer the world, and we cannot have that.
You are our best Scheduler, commander! We have fewer troops and simpler ones, so we will need your help. Already two armies of the Deadlock Empire are approaching our border keeps. They are poorly equipped and poorly trained, however. You might be able to desync them and break their morale.
j123123,
20 Февраля 2021