- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
char str[STR_LEN + 1];
strncpy(str, inpust_str, STR_LEN);
xxx[STR_LEN] = '\0';
str[ strlen(str) ] = ':';
str[ strlen(str) + 1 ] = '1';
str[ strlen(str) + 2 ] = '\0';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+96
char str[STR_LEN + 1];
strncpy(str, inpust_str, STR_LEN);
xxx[STR_LEN] = '\0';
str[ strlen(str) ] = ':';
str[ strlen(str) + 1 ] = '1';
str[ strlen(str) + 2 ] = '\0';
Попытка добавить ":1" к строке.
Первым же "str[ strlen(str) ] = ':';" гробим нулевой символ в конце строки. Дальнейшие вызовы "strlen" - просто фигня какая-то. Ну и портим память.
+152.6
function str_replace ( search, replace, subject ) { // Replace all occurrences of the search string with the replacement string
//
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Gabriel Paderni
if(!(replace instanceof Array)){
replace=new Array(replace);
if(search instanceof Array){//If search is an array and replace is a string, then this replacement string is used for every value of search
while(search.length>replace.length){
replace[replace.length]=replace[0];
}
}
}
if(!(search instanceof Array))search=new Array(search);
while(search.length>replace.length){//If replace has fewer values than search , then an empty string is used for the rest of replacement values
replace[replace.length]='';
}
if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
for(k in subject){
subject[k]=str_replace(search,replace,subject[k]);
}
return subject;
}
for(var k=0; k<search.length; k++){
var i = subject.indexOf(search[k]);
while(i>-1){
subject = subject.replace(search[k], replace[k]);
i = subject.indexOf(search[k],i);
}
}
return subject;
}
function str_replace(search, replace, subject) { return subject.split(search).join(replace);}
+147
<?php
if (preg_match('/^mysql/', $string == 1)) {
$dsn = $string;
}
###
###
###
?>
+124.8
varnamebegin // начало имени новой переменной
a // имя новой переменной
varnameend // конец имени новой переменной
varvaluebegin // начало значения новой переменной
newarray // новый массив
varvalueend // конец значения новой переменной
varcallbegin // начало имени вызываемой переменной
a // имя вызываемой переменной
varcallend // конец имени вызываемой переменной
push // добавить элементы в массив
lcobjectsbegin // начало области добавляемых элементов
bg // начало значения элемента массива
codedn // code — символ, d — префикс для цифр, n — спец-символ для цифры "0"
end // конец значения элемента массива
bg // начало значения элемента массива
codedo // code — символ, d — префикс для цифр, n — спец-символ для цифры "1"
end // конец значения элемента массива
lcobjectsend // конец области добавляемых элементов
functioninit // аналог ()
Создание массива с содержимым [0, 1] на одном из эзотерических ЯП. Фишка в том, что убраны все знаки препинания, цифры и т.д., оставлены лишь прописные латинские буквы.
Интересно, как на таком ЯП будет выглядеть полностью валидная проверка E-Mail (наподобии этой — ex-parrot.com/pdw/Mail-RFC822-Address.html) ?
+111.6
private ArrayList MNK(Matrix x, ArrayList y) {
normalization(ref x);
for (int i = 0; i < x.N; i++)
for (int j = 0; j < x.M; j++)
x.data[i, j] = Chebyshev.function(x.data[i,j],POWER_POLYNOM);
Matrix yNew = Matrix.CreateMatrixFromArrayList(y);
Matrix tranc = x.Tranc_Matrix(x);
Matrix temp = x.Obernena_Matrix(x.Mul_Matrix(tranc, x));
temp = x.Mul_Matrix(temp, tranc);
temp = x.Mul_Matrix(temp, yNew);
yNew = yNew.Mul_Matrix(x,temp);
return (returnValue(yNew, y));
}
//****************************************************
#region
private static ArrayList returnValue(Matrix yNew, ArrayList y)
{
ArrayList t = new ArrayList();
Random r = new Random();
double k = 2;
for (int i = 0; i < y.Count; i++)
{
if (y.GetHashCode() == y1.GetHashCode())
k = 1;
if (y.GetHashCode() == y2.GetHashCode())
k = 4000;
if (y.GetHashCode() == y3.GetHashCode())
k = 1000000;
t.Add((double)y[i] + ((double)(r.NextDouble() * k - k/2)));
}
return t;
}
#endregion
вот как тру системные аналитики пишут свои прогнозы))))))))))
+157.4
while (count(array_diff(array_keys($rows), $roots)) > 0)
{
$theLeaves = $this->_getLeaves($rows);
foreach ($theLeaves as $leafId)
{
if(isset($rows[$rows[$leafId]['parent_id']]['Menu']['data']) and
!is_array($rows[$rows[$leafId]['parent_id']]['Menu']['data']))
if(!is_array($rows[$rows[$leafId]['parent_id']]['Menu']['data']))
unset($rows[$rows[$leafId]['parent_id']]['Menu']['data']);
if(isset($rows[$rows[$leafId]['parent_id']]['data']) and
!is_array($rows[$rows[$leafId]['parent_id']]['data']))
if(!is_array($rows[$rows[$leafId]['parent_id']]['data']))
unset($rows[$rows[$leafId]['parent_id']]['data']);
$rows[$rows[$leafId]['parent_id']]['data'][] = $rows[$leafId];
unset($rows[$leafId]);
}
}
пришел проектик на доработку. сижу, пытаюсь разобраться
+75.4
if (!Float.valueOf("0.0").equals(price.getActualPrice()))
{
return true;
}
Сравнение чисел (float) нездоровым способом.
+166.3
function smla(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':)';}
function smls(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='>( ';}
function smld(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':D';}
function smlf(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='B)';}
function smlg(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='%)';}
function smlh(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':(';}
function smlj(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':o';}
function smlw(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='^_^';}
function smlk(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='<_<';}
function smll(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=';)';}
function smlq(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':p';}
Ещё один китаец. Вставляет смайлы в текстовое поле вот таким вот кодом. Источник — http://mirtorrent.ru/css/pppm.js
+161.8
$tpl->assign("L_OPENER", ($arr[7] == 40 || $arr[7] == 41 || $arr[7] == 42) ? 'opener.opener' : 'opener');
Вот так в один из шаблонов в зависимости от одного из параметров передаётся сами видите что. Почему так? Потому что бесчётное количество людей переделывали код. По мне, так это уже перебор.
+163.2
var idTa; //id of the textarea (param to makeWhizzyWig)
//OTHER GLOBALS
var oW, sel, rng, papa, trail, ppw, wn=window; //Whizzy contentWindow, current sel, range, parent, DOM path, popwindow;
var sels='';
var buts='';
var vals=new Array();
var opts=new Array();
var dobut=new Array();
//...
w('<div style="width:'+taWidth+'" onmouseover="c(\''+idTa+'\')"><div id="CONTROLS'+idTa+'" class="wzCtrl" unselectable="on">');
//...
function c(id) {//set current whizzy
if (id=="" || whizzies.join().indexOf(id)=='-1') return;
if (id!=idTa){
idTa=id;
try {oW=o("whizzy"+id).contentWindow;} catch(e){alert('set current: '+id);}
if (oW) {if(oW.focus)oW.focus();wn.status=oW.document.body.id; }
}
}
//...
Хтоническое порождение сумрачного гения
Все параметры редакторы лежат в global'ах. Но что делать если редакторов на странице несколько?
Правильно: mouse over!
http://www.unverse.net/wysiwyg.html