- 1
- 2
- 3
- 4
- 5
- 6
- 7
Код конца 2014 года
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
isRetina = true;
else
isRetina = false;5
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−406
Код конца 2014 года
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
isRetina = true;
else
isRetina = false;5
−407
#define RETURN_CREATED_SGINGLETON_MUTABLE_ARRAY \
static NSMutableArray* _singletonArray = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_singletonArray = [[NSMutableArray alloc] init]; \
}); \
return _singletonArray;
Используется массив для хранения заданий. Эдакий самописный NSOperationQueue.
+780
public class B
{
private readonly List<M> ms = new List<M>();
// ...
public void Match(M m) { ms.Add(m); }
public int IndexOf(M m) { return ms.IndexOf(m) == 0 ? 0 : 1; }
// ...
}
public class M
{
// ...
public void Match(B b)
{
try { b.Match(this); }
catch (Exception e)
{
// ...
}
}
// ...
}
Угадай песню по говнокоду. Сложность: 2/10.
Можете минусовать, в общем-то.
+72
resultWhereClause += " AND (lower(concat(per.firstName,' ',per.lastName,' ',per.middleName)) like lower(#{utils.concat(\"%\", \"" + applicant + "\", \"%\")})";
resultWhereClause += " or lower(concat(per.lastName,' ',per.firstName,' ',per.middleName)) like lower(#{utils.concat(\"%\", \"" + applicant + "\", \"%\")})";
resultWhereClause += " or lower(concat(per.firstName,' ',per.middleName,' ',per.lastName)) like lower(#{utils.concat(\"%\", \"" + applicant + "\", \"%\")}))";
resultWhereClause += "))";
Изящный хак для (на самом деле нет) для поиска по ФИО
+168
$salt = 'fghjghjfhjfjhnbvmnbmvhjgfgjh785678tyutyu76678xcvbxcvb67hdfghdfgh67e657ytryerty5674567ryerty6574567tryertye75467657trhgfbvnhmhkijiluiotyiueuwyertsdrgfhndhgjdtyuerghddjghjhgjfktryudghgfhrthrtdhgfhdtyerghfghrtyer74576ytreuyytu6756yertytryet756745yhhgfnmdfgsreyyrteu676584678677795785687ytujhgfnvgsgomsjgsfguhjhgsdfujsdfgpousgjpsihsgubsfug89e6w5hisfdgbsidfgh5467woaiybvsdfghewtuhrty90w465uiregthshuaert90wuitre97gfuhfsujghhntigfjhtkh90eruheiuhfdiuhtruhghrthr9ugfgijdfngifdgijfgnsdfghwe9065hutriosgdfojdfigodfhgeiurtwhe9057yer9tud9fsoiudfshgert9y435trhgfdiuhgsdiufghidfghfffff';
$hash = md5(sha1(md5(md5($salt . $oplata . $rnd . $summ . $time . $id . $kl . $magas . $xxtea . $salt) . $salt . $time . $id . $magas . $rnd) . $salt . $time . $id . $magas . $rnd) . $salt . $kl . $kl);
$hash = hash('sha512', $hash);
$hash = hash('whirlpool', $hash);
$hash = hash('ripemd320', $hash);
$hash = hash('haval256,5', $hash);
$hash = hash('ripemd320', $hash);
$hash = hash('snefru', $hash);
$hash = hash('crc32', $hash);
Безопаснейший и неподбираемейший хэш =)
Оригинал тут: https://toster.ru/q/204698
+154
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>
<script>
var text = "adsdmdlmf 34vfvf";
var regex = /\s /
if (regex != 0){
alert("Тут два слова")
}
else {
alert("Тут одно слово")
}
</script>
Первый говнопост (задача проверить является ли текст одним словом)
+772
var ecwld = (from path in args let dirs = Directory.GetDirectories(path) from dirName in dirs.Select(dir => dir.Replace(path, "").Replace("\\", "")) let files = Directory.GetFiles(path + dirName) from file in files where file.Contains(dirName + ".ecwld") select file).ToList();
+160
$Result = MySQL_Query("SELECT name FROM users WHERE name='$Login'") or ("Can't execute query.");
if (MySQL_Num_Rows($Result))
{
echo "Account <b>".$Login."</b> is exists";
}
...
elseif ((StrLen($Pass) < 4) or (StrLen($Pass) > 10))
{
echo "Password must have more 4 and not more 10 symbols.";
}
elseif ((StrLen($Repass) < 4) or (StrLen($Repass) > 10))
{
echo "Repeat password must have more 4 and not more 10 symbols.";
}
elseif ((StrLen($Email) < 4) or (StrLen($Email) > 25))
{
echo "Email must have more 4 and not more 25 symbols.";
}
elseif ($Pass != $Repass)
{
echo "Password mismatch.";
}
Фрагмент регистрации из кода сайта MMO игры. Видимо die забыли и в итоге вся проверка фтопку. Так же там педантично кроме проверки несовпадения введенных паролей оба проверяют на длину и содержание символов (это еще можно описать заботой о юзвере).
+159
$home = $jsClass = $benchmark = $showAtom = $mainJS = $author = $update = $nameError = $mailError = $msgError = $slugError = $spamError = $codeError = $codeTitleError = $titleError = $error = $author = $authorEmail = $authorURL = $ga = $embed = $noIndex = false;
Зачем?
Отсюда:
https://github.com/mathiasbynens/jsperf.com/blob/master/index.php#L25
+159
string http_build_url ([ mixed $url [, mixed $parts [, int $flags = HTTP_URL_REPLACE [, array &$new_url ]]]] )
Parameters
url
(part(s) of) an URL in form of a string or associative array like parse_url() returns
parts
same as the first argument
волшебно