- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
while(true){
$it = $this->item_by_id($i++);
if($it != null){
$nItems[] = $it;
}
if(count($nItems) >= 5){
break;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
while(true){
$it = $this->item_by_id($i++);
if($it != null){
$nItems[] = $it;
}
if(count($nItems) >= 5){
break;
}
}
+153
$d = date("d")-1;
$h = date("H")-2;
header("Last-Modified: " . gmdate("D, ".$d." M Y ".$h.":i:s") . " GMT");
Вчера
+144
genchatmessage: function(text, avatar1, avatar2, time, rtl) {
if (typeof rtl == "undefined") var rtl = false;
if (typeof avatar == "undefined") var avatar = "images/user_male.png";
if (typeof time == "undefined") var time = this.gettime();
var tr = document.createElement("tr");
var td = [document.createElement("td"), document.createElement("td"), document.createElement("td")];
var div = document.createElement("div");
var span = document.createElement("span");
var pre = document.createElement("pre");
span.innerHTML = time;
pre.innerHTML = interface.innerText(String(text));
if (rtl) {
div.className = "chat-message-rtl";
} else div.className = "chat-message";
if (typeof avatar1 == "string") {
var img1 = document.createElement("img");
img1.src = avatar1;
td[0].appendChild(img1);
}
if (typeof avatar2 == "string") {
var img2 = document.createElement("img");
img2.src = avatar2;
td[2].appendChild(img2);
}
+151
var form = jQuery('#' + formId);
jQuery(form).attr('action', s.url);
jQuery(form).attr('method', 'POST');
jQuery(form).attr('target', frameId);
if(form.encoding)
{
jQuery(form).attr('encoding', 'multipart/form-data');
}
else
{
jQuery(form).attr('enctype', 'multipart/form-data');
}
jQuery(form).submit();
Без комментариев.)
−116
sprintf "%d-%02d-%02d", map { $$_[5]+1900, $$_[4]+1, $$_[3]+1 } [localtime];
Даты. Perl. Классика.
http://perldoc.perl.org/POSIX.html#strftime
+67
System.out.println(randomString(-229985452) + " " + randomString(-147909649));
Функция randomString() реализуется примерно вот так:
public static String randomString(int i)
{
Random ran = new Random(i);
StringBuilder sb = new StringBuilder();
for (int n = 0; ; n++)
{
int k = ran.nextInt(27);
if (k == 0)
break;
sb.append((char)('`' + k));
}
return sb.toString();
}
Оригинальный hello world на java
+1
int main()
{
__asm()
{
NOP
}
return 0;
}
программа делает ничего, но делает
+132
public event ConnectedHandler OnConnected;
.......
lock( OnConnected )
{
if( OnConnected != null )
{
OnConnected( ... );
}
}
Быдломакронабиратели...
+13
CompoundExpression*
CompoundExpression::newBinaryExpression(
BasicBinaryOperation::Type operation,
const Expression *x,
const Expression *y
) {
vector<Expression::const_pointer> params(2);
params[0] = x;
params[1] = y;
// integer power optimization
if (operation == BasicBinaryOperation::POWER) {
if (y->isNumber()) {
Number::const_pointer number_y = dynamic_cast<typeof number_y>(y);
if (number_y != NULL && number_y->isIntegerNumber()) {
IntegerNumber::const_pointer integer_y = dynamic_cast<typeof integer_y>(number_y);
if (integer_y != NULL) {
operation = BasicBinaryOperation::INT_POWER;
return new CompoundExpression(BinaryOperation::getOperation(operation), params);
}
}
}
}
// x^(y/n), where 'n' is odd integer
// transform to '(x^y)^(1/n)'
if (operation == BasicBinaryOperation::POWER) {
if (y->isCompoundExpression()) {
auto compoundExpressionY = dynamic_cast<CompoundExpression::const_pointer>(y);
if (compoundExpressionY != NULL && compoundExpressionY->operation->isBinary()) {
auto innerOperation = compoundExpressionY->operation;
auto binaryOperation = dynamic_cast<BinaryOperation const *>(innerOperation);
if (binaryOperation != NULL && binaryOperation->getType() == BasicBinaryOperation::DIVIDE) {
Expression::const_pointer numerator = compoundExpressionY->params[0];
Expression::const_pointer denominator = compoundExpressionY->params[1];
if (denominator->isNumber()) {
auto numberDenominator = dynamic_cast<Number::const_pointer>(denominator);
if (numberDenominator != NULL && numberDenominator->isIntegerNumber()) {
auto integerDenominator = dynamic_cast<IntegerNumber::const_pointer>(numberDenominator);
if (integerDenominator != NULL && (integerDenominator->intValue() % 2) != 0) {
auto base = CompoundExpression::newBinaryExpression(BasicBinaryOperation::POWER, x, numerator);
return CompoundExpression::newBinaryExpression(BasicBinaryOperation::NTH_ROOT, integerDenominator, base);
}
}
}
}
}
}
}
return new CompoundExpression(BinaryOperation::getOperation(operation), params);
}
Моё. Потребовалось воткнуть оптимизацию арифметического выражения некоторого вида. В результате родился вот такой костыль.
+8
#define I_HATE_MACRO2(BEGIN__, END__) BEGIN__##END__
#define CONCAT_MACRO(BEGIN__, END__) I_HATE_MACRO2(BEGIN__,END__)