- 1
- 2
- 3
- 4
- 5
- 6
function Podergatsya($i)
{
$i++;
$i--;
return $i;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+43
function Podergatsya($i)
{
$i++;
$i--;
return $i;
}
Индусская CMS
+137
void riffoser_track_writeriff(struct riffoser_track * track,char * filename,riffoser_samplerate_t samplerate,riffoser_bitspersample_t bitspersample) {
FILE * fp;
unsigned long i1,i2,i3,i4,i5,i6,fpi;
unsigned char c1,bytespersample;
unsigned char * skipbuf;
float fret,val;
long ival;
unsigned char nomorewaves;
riffoser_channel_t chan;
bytespersample=bitspersample/8;
fp=fopen(filename,"wb");
i1=track->channels*samplerate*bytespersample*track->length;
i2=4+24+8+i1+(i1%2>0?1:0);
riffoser_writestr("RIFF");
riffoser_writeint(4,4+24+8+i1+(i1%2>0?1:0));
riffoser_writestr("WAVEfmt ");
riffoser_writeint(4,16);
riffoser_writeint(2,1);
riffoser_writeint(2,track->channels);
riffoser_writeint(4,samplerate);
riffoser_writeint(4,bytespersample*track->channels*samplerate);
riffoser_writeint(2,bytespersample*track->channels);
riffoser_writeint(2,bytespersample*8);
riffoser_writestr("data");
riffoser_writeint(4,i1);
if (i1%2>0)
riffoser_writeint(1,0);
i1=0;
i3=track->waves_count;
i6=0;
nomorewaves=0;
while (1) {
chan=i1%track->channels;
if (i3==track->waves_count&&!nomorewaves) {
i5=i1;
0&&printf("%lu: finding nearest wave...\n",i1);
for (i2=0;i2<track->waves_count;i2++){
if ((track->wavestates[i2]->state==RIFFOSER_WAVESTATE_IDLE)&&(((i3==track->waves_count))||(RIFFOSER_RENDER___FROM(track->wavestates[i2])<=i5))&&(RIFFOSER_RENDER___FROM(track->wavestates[i2])>=i6)) {
0&&printf("%lu: found wave %lu with from %f\n",i1,i2,RIFFOSER_RENDER___FROM(track->wavestates[i2]));
i3=i2;
i5=RIFFOSER_RENDER___FROM(track->wavestates[i2]);
}
else {
0&&printf("%lu: skipping wave %lu\n",i1,i2);
}
}
if (i3!=track->waves_count)
0&&printf("next wave will be %lu at %f\n",i3,RIFFOSER_RENDER___FROM(track->wavestates[i3]));
else nomorewaves=1;
}
c1=0;
val=0;
for (i2=0;i2<track->waves_count;i2++){
if (track->wavestates[i2]->state==RIFFOSER_WAVESTATE_RENDERING) {
if (RIFFOSER_RENDER___TO(track->wavestates[i2])<i1) {
track->wavestates[i2]->state=RIFFOSER_WAVESTATE_FINISHED;
0&&printf("%lu: wave %lu finished\n",i1,i2);
} else {
if (track->wavestates[i2]->channel==chan) {
// printf("correct channel\n");
track->wavestates[i2]->samplenum++;
if (track->wavestates[i2]->samplenum>RIFFOSER_RENDER___WSC(track->waves[i2]))
track->wavestates[i2]->samplenum-=RIFFOSER_RENDER___WSC(track->waves[i2]);
0&&printf("%lu: rendering wave %lu (%f-%f), samplenum is %f (%f%%)\n",i1,i2,RIFFOSER_RENDER___FROM(track->wavestates[i2]),RIFFOSER_RENDER___TO(track->wavestates[i2]),track->wavestates[i2]->samplenum,RIFFOSER_RENDER___WPP(track->waves[i2],track->wavestates[i2]->samplenum));
RIFFOSER_WAVE_FUNC(track->waves[i2],RIFFOSER_RENDER___WPP(track->waves[i2],track->wavestates[i2]->samplenum));
fret=fret*track->waves[i2]->amplitude/200;
// replace for now
val=fret;
}
else {
// printf("wrong channel ( %u / %u )\n",track->wavestates[i2]->channel,chan);
}
c1=1;
}
}
}
if (bytespersample==1) {
ival=round(val*2.56)-128;
if (ival>127)
ival=127;
}
else if (bytespersample==2) {
ival=round(val*655.36);
if (ival>65535)
ival=65535;
}
else if (bytespersample==4) {
ival=round(val*42949672.96);
if (ival>4294967295)
ival=4294967295;
}
riffoser_writeint(bytespersample,ival);
if (c1==0) {
if (i3!=track->waves_count) {
0&&printf("%lu: warping to position %lu\n",i1,i5);
i4=(i5-i1)*bytespersample;
skipbuf=malloc(i4);
memset(skipbuf,0,i4);
riffoser_writebuf(i4,skipbuf);
Полная версия - https://github.com/anon4ik/riffoser/blob/master/libriffoser.c
+128
[Record] variant ItemPatternMatched: PatternMatchedBase, IPatternMatched
_matchByLexemeValue:option[string]
public Match(source:SourceLexemes, namedLinkDictionary:NamedLinkDictionary):MatchResult
match(source)
|[] => MatchResult.EndOfLexemes(source, namedLinkDictionary)
|lexeme_::lexemes_=> def updatedNamedLinkDictionary = updateNamedLinkDictionary(lexeme_::[], namedLinkDictionary);
def failure = MatchResult.Failure(source, namedLinkDictionary);
def success = MatchResult.Success(lexemes_, updatedNamedLinkDictionary);
match(_matchByLexemeValue)
|None | Some(lexemeValue_) when (lexemeValue_==lexeme_._value) =>
match(this, lexeme_._type)
|(Symbol, SourceLexeme.Type.Symbol) | (Identificator, SourceLexeme.Type.Identificator) | (Number, SourceLexeme.Type.Number) =>
success
|_ =>
failure
|_ =>
failure
|Symbol
|Identificator
|Number
Начальник, посмотрев на код, сказал, что NemerleGovno. Я не знаю, что ему ответить?
+72
if("all".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_ALL);
} else if("trace".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_TRACE);
} else if("debug".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_DEBUG);
} else if("info".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_INFO);
} else if("warn".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_WARN);
} else if("error".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_ERROR);
} else if("fatal".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_FATAL);
} else if("off".equalsIgnoreCase(lvl)) {
setLevel(SimpleLog.LOG_LEVEL_OFF);
}
Внутренности конструктора org.apache.commons.logging.impl.SimpleLo g
+137
static /*public*/ string GenerateRandomJpegName()
{
return GenerateRandomString() + ".jpg";
}
static string GenerateRandomString()
{
bool UseSigns = true;
bool UseUpperLetters = true;
bool UseLetters = true;
int Length;
NewLabel:
try
{
Length = new Random(DateTime.Now.Millisecond - DateTime.Now.Second + new Random(DateTime.Now.Millisecond).Next(0, 100) / new Random(DateTime.Now.Millisecond - DateTime.Now.Second).Next(0, 10)).Next(0, 100);
}
catch { goto NewLabel; }
string result = "C:/";
try
{
int Seed = 0;
char[] letters = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
char[] signs = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
List<char> keyWords = new List<char>();
List<char> upperLetters = new List<char>();
foreach (char c in letters)
upperLetters.Add(Convert.ToChar(c.ToString().ToUpper()));
if (UseLetters)
foreach (char c in letters)
keyWords.Add(c);
if (UseSigns)
foreach (char c in signs)
keyWords.Add(c);
if (UseUpperLetters)
foreach (char c in upperLetters)
keyWords.Add(c);
int MaxValue = keyWords.Count;
for (int i = 0; i <= Length; i++)
{
try
{
Random mainrand = new Random(Seed);
char RandChar = keyWords[mainrand.Next(0, MaxValue)];
result += RandChar;
Seed += DateTime.Now.Millisecond + Seed - new Random().Next(10) + new Random(DateTime.Now.Millisecond + 800 * 989 / 3).Next(10);
}
catch { continue; }
}
}
catch { }
return result;
}
Вместо одного вызова Path.GetRandomFileName
+79
List<String> list;
....
Long num = Long.parseLong( "" + list.size() );
Самый оригинальный способ конвертации int в Long, кот. встречал в проекте )
+41
int sheeps(int pole[10][10])
{
int i,j,f,k,r;
int rand_chislo, rand_chislo1, ts,s;
srand(time(NULL));
for (i=0;i<10;i++)
for (j=0;j<10;j++)
pole [i][j]=0;
do{ f=0;
rand_chislo = 0 + rand() %10;
rand_chislo1= 0 + rand() %10;
ts = 1+rand()%4;
if (ts==1) {for(i=0;i<3;i++) if(rand_chislo==i)f=1;}
if (ts==2) {for(i=7;i<10;i++) if(rand_chislo==i)f=1;}
if (ts==3) {for(i=0;i<3;i++) if(rand_chislo1==i)f=1;}
if (ts==4) {for(i=7;i<10;i++) if(rand_chislo1==i)f=1;}
}
while (f==1);
switch (ts){
case 1: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo-1][rand_chislo1]=1;
pole[rand_chislo-2][rand_chislo1]=1;pole[rand_chislo-3][rand_chislo1]=1; break;
case 2: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo+1][rand_chislo1]=1;
pole[rand_chislo+2][rand_chislo1]=1;pole[rand_chislo+3][rand_chislo1]=1; break;
case 3: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1-1]=1;
pole[rand_chislo][rand_chislo1-2]=1;pole[rand_chislo][rand_chislo1-3]=1;break;
case 4: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1+1]=1;
pole[rand_chislo][rand_chislo1+2]=1;pole[rand_chislo][rand_chislo1+3]=1; break; }
for (k=0;k<3;k++)
{
do{ f=0;
rand_chislo = 0 + rand() %10;
rand_chislo1= 0 + rand() %10;
ts = 1+rand()%4;
if (ts==1) {if(rand_chislo!=0){ for (i=rand_chislo-2;i<rand_chislo+2;i++)
for (j=rand_chislo1-1;j<=rand_chislo1+1;j++)
{if (pole[i][j]!=0){f=1;}}}else f=1; }
if (ts==2) {if (rand_chislo!=9) { for (i=rand_chislo-1;i<=rand_chislo+2;i++)
for (j=rand_chislo1-1;j<=rand_chislo1+1;j++)
{ if (pole[i][j]!=0){ f=1;}}}else f=1; }
if (ts==3) { if (rand_chislo1!=0) { for (i=rand_chislo-1;i<=rand_chislo+1;i++)
for (j=rand_chislo1-2;j<=rand_chislo1+1;j++)
{ if (pole[i][j]!=0){ f=1;}}}else f=1; }
if (ts==4) { if (rand_chislo1!=9) { for (i=rand_chislo-1;i<=rand_chislo+1;i++)
for (j=rand_chislo1-1;j<=rand_chislo1+2;j++)
{ if (pole[i][j]!=0){ f=1;}}}
else f=1; }
}
while (f==1);
switch (ts){
case 1: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo-1][rand_chislo1]=1; break;
case 2: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo+1][rand_chislo1]=1; break;
case 3: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1-1]=1;break;
case 4: pole[rand_chislo][rand_chislo1]=1; pole[rand_chislo][rand_chislo1+1]=1; break; }
}
for (k=0;k<2;k++)
{
do{ f=0;
rand_chislo = 0 + rand() %10;
rand_chislo1= 0 + rand() %10;
/*зесь еще 2 таких же while (if==1) и for k<3 и k<4 */
return pole[10][10];
}
курсовик первокурсника "морской бой". функция расстановки кораблей
+58
// что-то страшно мне стало
class Mysql{
private $db = null;
private $result = null;
//private $row = null;
function __construct($dbname,$dbuser,$dbpass,$dbhost){
$this->db = mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
mysql_select_db($dbname) or die ("<br>Invalid query: " . mysql_error());
mysql_query("SET NAMES utf8") or die ("<br>Invalid query: " . mysql_error());
}
function connect(){
if(!$this->db){
exit("Error connect BD!");
}
}
function query($query){
if(!$query){exit("No [query]");}
$this->result = $query = mysql_query($query) or die ("<br>Invalid query: " . mysql_error());
return $query;
}
}
−158
SELECT ft_login,fi_system,ft_password,fk_id
FROM users u
INNER JOIN taccountscontent t ON u.id = t.fk_id
WHERE u.id IN (select id from users where id=123)
Оригинал http://www.askdev.ru/question/16663/%D0%97%D0%B0%D0%BF%D1%80%D0%BE%D1%81-%D0%BA-%D0%91%D0%94-%D0%B8-%D1%86%D0%B8%D0%BA%D0%BB-While/
−160
<div class="comment-content">
<% if comment.body.include?('[/quote]') %>
<% @text = Array.new %>
<% summ = '' %>
<% @text = simple_format(comment.body).split(' ') %>
<% namecheck = false %>
<% contentcheck = false %>
<% quotestart = false %>
<% donothing = true %>
<% quotecount = 0 %>
<% count_quotes = 0 %>
<% @text.each do |t| %>
<% if t.include?('[/quote]') %>
<% count_quotes ||= 0 %>
<% count_quotes += 1 %>
<% end %>
<% end %>
<% @text.each do |t| %>
<% if t.include?('[/quote]') %>
<% contentcheck = false %>
<% namecheck = false %>
<% t = t.gsub('[/quote]', '</div></div>') %>
<% elsif t.include?('[quote=') %>
<% namecheck = true %>
<% donothing = false %>
<% t = t.gsub('[quote=', '') %>
<% elsif t.include?(']') %>
<% t = t.gsub(']', '') %>
<% end %>
<% if donothing == false %>
<% if contentcheck == true and namecheck == true and t != '' and t != '<p>' and t != '</p>' %>
<% t = '<div class=quotecontent>' + '<div class=quotestart>' + '<div class=quotename>' + 'Цитата - ' + t + '</div>' %>
<% contentcheck = true %>
<% namecheck = false %>
<% elsif contentcheck == true and t != '' and t != '<p>' and t != '</p>' %>
<% t = '<div class=quotecontent>' + t %>
<% contentcheck = false %>
<% elsif namecheck == true and t != '' and t != '<p>' and t != '</p>' %>
<% t = '<div class=quotestart>' + '<div class=quotename>' + 'Цитата - ' + t + '</div>' %>
<% namecheck = false %>
<% contentcheck = true %>
<% end %>
<% end %>
<% summ = summ + t + ' ' %>
<% end %>
<% else %>
<% summ = comment.body %>
<% end %>
<%=raw simple_format(summ) %>
</div>
Вьюха списка комментариев. Когда это попало к верстальщику - он был мягко говоря шокирован.