- 1
if(ignoreSelection?[atml extraCharges]!=NULL:[atml extraCharges]&&![atml selectedAttribute])
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−105
if(ignoreSelection?[atml extraCharges]!=NULL:[atml extraCharges]&&![atml selectedAttribute])
Лесенки для слабаков!!
+155
if (!$left || !$right) return true;
$sql = "DELETE FROM {$this->_tableName} WHERE `user_id`=$user_id";
$this->_db->exec($sql);
if (!$this->_isTriggers) {
if (($right - $left) == 1) {
$sql = "UPDATE {$this->_tableName} SET `left`=IF(`left` >= $left,`left`-2,`left`),`right`=`right`-2 WHERE `right` >= $left";
} else {
$sql = "UPDATE {$this->_tableName} SET
`left`=IF(`left` BETWEEN $left AND $right,`left`-1,`left`),
`right`=IF(`right` BETWEEN $left AND $right,`right`-1,`right`),
`level`=IF(`left` BETWEEN $left AND $right,`level`-1,`level`),
`left`=IF(`left`>$right,`left`-2,`left`),
`right`=IF(`right`>$right,`right`-2,`right`)
WHERE `right` > $left
";
}
$this->_db->exec($sql);
Только ручной сбор запроса. Zend Db
−108
- (void) fixUIAfterRotation: (UIInterfaceOrientation) interfaceOrientation
{
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:UIInterfaceOrientationIsPortrait(interfaceOrientation)? @"bg_new.png":@"bg_new_90.png"]]];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString *htmlStr;
webError = NO;
orient = UIInterfaceOrientationIsPortrait(interfaceOrientation)? 1:2;
float width_ = [[UIScreen mainScreen] bounds].size.height;
viewNews.frame = isRotation? (UIInterfaceOrientationIsPortrait(interfaceOrientation)?
CGRectMake(0, 0, width_, 240):CGRectMake(0, 0, width_, width_ - 90)):(UIInterfaceOrientationIsPortrait(interfaceOrientation)? CGRectMake(0, 0, 320, width_ - 81):CGRectMake(0, 0, width_, 240));
isRotation = isRotation? NO:isRotation;
#if defined(PRO_PROJECT)
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
htmlStr = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled Document</title>
<style>body {margin:0px; padding:0px; font:13px arial; background:none;}
a {text-decoration:underline; color:#fbcf04; font-weight:bold; !important;} a:hover {text-decoration:none;}
.title{background:#575757 left top repeat-x; font:bold 15px Arial; color:#FFF; padding:14px 30px 0px 0px; height:31px;
border-bottom:1px solid #000000; line-height:14px}.titleIm{background:#575757 left top repeat-x; padding:13px 8px 13px 13px; height:31px;
border-bottom:1px solid #000000;}.news_body {border-top:1px solid #414141; padding:10px 14px 14px 14px;
color:#FFF; line-height:19px; background:#3d3d3d;}.news_body p {padding-top:0px;}</style></head>
<body><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"320\" height=\"388\"><tr><td width=\"75\" valign=\"top\" class=\"titleIm\">
<img src=%@ height=\"70\" width=\"70\"></td><td valign=\"top\" class=\"title\">%@
<div style=\"font:11px Arial; color:#858585; line-height:18px;\">%@</div></td></tr><tr>
<td colspan=\"2\" valign=\"top\" class=\"news_body\">%@</td></tr></table></body></html>",
imageName, [newsDescription objectForKey:@"titleNews"],
[CORENewsTitleList getDataString:[newsDescription objectForKey:@"dateNews"]],
[newsDescription objectForKey:@"discriptionNews"]];
}
else
{
htmlStr = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled Document</title>
<style>body {margin:0px; padding:0px; font:13px arial; background:none;}
a {text-decoration:underline; color:#fbcf04; font-weight:bold; !important;}a:hover {text-decoration:none;}
.title {background:#575757 left top repeat-x; font:bold 15px Arial; color:#FFF; padding:14px 30px 0px 0px; height:31px;
border-bottom:1px solid #000000; line-height:14px}.titleIm {background:#575757 left top repeat-x; padding:13px 8px 13px 13px; height:31px;
border-bottom:1px solid #000000;}.news_body {border-top:1px solid #414141; padding:10px 14px 14px 14px;
color:#FFF; line-height:19px; background:#3d3d3d;}.news_body p {padding-top:0px;}</style></head>
<body><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"%f\" height=\"240\"><tr><td width=\"75\" valign=\"top\" class=\"titleIm\">
<img src=%@ height=\"70\" width=\"70\"></td><td valign=\"top\" class=\"title\">%@
<div style=\"font:11px Arial; color:#858585; line-height:18px;\">%@</div></td></tr><tr>
<td colspan=\"2\" valign=\"top\" class=\"news_body\">%@</td></tr></table></body></html>",
width_, imageName, [newsDescription objectForKey:@"titleNews"],
[CORENewsTitleList getDataString:[newsDescription objectForKey:@"dateNews"]],
[newsDescription objectForKey:@"discriptionNews"]];
}
#else
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
// тот же упоротый код, что и выше, за исключением цветов для бэкграунда и надписей.
}
else
{
// тот же упоротый код, что и выше, за исключением цветов для бэкграунда и надписей.
}
#endif
[viewNews loadHTMLString:htmlStr baseURL:baseURL];
}
Поворачиваем вебвью во вью-контроллере, который может использоваться в 2 проектах, имеющих различные темы (отличается бэкграунд и цвет надписей).
+150
if (isset($_trade) && $_trade == 'wholesale') {
header('Location: /market/order/');
exit;
}
else {
header('Location: /market/order/');
exit;
}
Нашел в коде магазина
+136
public static bool isLaterThan()
{
string hd = DateTime.Now.ToString("tt", new CultureInfo("en-US")).ToLower();
if (hd == "pm")
return false;
return DateTime.Now.Hour < 1;
}
уже есть час ночи?
+129
public static MvcHtmlString TextWithLinks(this HtmlHelper helper, string inputStr)
{
string html = String.Empty;
Uri url;
string[] arr = inputStr.Split(' ');
for (int i = 0; i < arr.Length; i++)
{
if (i != 0)
{
html += " ";
}
if (Uri.TryCreate(arr[i],UriKind.Absolute, out url))
{
html += String.Format("<a href='{0}' target='_blank'>{0}</a>", url.AbsoluteUri);
}else
{
html += arr[i];
}
}
return new MvcHtmlString(html);
}
+143
$result_set = mysql_query("SELECT * FROM $db.$class_table WHERE class_id = ".$_POST["class_id"]." ORDER BY `class_name_short` ASC LIMIT 0 , 1;")
or die("Invalid query: " . mysql_error());
while ($row = mysql_fetch_array($result_set, MYSQL_ASSOC))
{
echo(json_encode($row));
}
Пыталась выбирать одну запись из таблицы и передавать ее на клиент.
По логике вещей должен быть более элегантный подход, но я о нем не знаю... :(
Если кто знает, то поделитесь.
+14
std::set_unexpected( [] () {} );
Студия достала и не позволяла обрабатывать исключения, а они нужны были для демонстрации работы, в итоге навесил такой костыль и включил SEH исключения в параметрах компиляции.
+138
// Преобразует BCD формат в число
private static int BCDToInt(byte bIn)
{
return ((((bIn / 0x10) * 10) + bIn) - ((bIn / 0x10) * 0x10));
}
// Преобразует число в BCD формат
private static byte IntToBCD(int value)
{
value -= (value / 100) * 100;
byte bTH = (byte)(value / 10);
byte bTL = (byte)(value - (bTH * 10));
return (byte)(bTL + ((byte)(bTH << 4)));
}
навеяло сложными запутывающими большими и маленькими индейцами для элитных программистов
референс-код от партнеров для конверсии binary-coded decimal вперёд и взад
чтобы как бы верно срослось между ихним с# и нашим сраным с++
+108
bool getSelectedFile(wchar_t *out, bool skip) {
HWND hwndFind = GetForegroundWindow();
TCHAR g_szPath[BUF_SIZE];
TCHAR g_szItem[BUF_SIZE];
//g_szPath[0] = TEXT('\0');
//g_szItem[0] = TEXT('\0');
memset(g_szPath, 0, sizeof(TCHAR) * BUF_SIZE);
memset(g_szItem, 0, sizeof(TCHAR) * BUF_SIZE);
IShellWindows *psw;
if(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw) != S_OK) return false;
VARIANT v;
v.vt = VT_I4;
IDispatch *pdisp;
bool fFound = false;
bool pExtracted = false;
bool nExtracted = false;
for (V_I4(&v) = 0; !fFound && psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
IWebBrowserApp *pwba;
if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
HWND hwndWBA;
if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA)) && hwndWBA == hwndFind) {
fFound = true;
IServiceProvider *psp;
if(SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
IShellBrowser *psb;
if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
IShellView *psv;
if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
IFolderView *pfv;
if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
IPersistFolder2 *ppf2;
if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
LPITEMIDLIST pidlFolder;
if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
if(SHGetPathFromIDList(pidlFolder, g_szPath)) {
pExtracted = true;
if(skip) {
lstrcpy(out, g_szPath);
out[lstrlen(g_szPath)] = 0;
return true;
}
}
int iFocus;
if(SUCCEEDED(pfv->GetFocusedItem(&iFocus))) {
LPITEMIDLIST pidlItem;
if (SUCCEEDED(pfv->Item(iFocus, &pidlItem))) {
IShellFolder *psf;
if (SUCCEEDED(ppf2->QueryInterface(IID_IShellFolder, (void**)&psf))) {
STRRET str;
if(SUCCEEDED(psf->GetDisplayNameOf(pidlItem, SHGDN_INFOLDER, &str))) {
StrRetToBuf(&str, pidlItem, g_szItem, 1024);
nExtracted = true;
int psz = lstrlen(g_szPath);
int isz = lstrlen(g_szItem);
if(pExtracted) {
lstrcpy(out, g_szPath);
out[psz] = '\\';
}
lstrcpy(out+psz+1, g_szItem);
out[psz + isz + 2] = 0;
}
psf->Release();
}
CoTaskMemFree(pidlItem);
}
}
CoTaskMemFree(pidlFolder);
}
ppf2->Release();
}
pfv->Release();
}
psv->Release();
}
psb->Release();
}
psp->Release();
}
}
pwba->Release();
}
pdisp->Release();
}
psw->Release();
return (pExtracted && nExtracted);
}
Две очаровательных (говно) лестницы из какой-то очередной переназначалки горячих клавиш в Windows.
Оригинал тут: https://github.com/mapseamoff/KeyBinder/blob/master/ShellHelper/ShellHelper/main.cpp