- 1
- 2
URI uri = new URI("http://themoneyconverter.com/USD/rss.xml");
Document doc = db.parse(uri.toString());
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+83
URI uri = new URI("http://themoneyconverter.com/USD/rss.xml");
Document doc = db.parse(uri.toString());
Умей передавать строки правильно, падаван
+145
;
Пример реализации абстрактного класса
https://lh6.googleusercontent.com/-rKfFtpL_K1A/Tuh34-faW_I/AAAAAAAAAi8/B05ygbQKIu8/w402/abstract_class.png
+980
private string doubleToString(double v)
{
if (v < 0)
return "-" + (-(int)v).ToString() + "." + (-(v - (int)v) * 10000000).ToString("0000000.");
return ((int)v).ToString() + "." + ((v - (int)v) * 10000000).ToString("0000000.");
}
Превращаем double в строку. Разделитель - надо точку, а то "блин, он ставит запятую, SQL-сервер потом это не понимает" (с)
+153
'email' => array('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', 'Введите правильный e-mail, пожалуйста.')
Вот такая проверка валидности email
+137
#define MAKEPTR(p,o) (LPVOID) ( (DWORD)p + (DWORD)o )
#define WRITE_OPCODE(pCode, x) \
res = WriteProcessMemory( hProcess, pCode, &x, sizeof(x), &nWritten ); \
if( !res ) return FALSE; \
pCode = MAKEPTR(pCode,sizeof(x))
#define WRITE_DWORD(pCode, x) \
res = WriteProcessMemory( hProcess, pCode, &x, sizeof(x), &nWritten ); \
if( !res ) return FALSE; \
pCode = MAKEPTR(pCode,sizeof(x))
макрос "сюрприз" хоть бы назвал яснее типа
WRITE_OPCODE_AND_RETURN_VAL_IF_FAIL
но чем так писать лучше уж условие не прятать
http://ospy.googlecode.com/svn/!svn/bc/2/trunk/Agent/hooking.cpp
−120
-(NSString*) getPackName:(int)index
{
NSString *res=nil;
switch (index)
{
case 1:
res = @"Classic";
break;
case 2:
res = @"Wood";
break;
case 3:
res = @"Cowbell";
break;
case 4:
res = @"Metal";
break;
case 5:
res = @"Electro";
break;
default:
res = @"unknow";
break;
}
return res;
}
Если не ошибаюсь, за тем же авторством, что и предыдущий.
+162
/*
* Функция получает выбор пользователя о типе доставки
* проверяет ИД полученного ордера
* и передает ордерИД и delivery_name
*/
public function actionSelectDelivery($OrderId = 1)
{
$modules = array();
foreach($this->module->components as $k => $dir)
{
$modules[$k] = $dir['show_name'];
}
$model = new Delivery();
$model->order_id = $OrderId;
if(isset($_POST['Delivery']))
{
$model->attributes = $_POST['Delivery'];
$params = $this->module->getParams();
$b = false;
if(isset($OrderId))
{
$modelOrder = CActiveRecord::model($params['OrderModel'])->findByPk($OrderId);
if(!isset($modelOrder))
$b = true;
}
else
$b = true;
if(!$b) {
$url = $this->createUrl('/delivery/default/createD', array( 'OrderId' => $OrderId, 'DeliveryName' => $model->delivery_name));
}
else
echo 'Error with order #' . $OrderId;
}
$this->render(__FUNCTION__, array(
'modules' => $modules,
'model' => $model,
)
);
}
−115
@try {
NSMutableArray *items = nil;
if(isGrouped){
items = [NSMutableArray arrayWithArray:[_sortedItemsDict objectForKey:[_alphabet objectAtIndex:section]]];
}else{
items = _itemsArray;
}
[cell.textLabel setText:[[items objectAtIndex:row] name]?[[items objectAtIndex:row] name]:@"No Title"];
if([[items objectAtIndex:row] isKindOfClass:[Song class]]){
Song *song = (Song*)[items objectAtIndex:row];
[cell.detailTextLabel setText:[NSString stringWithFormat:@"%@ %@", [song albumName]?[song albumName]:[NSString string], [song artistName]]?[song artistName]:[NSString string]];
if([song isAvailableAtItunes])
NSLog(@"%@ %d", [song name], [song ID]);
[cell setTag:[song ID]];
}else if([[items objectAtIndex:row] isKindOfClass:[Album class]]){
[cell.detailTextLabel setText:[NSString stringWithFormat:@"%@", [[items objectAtIndex:row] artistName]]?[[items objectAtIndex:row] artistName]:[NSString string]];
}else if([[items objectAtIndex:row] isKindOfClass:[Podcast class]] || [[items objectAtIndex:row] isKindOfClass:[Audiobook class]]){
[cell setTag:[[items objectAtIndex:row]ID]];
}
if(!isFromSelfLibrary){
if(items && ([[items objectAtIndex:row] isKindOfClass:[Song class]] || [[items objectAtIndex:row] isKindOfClass:[Podcast class]] || [[items objectAtIndex:row] isKindOfClass:[Audiobook class]])){
if([[items objectAtIndex:row]isAvailableAtItunes]){
for(UIView *view in [cell subviews]){
if(view.tag == 111){
[view setHidden:NO];
}
}
}else{
[[DataController instance] checkItem:[items objectAtIndex:row]];
}
[cellsDict setValue:cell forKey:[NSString stringWithFormat:@"%d",[cell tag]]];
}
}
if(items && ![[items objectAtIndex:row] isKindOfClass:[Song class]]
&& ![[items objectAtIndex:row] isKindOfClass:[Podcast class]]
&& ![[items objectAtIndex:row] isKindOfClass:[Audiobook class]])
{
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
[cell.textLabel setTextColor:[UIColor whiteColor]];
[cell.textLabel setShadowColor:[UIColor blackColor]];
[cell.textLabel setShadowOffset:CGSizeMake(0, 1)];
[cell.detailTextLabel setTextColor:[UIColor lightGrayColor]];
[cell.detailTextLabel setShadowOffset:CGSizeMake(0, 1)];
[cell.detailTextLabel setShadowColor:[UIColor blackColor]];
[tableView deselectRowAtIndexPath: indexPath animated: YES];
}
@catch (NSException *exception) {
NSLog(@"olo1");
}
Не то, чтобы отлов исключения меня печалит.... :'(
+156
case "delete":
$id=$_GET['id'];
if(!isset($id)){
// no id? GTFO
header('Location: index.php?go=manage_costumes&act=view');
exit();
}else{
// id exists
...
)))
+159
private function isBonusAddOK($code,$ffStr)
{
switch($code)
{
case 1:if(
($this->isBFFOK($ffStr,40) || $this->isBFFOK($ffStr,38) || $this->isBFFOK($ffStr,37)) &&
$this->isBFFOK($ffStr,24) && $this->isBFFOK($ffStr,19) &&
($this->isBFFOK($ffStr,42) || $this->isBFFOK($ffStr,43) || $this->isBFFOK($ffStr,44))
)return true;return false;
case 6:if(
($this->isBFFOK($ffStr,40) || $this->isBFFOK($ffStr,38) || $this->isBFFOK($ffStr,37)) &&
$this->isBFFOK($ffStr,24) && $this->isBFFOK($ffStr,20) &&
($this->isBFFOK($ffStr,42) || $this->isBFFOK($ffStr,43) || $this->isBFFOK($ffStr,44))
)return true;return false;
case 11:if(
$this->isBFFOK($ffStr,24) &&
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
$this->isBFFOK($ffStr,62) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5))
)return true;return false;
case 14:if(
$this->isBFFOK($ffStr,24) &&
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
$this->isBFFOK($ffStr,61) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5))
)return true;return false;
case 17:if(
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5)) &&
$this->isBFFOK($ffStr,17)
)return true;return false;
case 20:if(
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5)) &&
$this->isBFFOK($ffStr,25) && $this->isBFFOK($ffStr,21)
)return true;return false;
case 23:if(
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5)) &&
$this->isBFFOK($ffStr,21)
)return true;return false;
.... еще куча строк до значения 88
default: return true;
}
}
private function isBFFOK($ffStr,$pos)
{
$val = substr($ffStr,$pos,1);//echo $pos.':'.$val;var_dump(($val != '0'));echo ' ';
return ($val != '0');
/*if($val == 0)return false;
ИфЗебок