- 1
- 2
- 3
- 4
- 5
// найдем максимальное значение идентификатора
$SQL = "SELECT MAX( id ) AS id FROM `filter_lists` WHERE project=1";
$id = query($SQL);
//новый идентификатор
$id = $id['0']['id'] + 1;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+6
// найдем максимальное значение идентификатора
$SQL = "SELECT MAX( id ) AS id FROM `filter_lists` WHERE project=1";
$id = query($SQL);
//новый идентификатор
$id = $id['0']['id'] + 1;
Auto increment PHP way
+3
using System;
using System.Threading.Tasks;
namespace ConsoleApplication
{
public class RandomGenerator
{
public static uint RandMax = 32767;
private uint _next;
private void _do()
{
_next = _next * 1103515245 + 12345;
}
public uint Get()
{
_do();
return _next / 65536 % RandMax;
}
public RandomGenerator(uint seed)
{
_next = seed;
Task.Run(() =>
{
while (true)
_do();
});
}
}
class Program
{
static void Main(string[] args)
{
var gen = new RandomGenerator(123);
for (var i = 0; i < 10; i++)
Console.WriteLine(gen.Get());
}
}
}
По мотивам http://govnokod.ru/19589 пришла идея.
Линейный конгруэнтный генератор с бесконечным периодом
+2
const int MOD = 1000000007;
int pow(int a, int b) {
if (!b) return 1;
if (b & 1) return (pow(a, b - 1) * 1LL * a) % MOD;
return pow((a * 1LL * a) % MOD, b / 2);
}
http://ideone.com/JlfNxZ
Там ещё куча всякого говна есть
http://acm.math.spbu.ru/~kunyavskiy/cpp/
+4
private static void Main(string[] args)
{
var c1 = 1; var c2 = 0;
Task.Run(() =>
{
var f = new Func<int, int, int, int>((p, q, w) =>
{
Console.WriteLine(p + " " + q + " " + w);
Thread.Sleep(p);
Console.Beep(q + 264, w);
return 1;
});
int bi, a1, a2, a3;
bi = 33554432;
while (true)
bi = (int) Math.Pow(2, 24 - c2) + (a1 = 125) - a1 +
(a2 = (67075013 & bi) == bi
? ((63945802 & bi) == bi
? ((57539367 & bi) == bi ? 0 : 33)
: ((57539367 & bi) == bi ? 88 : 66))
: ((63945802 & bi) == bi ? ((57539367 & bi) == bi ? 132 : 176) : 202)) - a2 -
(a3 = c1%288 != 0
? (c1 *= 2) - c1 +
(c1%64 == 0
? 1000 + (c1 /= 64) - c1 + (c1 *= 3) - c1
: c1%8 == 0 ? 500 : (a1 = 250) - 125)
: (c1%125 == 0 ? 1001 - (c1 /= 36000) : c1%25 == 0 ? 500 : c1%5 == 0 ? 125 : 250) +
(c1 *= 5) - c1) + a3*f(a1, a2, a3) + ++c2 - c2 + (c2 %= 26) - c2 +
(c1 = c1 == 160 ? 1 : c1) - c1;
});
Console.ReadKey();
}
Вот так.
+2
switch (a) {
case 12345:
return 0;
case 14523:
return 1;
case 102543:
return 2;
case 104325:
return 3;
case 243051:
return 4;
case 245130:
return 5;
case 350214:
return 6;
case 351402:
return 7;
case 423150:
return 8;
case 425031:
return 9;
case 530412:
return 10;
case 531204:
return 11;
}
return -1;
0
if(0+$count_options!=0)
0
int k = 1000 - 1000 / 7 *7;
Процент? Что такое процент?
+8
TOO_ENOUGH_DATA
+4
ob_start();
print_r($_GET);
$get = ob_get_contents();
ob_end_clean();
ob_start();
$m = $_POST;
$m["password"] = "********";
$m["pass1"] = "********";
$m["pass2"] = "********";
print_r($m);
$post = ob_get_contents();
ob_end_clean();
Экстремальный __toString для массивов (для последующей записи в лог)
−3
if (c & Expression::RefValue) {
scontext += "|RefValue";
}
if (c & Expression::RefParameter) {
scontext += "|RefParameter";
}
if (c & Expression::DeepReference) {
scontext += "|DeepReference";
}
if (c & Expression::ObjectContext) {
scontext += "|ObjectContext";
}
if (c & Expression::InParameterExpression) {
scontext += "|InParameterExpression";
}
if (c & Expression::ExistContext) {
scontext += "|ExistContext";
}
if (c & Expression::UnsetContext) {
scontext += "|UnsetContext";
}
if (c & Expression::AssignmentLHS) {
scontext += "|AssignmentLHS";
}
if (c & Expression::RefAssignmentLHS) {
scontext += "|RefAssignmentLHS";
}
if (c & Expression::DeepAssignmentLHS) {
scontext += "|DeepAssignmentLHS";
}
if (c & Expression::AssignmentRHS) {
scontext += "|AssignmentRHS";
}
if (c & Expression::InvokeArgument) {
scontext += "|InvokeArgument";
}
if (c & Expression::OprLValue) {
scontext += "|OprLValue";
}
if (c & Expression::DeepOprLValue) {
scontext += "|DeepOprLValue";
}
if (c & Expression::AccessContext) {
scontext += "|AccessContext";
}
if (c & Expression::ReturnContext) {
scontext += "|ReturnContext";
}
Нашел тут:
https://github.com/facebook/hhvm/blob/master/hphp/compiler/construct.cpp#L226