- 1
- 2
- 3
- 4
function striptags($variables_for_function=array()) {
if (!isset($variables_for_function[1])) {$variables_for_function[1]='';}
return strip_tags($variables_for_function[0], $variables_for_function[1]);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+51
function striptags($variables_for_function=array()) {
if (!isset($variables_for_function[1])) {$variables_for_function[1]='';}
return strip_tags($variables_for_function[0], $variables_for_function[1]);
}
Только сегодня и только для вас, безопасный strip_tags. Теперь с заSHITой от говнокодеров.
PHP Innovations.
+118
void dwflt_to_str(DWORD dw, char *pch, int &nsmb)
{
DWORD dw_a = dw;
char ch_a;
char tbldec[] = "0123456789";
nsmb = 0;
if (dw_a == 0) { pch[0] = '0'; nsmb++; goto lab2; }
while (dw_a != 0)
{
pch[nsmb] = tbldec[dw_a%10]; dw_a /= 10; nsmb++;
}
dw_a = nsmb/2;
while (dw_a)
{
ch_a = pch[nsmb - dw_a]; pch[nsmb - dw_a] = pch[dw_a - 1]; pch[dw_a - 1] = ch_a; dw_a--;
}
lab2:
pch[nsmb] = 0;
}
const int n_fr2 = 7; // - эта константа определяет фиксированное число цифр после точки в выводимой строке, представляющей float.
void float_to_str(float flt, char *pchar, int &nsmb)
{
int i, deg, ns_int, ns_frac;
double frac_dbl;
DWORD dw_f, mant, intg, fract;
DW_FL f_flt;
char szfl_int[16], szfl_frac[16];
f_flt.fl = flt;
dw_f = f_flt.dw;
if (dw_f == 0) { pchar[0] = '0'; pchar[1] = '.'; pchar[2] = '0'; pchar[3] = 0; nsmb = 3; return; }
if (dw_f & 0x80000000) { pchar[0] = '-'; } else { pchar[0] = '+'; }
deg = int((dw_f & 0x7F800000) >> 23) - 127;
mant = (dw_f & 0x007FFFFF) | 0x00800000;
if (deg == 0) { intg = 1; fract = dw_f & 0x007FFFFF; goto lab_1; }
if (deg > 0) { intg = mant >> (23 - deg); fract = ((dw_f & 0x007FFFFF) << deg) & 0x007FFFFF; goto lab_1; }
if (deg < 0) { intg = 0; fract = ((dw_f & 0x007FFFFF) | 0x00800000) >> (-deg); }
lab_1:
frac_dbl = double(fract)*1.1920928955078125;// 1.1920928955078125 = 10^n_fr2 / 2^23 = 10^7 / 2^23
fract = (int)frac_dbl;
dwflt_to_str(intg, szfl_int, ns_int);
nsmb = 1; i = ns_int; while (i) { pchar[i + 1] = szfl_int[i]; i--; } pchar[1] = szfl_int[0];
nsmb += ns_int; pchar[nsmb] = '.'; nsmb++;
dwflt_to_str(fract, szfl_frac, ns_frac); szfl_frac[n_fr2] = 0;
i = ns_frac; while (i) { szfl_frac[6 - ns_frac + i] = szfl_frac[i - 1]; i--; }
i = n_fr2 - ns_frac; while (i) { szfl_frac[i - 1] = '0'; i--; }
i = n_fr2 - 1; while (i) { pchar[nsmb + i] = szfl_frac[i]; i--; } pchar[nsmb] = szfl_frac[0];
nsmb += n_fr2; pchar[nsmb] = 0;
}
void float_to_str_exp(float flt, char *pchar, int &nsmb)
{
int i, deg, poli, ns_int, ns_frac, ns_poli;
double frac_dbl;
DWORD dw_f, mant, intg, fract;
DW_FL f_flt;
char szfl_int[16], szfl_frac[16];
f_flt.fl = flt;
dw_f = f_flt.dw;
if (dw_f == 0) { pchar[0] = '0'; pchar[1] = '.'; pchar[2] = '0'; pchar[3] = 0; nsmb = 3; return; }
if (dw_f & 0x80000000) { pchar[0] = '-'; } else { pchar[0] = '+'; }
deg = int((dw_f & 0x7F800000) >> 23) - 127;
mant = (dw_f & 0x007FFFFF) | 0x00800000;
if (deg == 0) { intg = 1; fract = dw_f & 0x007FFFFF; goto lab_1; }
if (deg > 0) { intg = mant >> (23 - deg); fract = ((dw_f & 0x007FFFFF) << deg) & 0x007FFFFF; goto lab_1; }
if (deg < 0) { intg = 0; fract = ((dw_f & 0x007FFFFF) | 0x00800000) >> (-deg); }
lab_1:
frac_dbl = double(fract)*1.1920928955078125;// 1.1920928955078125 = 10^n_fr2 / 2^23 = 10^7 / 2^23
fract = (int)frac_dbl;
dwflt_to_str(intg, szfl_int, ns_int);
dwflt_to_str(fract, szfl_frac, ns_frac); szfl_frac[n_fr2] = 0;
if (intg != 0)
{
nsmb = 1; i = ns_int; while (i) { pchar[i + 2] = szfl_int[i]; i--; } pchar[1] = szfl_int[0];
pchar[2] = '.'; nsmb += ns_int + 1; poli = ns_int - 1;
}
else
{
i = ns_frac - 1; while (i) { pchar[2 + i] = szfl_frac[i]; i--; } pchar[1] = szfl_frac[0];
pchar[2] = '.'; nsmb = 3;//nsmb += ns_frac + 1;
poli = ns_frac - n_fr2 - 1; goto lab_2;
}
i = ns_frac; while (i) { szfl_frac[6 - ns_frac + i] = szfl_frac[i - 1]; i--; }
i = n_fr2 - ns_frac; while (i) { szfl_frac[i - 1] = '0'; i--; }
i = n_fr2 - 1; while (i) { pchar[nsmb + i] = szfl_frac[i]; i--; } pchar[nsmb] = szfl_frac[0];
lab_2:
nsmb += n_fr2; pchar[nsmb] = 'E';
int_to_str(poli, &pchar[nsmb + 1], ns_poli);
nsmb += ns_poli + 1; pchar[nsmb] = 0;
}
оттуда
+34
if (date('dmY', $lmtime) === date('dmY')) {
Нужно было узнать, не сегодняшний ли день в отметке $lmtime.
+13
void SetInterruptHandler(int id, unsigned int offset) {
__asm cli;
unsigned int *idt = (unsigned int*)0;
idt[id*2+0] = 0x00080000 | (offset & 0x0000FFFF);
idt[id*2+1] = 0x00008E00 | (offset & 0xFFFF0000);
__asm sti;
}
Как и обещал в http://govnokod.ru/12413#comment166763, выкладываю исходник говнолоадера, запускающего 32-х битный сишный код с дискетки: https://github.com/bormand/tryos, хотя судя по всему никому это не интересно...
Если кому-то все-таки придет в голову странное желание это собрать - нужна вижуалка (к сожалению код написан лет 5 назад, когда я юзал вижуалку) и nasm. Путь к nasm прописываем в Makefile, запускаем nmake, полученный floppy.dsk можно скормить виртуалбоксу, или же зарезать на дискету, если удастся вспомнить как она выглядит...
UPD: Скрин http://rghost.ru/43035733.view
+127
<select name="animals">
<option value="1" addTags="<div class='kv'></div>">Медведь</option>
<option value="2" addTags="<input type='checkbox' />">Волк</option>
</select>
html в js - это прошлый век =)
http://www.xiper.net/collect/html-and-css-tricks/verstka-form/nice-select-jquery.html
−89
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def") {
options.ad_started();
var fn:Function = function ():void {
options.ad_finished();
};
setTimeout(fn, 100);
return;
}
сегодня в выпуске - как задизаблить мойшеадс лёгким движением руки в любой флешке, скомпиленной со стандартной либой
−107
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 6;
}
-(UITableViewCell *) tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *kCellIdentifier = @"";
switch (indexPath.row)
{
case 0:
kCellIdentifier = @"SpaceCell";
break;
case 1:
kCellIdentifier = @"LoginCell";
break;
case 2:
kCellIdentifier = @"PasswordCell";
break;
case 3:
kCellIdentifier = @"EmailCell";
break;
case 4:
kCellIdentifier = @"BirhtdayCell";
break;
default:
kCellIdentifier = @"ForgotCell";
break;
}
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];
if (indexPath.row == 1)
{
[self backgroundCells:cell fileImage:@"top_downlayer.png"];
self.loginTextField.text = userName;
self.loginTextField.placeholder = @"User Name";
self.loginTextField.frame = CGRectMake(10.0f, 10.0f, 300.0f, 30.0f);
[cell.contentView addSubview:self.loginTextField];
}
else if (indexPath.row == 2)
{
[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
self.passwordTextField.text = password;
self.passwordTextField.placeholder = @"Password";
self.passwordTextField.frame = CGRectMake(10.0f, 8.0f, 300.0f, 30.0f);
[cell.contentView addSubview:self.passwordTextField];
}
else if (indexPath.row == 3)
{
[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
self.email.text = emailString;
self.email.placeholder = @"Email";
self.email.frame = CGRectMake(10.0f, 7.0f, 300.0f, 30.0f);
[cell.contentView addSubview:self.email];
}
else if (indexPath.row == 4)
{
[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
UIImageView *inputIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"input_login.png"]];
inputIV.frame = CGRectMake(20, 8, 280, 28);
[inputIV setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[cell addSubview:inputIV];
[inputIV release];
if (![resultsDate.text length])
{
UILabel *birhtdayLabel = [[UILabel alloc] initWithFrame:CGRectMake(29, 12, 150, 20)];
birhtdayLabel.text = @"Birthday";
[birhtdayLabel setTextAlignment:UITextAlignmentLeft];
[birhtdayLabel setFont: [UIFont fontWithName:@"Arial" size:17.0f]];
[birhtdayLabel setTextColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.25]];
[birhtdayLabel setHighlightedTextColor:[UIColor whiteColor]];
[birhtdayLabel setBackgroundColor:[UIColor clearColor]];
[birhtdayLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[cell addSubview:birhtdayLabel];
[birhtdayLabel release];
}
else
[cell addSubview:resultsDate];
}
else if (indexPath.row == 5)
{
[self backgroundCells:cell fileImage:@"down_downlayer.png"];
UIImage *buttonBackgroundPressed = [UIImage imageNamed:@"search_btn_act.png"];
UIImage *buttonBackground = [UIImage imageNamed:@"search_btn.png"];
UIButton *singUpButton = [CustomButton buttonWithTitle:@"SIGN UP" target:self selector:@selector(singUpTouchAction:) frame:CGRectMake(20, 6, 280, 28) image:buttonBackground imagePressed:buttonBackgroundPressed];
singUpButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
singUpButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[cell addSubview:singUpButton];
}
return cell;
}
Старый проект. Открыл класс наугад.
Так кто-то строил форму для регистрации юзера. Каждое поле в форме - уникально.
+55
$result["rg"][count($result["rg"])-1]["status"][] = Array();
$c_res = count($result["rg"][count($result["rg"])-1]["status"])-1;
$result["rg"][count($result["rg"])-1]["status"][$c_res] = $arr_source_data[$i];
Им за число строк платят, что ли?
+157
var onClear = function(e)
{
if(e.value == "Логин" || e.value == "Пароль")
{
e.value = "";
}
}
<input type="text" name="login" value="Логин" onclick="onClear(this);"/>
Ох блин...
+23
volatile bool b;
class BoolKeeper
{
bool &fb;
public:
BoolKeeper(bool &b)
{
while (b);
b = true;
}
~BoolKeeper ()
{
b = false;
}
}
void Thread1
{
BoolKeeper ololo(b);
// что-то делаем
}
void Thread2
{
// что-то делаем
BoolKeeper ololo(b);
// что-то делаем, причём в этом месте нам важен факт, что Thread1 не выполняется
}
http://www.gamedev.ru/flame/forum/?id=171558