- 1
- 2
- 3
- 4
import sys, os
# include project path like an EVIL
sys.path.append('/'+os.path.join(*os.getcwd().split(os.path.sep)[1:-1]))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−96
import sys, os
# include project path like an EVIL
sys.path.append('/'+os.path.join(*os.getcwd().split(os.path.sep)[1:-1]))
Включении в поиск родительской директории
+78
public function monthToString($month)
{
$months = array('никогдарь', 'январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь');
if(is_numeric($month))
{
$month = ltrim($month, "0");
$month = $months[$month];
}
return $month;
}
Стажер нашел весьма нетривиальный способ получить месяц текстом =D
+111
// WARNING!
// This has to be optional=true so that OpenJPA uses
// LEFT JOIN instead of INNER JOIN. Otherwise, MySQL tries
// using a temporary table (horrible for performance) and dies.
@ManyToOne(optional = true)
@NotNull
private Font font;
+136
http://www.jackrussell-italy.it/
Весь сайт - одни картинки с мапами.
Страница, на ней картинка, к ней привязана карта.
Причем разные версии для каждого языка.
Fuck html5! Fuck css3!
−43
int eger;
−32
#pragma once
#include <vector>
#include <assert.h>
class Obj
{
public:
virtual ~Obj(void) { }
};
class Sig
{
typedef void (Obj::*slot_t)(void*);
mutable std::vector<std::pair<Obj*, Sig::slot_t>> m_connSlots;
public:
void operator()(void* arg) const
{
std::vector< std::pair<Obj *, slot_t> >::const_iterator iter = m_connSlots.cbegin();
while(iter != m_connSlots.cend())
{
Obj * object = iter->first;
slot_t slot = iter->second;
(object->*slot)(arg);
iter++;
}
}
template<class obj_T> void connect(obj_T* object, void (obj_T::*slot)(void*)) const
{
assert(dynamic_cast<Obj*>(object)!=0);
m_connSlots.push_back(std::make_pair(reinterpret_cast<Obj*>(object),
reinterpret_cast<Sig::slot_t>(slot)));
}
};
QBicycle
+101
private void FillLocalService(int SelectedPageIndex)
{
//Set category by search
string search = inputSearch.Value == inputSearchValue ? string.Empty : inputSearch.Value;
if (inputSearch.Value != inputSearchValue && !string.IsNullOrWhiteSpace(inputSearch.Value))
{
if (inputSearch.Value.StartsWith("landscap", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Landscapers";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("baby sitter", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Baby sitters";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("doctor", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Doctor";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("cleaning service", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Cleaning services";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("pet sitter", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Pet sitters";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("handyman", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Handyman";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("electrical service", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Electrical services";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("tutor", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Tutor";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("dog walker", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Dog walker";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("plumb", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Plumbing";
search = string.Empty;
}
else if (inputSearch.Value.StartsWith("Caterer", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Caterers";
search = string.Empty;
}
else if (inputSearch.Value.Equals("misc", StringComparison.InvariantCultureIgnoreCase))
{
SelectedCategory = "Misc";
search = string.Empty;
}
}
200+ строк кода
}
тот же девелопер, та же .aspx страница)))))
+65
$update_result = mysql_query($update) or die("failed");
if($update_result != false)
header("location: index.php");
else
die("Something Failed.");
−32
//
// std::string wrapper
//
namespace priv {
class string {
std::string &m_s;
std::string &(std::string::*m_pAssign1)( const char *, std::string::size_type );
std::string &(std::string::*m_pAssign2)( const char * );
public:
string( std::string &str ): m_s(str),
m_pAssign1(&std::string::assign), m_pAssign2(&std::string::assign) {}
string &assign( const char *s, std::string::size_type n )
{
(m_s.*m_pAssign1)( s, n ); return *this;
}
string &assign( const char *s )
{
(m_s.*m_pAssign2)( s ); return *this;
}
};
}
сегодня ассимилирую старый хлам на работе (проекты VC6) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
наткнулся в одной из либ на вот это
+123
#include <stdio.h>
int getLen(long long num)
{
int count=0;
while (num > 0)
{
count++;
num/=10;
}
return count;
}
int main(void)
{
int count = 0;
for (long long i=1; i<=9; i++)
{
long long num = 1;
int modify=0;
for (int j=1; j<30; j++)
{
if (i==7 && j == 5)
{
int a= 1;
a++;
}
num *= i;
if (getLen(num) == j-modify)
{
printf("%d^%d=%lld OK %d\n", i, j, num, count+1);
count++;
}
if (num > 10000000)
{
num/=10;
modify++;
}
}
}
printf("%d\n", count);
return 0;
}
http://projecteuler.net/problem=63
http://projecteuler.net/thread=63&page=8
>I don't want to write again an big number rendering algorithm, so I played a little trick on it and hoped it won't cause any trouble..