- 1
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java#L213
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+76
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java#L213
wtf?!
−117
[storeButton performSelectorInBackground:@selector(onTouchUp) withObject:nil];
...
-(void)onTouchUp{
[self setHighlighted:NO];
[self.storeNameLabel setHighlighted:NO];
[self.storeAddressLabel setHighlighted:NO];
[self.storePhoneLabel setHighlighted:NO];
[self.storeAddress2Label setHighlighted:NO];
}
+77
public CommandResult update() {
CommandResult res = null;
try {
long start = System.nanoTime();
res = _port.runCommand(_mongo.getDB("admin"), isMasterCmd);
long end = System.nanoTime();
float newPingMS = (end - start) / 1000000F;
if (!successfullyContacted)
_pingTimeMS = newPingMS;
else
_pingTimeMS = _pingTimeMS + ((newPingMS - _pingTimeMS) / latencySmoothFactor);
getLogger().log(Level.FINE, "Latency to " + _addr + " actual=" + newPingMS + " smoothed=" + _pingTimeMS);
successfullyContacted = true;
if (res == null) {
throw new MongoInternalException("Invalid null value returned from isMaster");
}
if (!_ok) {
getLogger().log(Level.INFO, "Server seen up: " + _addr);
}
_ok = true;
// max size was added in 1.8
if (res.containsField("maxBsonObjectSize")) {
_maxBsonObjectSize = (Integer) res.get("maxBsonObjectSize");
} else {
_maxBsonObjectSize = Bytes.MAX_OBJECT_SIZE;
}
} catch (Exception e) {
if (!((_ok) ? true : (Math.random() > 0.1))) {
return res;
}
final StringBuilder logError = (new StringBuilder("Server seen down: ")).append(_addr);
if (e instanceof IOException) {
logError.append(" - ").append(IOException.class.getName());
if (e.getMessage() != null) {
logError.append(" - message: ").append(e.getMessage());
}
getLogger().log(Level.WARNING, logError.toString());
} else {
getLogger().log(Level.WARNING, logError.toString(), e);
}
_ok = false;
}
return res;
}
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java
Незаметен.
−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));
}
Пыталась выбирать одну запись из таблицы и передавать ее на клиент.
По логике вещей должен быть более элегантный подход, но я о нем не знаю... :(
Если кто знает, то поделитесь.