- 1
return Training.ContainsKey(typeof(unit)) ? true : false;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+133
return Training.ContainsKey(typeof(unit)) ? true : false;
А я ведь говорил ему не рефакторить на ночь глядя.
+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
+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;
}
уже есть час ночи?
+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 вперёд и взад
чтобы как бы верно срослось между ихним с# и нашим сраным с++
−163
public function algorithmChanged(arg1:flash.events.Event):*
{
var loc1:*;
loc1 = null;
if (currentAlgorithm != null)
removeChild(currentAlgorithm);
loc1 = arg1.target.selectedLabel;
currentAlgorithm = null;
animationManager.resetAll();
if (loc1 != "Heap")
if (loc1 != "Comparison Sort")
if (loc1 != "Counting Sort")
if (loc1 != "Bucket Sort")
if (loc1 != "Radix Sort")
if (loc1 != "Heap Sort")
if (loc1 != "Binary Search Tree")
if (loc1 != "AVL Tree")
if (loc1 != "Open Hashing")
if (loc1 != "Closed Hashing")
if (loc1 != "Graph")
if (loc1 != "DFS")
if (loc1 != "BFS")
if (loc1 != "Connected Components")
if (loc1 != "Dijkstra")
if (loc1 != "Prim")
if (loc1 != "Kruskal")
if (loc1 != "Topological Sort")
if (loc1 != "Floyd-Warshall")
if (loc1 != "B Tree")
if (loc1 != "Binomial Queue")
if (loc1 != "Disjoint Sets")
if (loc1 != "Array Stack")
if (loc1 != "Array Queue")
if (loc1 != "Linked List Stack")
if (loc1 != "Linked List Queue")
if (loc1 != "Red Black Tree")
if (loc1 != "Closed Hashing (buckets)")
if (loc1 == "B+ Tree")
{
currentAlgorithm = new BPlusTree(animationManager);
addChildAt(currentAlgorithm, 0);
}
else
{
currentAlgorithm = new ClosedHash2(animationManager);
addChildAt(currentAlgorithm, 0);
}
else
{
currentAlgorithm = new RedBlackTree(animationManager);
addChildAt(currentAlgorithm, 0);
}
и т.д. пока не закроются все if'ы
Визуализатор сортировок университета Сан-Франциско
−113
if ([_categories count] != 0) {
for (NSString *item in _categories) {
[path appendFormat:@"categories/%@/", item];
}
}
Случайно обнаружил у себя :)
+36
#include <iostream>
int main()
{
system("calc");
}
Калькулятор на C++? Да пожалуйста.
+24
template <typename IdType, class Tag>
class id {
public:
typedef IdType value_type;
explicit id(value_type val)
: value(val)
{}
bool operator==(id rhs)
{
return rhs.value == value;
}
bool operator!=(id rhs)
{
return rhs.value != value;
}
value_type value;
};
#define HASKELL_NEWTYPE(type_name, value_type) struct __##type_name##_tag__ {}; \
typedef ::id<value_type, __##type_name##_tag__> type_name
Когда newtype нет, но очень хочется.
http://ideone.com/VRu56j
Простите за синтетику
+15
/**
* @brief Serializer generic interface.
*/
template<typename ValueType>
struct serializer
{
/**
* @brief Parses value from raw bytes.
* @param from byte buffer parse value from
*/
static ValueType parse(uint8_t *from);
/**
* @brief Writes value to raw byte buffer.
* @param value value to write
* @param dest destination buffer
*/
static void write(ValueType value, uint8_t *dest);
};
template<>
struct serializer<uint8_t>
{
static uint8_t parse(uint8_t *from)
{
return *from;
}
static void write(const uint8_t value, uint8_t *to)
{
*to = value;
}
};
template<>
struct serializer<uint16_t>
{
static uint16_t parse(uint8_t *from)
{
return (uint16_t)from[0] << 8 | from[1];
}
static void write(const uint16_t value, uint8_t *to)
{
to[0] = (value >> 8);
to[1] = value & 0xff;
}
};
template<>
struct serializer<uint32_t>
{
static uint32_t parse(uint8_t *from)
{
return from[0] << 24 | from[1] << 16 | from[2] << 8 | from[3];
}
static void write(const uint32_t value, uint8_t *to)
{
serializer<uint16_t>::write(value >> 16, to);
serializer<uint16_t>::write(value & 0xffff, to + 2);
}
};
template<>
struct serializer<uint64_t>
{
static uint64_t parse(uint8_t *from)
{
const uint32_t high = serializer<uint32_t>::parse(from);
const uint32_t low = serializer<uint32_t>::parse(from + 4);
return ((uint64_t) high << 32) | low;
}
static void write(const uint64_t value, uint8_t *to)
{
serializer<uint32_t>::write(value >> 32, to);
serializer<uint32_t>::write(value & 0xffffffff, to + 4);
}
};
Тут поднялась тема неуместного битолюбства... Решил поделиться одним из моих первых крестОпусов.
"кроссплатформенный hton(sl)".
+43
function Podergatsya($i)
{
$i++;
$i--;
return $i;
}
Индусская CMS