- 1
- 2
- 3
- 4
- 5
- 6
for (int i = 0; i <= 10000; i++)
{
if (a[i]=='a')
a[i] == "000";
continue;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+49
for (int i = 0; i <= 10000; i++)
{
if (a[i]=='a')
a[i] == "000";
continue;
}
Цикл, который в строке a меняет все символы 'a' на три ноля. Говнолабка одногруппницы.
+57
float factor = ((float)sizeof(char) / sizeof(wchar_t));
fileSize = (long)((float)fileSize * factor);
вот так выглядит деление на sizeof(wchar_t) :)
+161
var list = [ ];
// hidden elements
list[ NaN ] = 'this-element-always-is-last'; // max index
list[ Number.MAX_VALUE ] = 'this-is-smallest';
list[ Infinity ] = 'this-just-infinity';
// list.length == 0; // true
Делать нечего в селе, мы сидим навеселе. Всех с пятницей!
+144
while (1) { // Не все знают логические значения
...
}
for (;;) // Ещё хуже
{ ... }
+127
['10','10','10','10'].map(parseInt)
Результат:
[10, NaN, 2, 3]
+154
// Цитата №1: массив регулярных выражений из введённых пользователем строк
var strings = what.filter(function(e){ return e.replace(/s+/g,'').length; }).map(function(e){ var re = new RegExp(e, 'g' + (ignoreCase ? 'i' : '')); return re; });
// Цитата №2: проверяется наличие введённых строк в тексте и выводит результаты
function processText(pid, cid, text){
if(strings.every(function(re){
return re.test(text);
})){
// совпало
// тут выводится информация о совпадении для поста/комментария
// кроме вывода в консоль побочных эффектов нет
....
}
}
// Цитата №3: запуск поиска
posts.forEach(function(post){
processText(post.id, null, post.author.name + ' ' + post.text);
processText(post.id, null, post.author.name + ' ' + post.description);
post.comments.forEach(function(comment){
processText(post.id, comment.id, comment.author.name + ' ' + comment.text);
});
});
Цитаты из скрипта поиска по ГК.
Казалось бы, write-only питушня, работает - не трогать. Но, прочитав, http://govnokod.ru/16577#comment246821, решил поискать упоминания доктора по званию. Открываю найденный пост X, а там не все упоминания найдены. Меняю список постов, в которых искать - для X меняется список найденных комментариев.
Откуда такая питушня? processText почти чистая, strings, posts не меняется. Может, вывод на консоль как-то влияет?
Все волосы на жопе вырвал пока нашел в чем ошибка.
Внимание, вопрос. В чем гавно? (c) ursus
+158
class TestThis
{
public $property = 'property';
public function test1()
{
$this->this($this, new ArrayObject);
$this['wierd'] = true;
print_r($this);
print_r($this->property . PHP_EOL);
return $this;
}
public function test2()
{
print_r($this);
}
public function this(&$object, $value)
{
$object = $value;
}
}
(new TestThis)->test1()->test2();
Вопрос к самому похапе.
Так вот нельзя:
$this = че-нибудь
"Cannot re-assign $this"
А вот как выше можно!
+152
<?php
class Config {
/* ... */
public function __construct ()
{
// Читаем настройки из дефолтного файла
$ini = parse_ini_file(dirname(dirname(__FILE__)).'/'.$this->config_file);
// Записываем настройку как переменную класса
foreach($ini as $var=>$value)
$this->vars[$var] = $value;
/* ... */
Взято из файла api/config.php из Simpla CMS.
Нельзя было $this->vars = parse_ini_file(dirname(dirname(__FILE__) ).'/'.$this->config_file); написать что ли?
+163
//проверяем, не извлечены ли данные пользователя из базы. Если нет, то он не вошел, либо пароль в сессии неверный. Выводим окно для входа. Но мы не будем его выводить для вошедших, им оно уже не нужно.
Не замысловатый комментарий из истории одного проекта
+136
switch(event->touch_point) {
case 5:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x5);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y5);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
// printk("===x2 = %d,y2 = %d ====\n",event->x2,event->y2);
case 4:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x4);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y4);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
// printk("===x2 = %d,y2 = %d ====\n",event->x2,event->y2);
case 3:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x3);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y3);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
// printk("===x2 = %d,y2 = %d ====\n",event->x2,event->y2);
case 2:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x2);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y2);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
// printk("===x2 = %d,y2 = %d ====\n",event->x2,event->y2);
case 1:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x1);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y1);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 1);
input_mt_sync(data->input_dev);
printk("===x1 = %d,y1 = %d ====\n",event->x1,event->y1);
default:
// printk("==touch_point default =\n");
break;
}
Автору платили за строки?
Из драйвера тачскрина ft5x0x