-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+162
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
javascript:(function () {
var nodes = document.querySelectorAll( 'span.hidden-text' );
for ( var i = 0; i < nodes.length; i++ ) {
/* Opera suck at this
nodes[i].classList.remove( 'entry-comment-hidden' );
*/
var classList = nodes[i].parentNode.className.split( /\s+/ );
var index = classList.indexOf( 'entry-comment-hidden' );
if ( index != -1 ) {
classList.splice( index, 1 );
}
else {
classList.push( 'entry-comment-hidden' );
}
nodes[i].parentNode.className = classList.join( ' ' );
}
})()
Посвящается анону-полуёбку, который нашёл хаккирский скрипт.
Олежка?
bugmenot,
15 Июля 2011
-
+955
- 1
- 2
- 3
- 4
- 5
- 6
static string foo()
{
int i = 0;
//code
return "some string "+ i++;
}
Irdis,
07 Июля 2011
-
+129
- 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
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
public void ReadFromFile()
{
LoadIntervals = new TimeIntervals(Color.Black);
StreamReader tReader = null;
tReader = File.OpenText("DefaultIntervals");
string income = null;
while ((income = tReader.ReadLine()) != null)
{
// string income = tReader.ReadLine();
string colorR = null; string colorG = null; string colorB = null; string colorA = null; string interval = null;
int i = 0;
for (i = 4; i < income.Length; i++)
{
if (income[i] != ',')
{
interval += income[i];
}
else { break; }
}
for (int a = i + 10; a < income.Length; a++)
{
if (income[a] != ',')
{
colorA += income[a];
}
else
{
for (int r = a + 4; r < income.Length; r++)
{
if (income[r] != ',')
{
colorR += income[r];
}
else
{
for (int g = r + 4; g < income.Length; g++)
if (income[g] != ',')
{
colorG += income[g];
}
else
{
for (int b = g + 4; b < income.Length; b++)
if (income[b] != ',')
{
if (income[b] != ']')
colorB += income[b];
}
else
{
break;
}
break;
}
break;
}
}
break;
}
}
TimePoint tp = new TimePoint(Convert.ToDouble(interval), Color.FromArgb(Convert.ToInt32(colorA), Color.FromArgb(Convert.ToInt32(colorR), Convert.ToInt32(colorG), Convert.ToInt32(colorB))));
LoadIntervals.Add(tp);
}
tReader.Close();
Intervals = LoadIntervals;
}
Так мы парсим файл конфигов вида. (Формат придуман автором кода)
Int=3,Color [A=223, R=253, G=4, B=38]
Int=10,Color [A=255, R=86, G=86, B=185]
Int=20,Color [A=200, R=255, G=215, B=0]
Int=50,Color [A=200, R=255, G=165, B=0]
lomomike,
15 Июня 2011
-
−357
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
chislo :: String -> Bool
chislo []=True
chislo (x:xs) =if (x=='1') then chislo xs
else if (x=='2') then chislo xs
else if (x=='3') then chislo xs
else if (x=='4') then chislo xs
else if (x=='5') then chislo xs
else if (x=='6') then chislo xs
else if (x=='7') then chislo xs
else if (x=='8') then chislo xs
else if (x=='9') then chislo xs
else if (x=='0') then chislo xs
else if (x=='.') then chislo xs
else False
haskell
resettik,
26 Мая 2011
-
+164
- 1
- 2
- 3
- 4
$data_array = file('./dir/file.txt'); //Прочитали файл в массив
$count = count($data_array); //Подсчитали количество элементов массива
$chislo = rand(0,$count-1); //Так как элементы массива имеют ключи с 0 до $count-1
echo $data_array[$chislo]; //Вот вам и произвольная строка из файла
Основная говнистость в том, что это статья, т.е. человек этому учит других, ни в чём не повинных людей.
DeaDrash,
07 Января 2011
-
+141
- 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
- 50
- 51
- 52
char *nvram_get(int index, char *name)
{
/* Initial value should be NULL */
char *recv = NULL;
//LIBNV_PRINT("--> nvram_get\n");
nvram_init(index);
recv = nvram_bufget(index, name);
//btw, we don't return NULL anymore!
if (!recv)
recv = "";
//Always need close nvram
nvram_close(index);
return recv;
}
char *nvram_bufget(int index, char *name)
{
int idx;
/* Initial value should be NULL */
static char *ret = NULL;
//LIBNV_PRINT("--> nvram_bufget %d\n", index);
LIBNV_CHECK_INDEX("");
LIBNV_CHECK_VALID();
idx = cache_idx(index, name);
if (-1 != idx) {
if (fb[index].cache[idx].value) {
//duplicate the value in case caller modify it
//Tom.Hung 2010-5-7, strdup() will cause memory leakage
//but if we return value directly, it will cause many other crash or delete value to nvram error.
ret = strdup(fb[index].cache[idx].value);
LIBNV_PRINT("bufget %d '%s'->'%s'\n", index, name, ret);
//btw, we don't return NULL anymore!
if (!ret)
ret = "";
return ret;
}
}
//no default value set?
//btw, we don't return NULL anymore!
LIBNV_PRINT("bufget %d '%s'->''(empty) Warning!\n", index, name);
return "";
}
Кусочек кода из библиотеки работы с nvram для железок на SoC Ralink. Китайцы плакали, кололись о утечки памяти, но продолжали настойчиво мешать указатели на статические строки с указателями на динамически выделенные в куче...
NiTr0man,
27 Декабря 2010
-
+118
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
static double SingleToDouble(Single v)
{
return double.Parse(v.ToString());
}
static void Scan()
{
double q = 0.0;
while (q <= 10.0)
{
Single s = (Single)q;
Double d = SingleToDouble(s);
if (d == q)
MessageBox.Show(q.ToString());
q = q + 0.1;
}
}
народ, кто-нибудь знает чем можно заменить код "return double.Parse(v.ToString());" в SingleToDouble?
"return v;" не подходит - на экран выводятся только 0, 0.5 и 4.5. А нужно чтобы все выводились 0, 0.1, 0.2 ... 0.9.
4eburashka,
16 Декабря 2010
-
+167
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
function suka($str){
$length = strlen($str);
for($i=1; $i<=$length; $i++){
$b = (-1)*$i;
$substrl .= substr($str, $b, 1);
}
echo $substrl;
}
$govno='jizni';
suka($govno);
Попросил соискателя написать функцию, которая перевернет строку. Просто хотелось посмотреть подход к коду.
zorbis,
23 Августа 2010
-
+82
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
<HTML>
<HEAD>
<TITLE>Коммерческий банк "ХОУМ-БАНК"</TITLE>
</HEAD>
<BODY>
<table border="0" width="100%">
<tr align="center">
<img src="/img/home.jpg" align="top">
</tr>
</table>
</BODY>
</HTML>
Сайт банка "Хоум-банк" (http://www.home-bank.ru). Никаких тебе пхп и жабаскрипт! Новое слово в сайтостроении! При изменении информации соответствующе фотошоппится картинка!
Неудивительно, что у банка отозвана лицензия: http://www.lenta.ru/news/2010/07/08/homebank/
Webkill,
08 Июля 2010
-
+116
- 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
class DllContainer
{
DllContainer()
{
// тут грузятся дллки в количестве N.
// LoadLibrary() + некоторые операции
}
~DllContainer()
{
// FreeLibrary() и т.п.
}
template <class T>
T* GetComponent(ComponentID id)
{
// аналог QueryInterface.
// ищет компонент, проверяет можно ли статик_кастить
// и вертает указатель нужного типа
}
};
class ComponentUser
{
void Method1()
{
DllContainer loader;
SomethingDoer* comp = loader.GetComponent<SomethingDoer>(ID1);
comp->DoSomething();
}
void Method2()
{
DllContainer loader;
SomethingElseDoer* comp = loader.GetComponent<SomethingElseDoer>(ID2);
comp->DoSomethingElse();
}
void MethodN()
{
DllContainer loader;
ShitPerformer* comp = loader.GetComponent<ShitPerformer>(IDN);
comp->PerformSomeShit();
}
};
недавно обнаружил код примерно такого плана.
крупный коммерческий проект...
g26g,
12 Мая 2010