- 1
- 2
- 3
- 4
- 5
- 6
int strnlen(const char *s, int size)
{
int i;
for(i=0; i<size; i++) if(!*s) break;
return i;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+110
int strnlen(const char *s, int size)
{
int i;
for(i=0; i<size; i++) if(!*s) break;
return i;
}
+139
List<string> duplicities = new List<string>();
foreach (var localItem in FileCollectionLocal)
{
foreach (var remoteItem in FileCollectionRemote)
{
if (localItem.FileName == remoteItem.FileName)
{
duplicities.Add(localItem.FileName);
}
}
}
+129
> echo 1 >1.cp
> echo 1 >1.cpp
> echo 1 >1.cppp
> dir /b *.cp
1.cp
> dir /b *.cpp
1.cpp
1.cppp
Баг в FindFirstFile/FindNextFile, показан на виндовом dir для простоты демонстрации. Призрак DOS'а жив даже в семерке...
−161
create temp table data (id serial, o1 money(16,2) default 0, o2 money(16,2) default 0,
o3 money(16,2) default 0, o4 money(16,2) default 0, o5 money(16,2) default 0,
o6 money(16,2) default 0, o7 money(16,2) default 0, o8 money(16,2) default 0,
o9 money(16,2) default 0, o10 money(16,2) default 0, o11 money(16,2) default 0,
o12 money(16,2) default 0, o13 money(16,2) default 0, o14 money(16,2) default 0,
o15 money(16,2) default 0, o16 money(16,2) default 0, o17 money(16,2) default 0,
o18 money(16,2) default 0, o19 money(16,2) default 0, o20 money(16,2) default 0,
o21 money(16,2) default 0, o22 money(16,2) default 0, o23 money(16,2) default 0,
o24 money(16,2) default 0, o25 money(16,2) default 0, o26 money(16,2) default 0,
o27 money(16,2) default 0, o28 money(16,2) default 0, o29 money(16,2) default 0,
o30 money(16,2) default 0, o31 money(16,2) default 0, f1 money(16,2) default 0,
f2 money(16,2) default 0, f3 money(16,2) default 0, f4 money(16,2) default 0,
f5 money(16,2) default 0, f6 money(16,2) default 0, f7 money(16,2) default 0,
f8 money(16,2) default 0, f9 money(16,2) default 0, f10 money(16,2) default 0,
f11 money(16,2) default 0, f12 money(16,2) default 0, f13 money(16,2) default 0,
f14 money(16,2) default 0, f15 money(16,2) default 0, f16 money(16,2) default 0,
f17 money(16,2) default 0, f18 money(16,2) default 0, f19 money(16,2) default 0,
f20 money(16,2) default 0, f21 money(16,2) default 0, f22 money(16,2) default 0,
f23 money(16,2) default 0, f24 money(16,2) default 0, f25 money(16,2) default 0,
f26 money(16,2) default 0, f27 money(16,2) default 0, f28 money(16,2) default 0,
f29 money(16,2) default 0, f30 money(16,2) default 0, f31 money(16,2) default 0,
ftot money(16,2) default 0)
... must be funny in the rich man's world ...
+54
<?php
class ArrObj implements ArrayAccess, Countable, Iterator
{
protected $_data = array();
protected $_indexes = array();
protected $_pos = 0;
public function __construct($data = array())
{
$this->_data = $data;
}
public function offsetGet($name)
{
if($isset = isset($this->_data[$name])) return $this->_data[$name];
$this->_data[$name] = new self();
return $isset ? $this->_data[$name] : null;
}
public function offsetSet($name, $value)
{
if(is_array($value)) $value = new self($value);
$this->_data[$name] = $value;
$this->_indexes[] = $name;
return $value;
}
public function offsetUnset($name)
{
unset($this->_data[$name]);
$this->_indexes = array_merge(array_diff($this->_indexes, array($name)));
}
public function offsetExists($name)
{
return isset($this->_data[$name]);
}
public function count()
{
return count($this->_data);
}
public function rewind()
{
$this->_pos = 0;
}
public function current()
{
return $this->_data[$this->_indexes[$this->_pos]];
}
public function key()
{
return $this->_indexes[$this->_pos];
}
public function next()
{
++$this->_pos;
}
public function valid()
{
return isset($this->_indexes[$this->_pos]);
}
}
?>
+14
/*!
* \brief Checks for a file existence
*/
inline bool IsFolderExist( const boost::filesystem::path &path )
{
return boost::filesystem::exists( path ) && boost::filesystem::is_directory( path );
}
/*!
* \brief Checks for a folder existence
*/
inline bool IsFileExist( const boost::filesystem::path &path )
{
return boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path );
}
Нашёл у себя в проекте. Кручу верчу - обмануть хочу). Про то, что даже правильные комментарии тут нафиг не нужны - я уже молчу.
+49
If($z["timeout"]==1 || $z['timeout']==3 || $z['timeout']==4 || $z['timeout']==5 || $z['timeout']==7 || $z['timeout']==10) {
} else {
$z['timeout'] = 3;
}
'<>' и 'or' ? неее, не слышали!
−113
http://lab.madscience.nl/oo.sh.txt
ООП-фаги, набигайте!
+121
#Creates an array with the frequencies from C2 to C5, 37 notes in all
for j from 1 to 37
if j = 1
notes [j] = 65.41 # лёгкие пути не нужны
endif
if j = 2
notes [j] = 69.30
endif
# ...дальше понятно...
endfor
# <...>
#Determining whether or not the scale contains C
#This determines how many notes of the 37 possible must be included.
noCList [1] = 3 # опа, а вот тут уже научились числовые индексы использовать
noCList [2] = 5
noCList [3] = 7
noCList [4] = 10
noCList [5] = 12
noC = 0
for n from 1 to 5
if 'starter' = noCList['n']
noC = 1
endif
endfor
#If there is a C...
if noC = 0
#The for loop mathematically selects the scale notes to use
for m from 1 to 22
if 'm' = 1
noteind = 'starter'
endif
if 'm' = 2
noteind = 'starter' + 2
if 'noteind' > 37
noteind = 'noteind' - 36
endif
endif
# ...ага-ага...
scalenotes ['m'] = notes['noteind']
endfor
#If there is not a C...
else
for m from 1 to 21
if 'm' = 1
noteind = 'starter'
endif
if 'm' = 2
noteind = 'starter' + 2
if 'noteind' > 37
noteind = 'noteind' - 36
endif
endif
# ...так точно...
scalenotes ['m'] = notes['noteind']
endfor
endif
# <...>
#Add new pitch information
#For each point, we move the freq to the closest scale note
for q from 1 to 'numPoints'
#The original freq of pitch
currentfreq = pitches['q']
#A starting threhold for difference between original and a musical note
diff = 50
#If there is C in the scale, making 22 possible notes to tune to...
if 'noC' = 0
#For loop finds the lowest difference between original pitch and a musical note
for c from 1 to 22
diff2 = abs('currentfreq' - scalenotes['c'])
if 'diff2' < 'diff'
diff = 'diff2'
noteindex = 'c'
endif
endfor
#Otherwise if there is not a C...
else
for c from 1 to 21
diff2 = abs('currentfreq' - scalenotes['c'])
if 'diff2' < 'diff'
diff = 'diff2'
noteindex = 'c'
endif
endfor
endif
#Add point at the original time with the new pitch
Add point... times['q'] scalenotes['noteindex']
endfor
http://schyzm.wordpress.com/2012/12/05/fun-with-praat-a-script-for-auto-tune/
Скрипт питч-коррекции для речевого анализатора Praat на встроенном языке сценариев. Не знаю, это афтар так жжот или язык располагает к черезжопию, но что-то тут воняет однозначно.
+12
int n, a[n]; //n - количество элементов
void qs(int* s_arr, int first, int last) {
int i = first, j = last, x = s_arr[(first + last) / 2];
do {
while (s_arr[i] < x) i++;
while (s_arr[j] > x) j--;
if(i <= j) {
if (i < j) swap(s_arr[i], s_arr[j]);
i++;
j--; }}
while (i <= j);
if (i < last) {
qs(s_arr, i, last); }
if (first < j) {
qs(s_arr, first,j); }}
Оттуда