- 1
- 2
- 3
- 4
const int size = 100000;
const int maxVal = 1e9;
for(int i = 0; i < n; i++)
values[i] = rand() % (maxVal + 1);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+3
const int size = 100000;
const int maxVal = 1e9;
for(int i = 0; i < n; i++)
values[i] = rand() % (maxVal + 1);
Код работает на вин32
+1
<?php $this->widget('bootstrap.widgets.TbButton', array(
'label' => 'Экспорт в Excel',
'type' => 'primary',
'url' => $this->createUrl('export'),
'htmlOptions' => array(
'target' => '_blank',
'onclick' => 'jQuery(this).attr(\'href\', jQuery(this).attr(\'href\').replace(/(\?.*)?$/, \'?\' + jQuery(this).closest(\'form\').serialize()))',
//'style' => 'float:right;',
),
)); ?>
Часто пытаюсь убедить людей, что Yii говно, но мои аргументы вечно парируют.
Как может здоровому человеку прийти в голову идея изобрести столь долбоёбский инструмент?
И ведь весь сраный Yii пропитан подобными высерами.
+2
function coolSplit(str, pattern) {
var result = [];
while(1){
var m = str.match(pattern);
if(!m) {
if(str) result.push(str);
return result;
}
if(m.index) result.push(str.substr(0, m.index));
result.push(str.substr(m.index, m[0].length));
str = str.substr(m.index + m[0].length);
}
}
Из шифроскрипта. https://github.com/1024--/govnokod.ru-userscripts/commit/898e6195b9799853b08a01834ce55f8d780757f3#diff-40cd32e1559d395399816968845cb034R151
coolSplit(str, /expr/) ≡ str.split(/(expr)/) // Говнокод обучающий
−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
+2
rates = rates.Join(filter, _=> filterItem.ToString(_), _ => _.ToString(), (_, _2) => _).ToList();
Не надо так.
+91
private static int NumberOfLeadingSpaces(string str)
{
str = str.TrimEnd();
return str.Length - str.Trim().Length;
}
Из моего проекта. Так я писал код 1.5 год назад.
Вместо того, чтобы пройтись циклом с начала строки, пока не встретиться символ, не являющийся пробелом.
+56
int GUIFont::getTextSize (std::string::iterator &begin, std::string::iterator &end ) {
int size = 0;
while(begin != end ) {
uint32_t id = utf8::unchecked::next (begin );
CharDescriptor *cd = chars- >getChar(id);
size += cd- >xadvance;
}
return size;
}
int GUIFont::getTextSize (std::string &text ) {
return getTextSize (text.begin (), text.end ());
}
int GUIFont::getTextSize (std::wstring &text ) {
std::string utf8text;
utf8::utf16to8 (text.begin (), text.end (), back_inserter (utf8text ));
return getTextSize (utf8text.begin (), utf8text.end ());
}
Вот так я зафейлил...
И что самое главное - студия сожрала и даже ворнинга не кинула, а эклипс ни в какую.
Без добрых людей на гейдеве не допер бы что к чему.
+157
foreach ($account->lists as $list) {
print "LIST Name: " . $list->name; echo ' '; echo ' '; echo ' '; print "LIST Id: " . $list->id;
echo "<br>";
}
Не говоря о том, что особой разницы между print и echo в ПХП нет, стоит отметить, что после «nbsp» пропущены точки с запятыми и всё тело этого фора можно было бы вывести одной строчкой.
+159
function redirect(){
setTimeout("redirect1();", 60000)
}
function redirect1(){
if(parent.lan_ipaddr == "192.168.1.1")
if(navigator.appName.indexOf("Microsoft") >= 0){
parent.location.reload();
//parent.location.href = "http://192.168.1.1/index.asp?t="+new Date().getTime();
}
else{
//parent.location.href = "http://192.168.1.1/";
parent.parent.location.href = parent.parent.location.href;
}
else{
parent.$('drword').innerHTML = "<#Setting_factorydefault_iphint#><br/>";
setTimeout("parent.hideLoading()",1000);
setTimeout("parent.dr_advise();",1000);
}
}
Решил тут посмотреть сорцы вебморды роутера
−97
jstemplate = ''
jstemplate += '$(document).ready(function () {'
jstemplate += ' $(document).on("click", ".im", function () {'
jstemplate += ' if ($(this).attr("src") != "") {'
jstemplate += ' $("#im").attr("src", $(this).attr("src"));'
jstemplate += ' $("#FixedBlack").show().fadeTo(200, 1);'
jstemplate += ' $("#im").show().fadeTo(0.5, 1);'
jstemplate += ' }'
jstemplate += ' });'
jstemplate += ' $(document).on("click", "#FixedBlack", function () {'
jstemplate += ' $("#im").hide();'
jstemplate += ' $("#FixedBlack").stop(true).fadeTo(200, 0, function () {'
jstemplate += ' $("#FixedBlack").hide();'
jstemplate += ' });'
jstemplate += ' });'
jstemplate += '});'
Это вместо того, чтобы положить шаблон в файл и спокойно прочитать его в переменную. nuff said.