- 1
new Date(System.currentTimeMillis());
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+86
new Date(System.currentTimeMillis());
Просто и со вкусом
+144
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}else{
if ((intYear % 4) == 0) { return true; }
}
return false;
}
Пистец %)
надыбал скриптец в проекте при чистке. Так индусы считали високостный год %))
походу сразу %4 не работает %) или тут зарыт какой-то мэйджик смысл? %) ы
+170
var a1 = Math.floor(Math.random()*15 + 1);
var a2 = Math.floor(Math.random()*15 + 1);
mismatch(2);
var a3 = Math.floor(Math.random()*15 + 1);
mismatch(3);
var a4 = Math.floor(Math.random()*15 + 1);
mismatch(4);
var a5 = Math.floor(Math.random()*15 + 1);
mismatch(5);
var a6 = Math.floor(Math.random()*15 + 1);
mismatch(6);
var a7 = Math.floor(Math.random()*15 + 1);
mismatch(7);
var a8 = Math.floor(Math.random()*15 + 1);
mismatch(8);
var a9 = Math.floor(Math.random()*15 + 1);
mismatch(9);
var a10 = Math.floor(Math.random()*15 + 1);
mismatch(10);
var a11 = Math.floor(Math.random()*15 + 1);
mismatch(11);
var a12 = Math.floor(Math.random()*15 + 1);
mismatch(12);
var a13 = Math.floor(Math.random()*15 + 1);
mismatch(13);
var a14 = Math.floor(Math.random()*15 + 1);
mismatch(14);
var a15 = Math.floor(Math.random()*15 + 1);
mismatch(15);
Это и многое другое на http://ru.wikiversity.org/wiki/15_puzzle
+162
/*
Макрос генерирует внутренности функции-заглушки OpenGL.
*/
#define BWT_DECLARE_OPENGL_PROC_IMPL(PROC, PROC_TYPE, ...) \
static PROC_TYPE _##PROC = 0; \
\
if (_##PROC) \
return _##PROC(__VA_ARGS__); \
else \
{ \
_##PROC = TryToGetProcAddress<PROC_TYPE>(#PROC); return _##PROC(__VA_ARGS__); \
}
/*
Функция получает адрес функции, или возбуждает исключение, если адрес получить не удалось.
*/
template<typename proc_type>
proc_type TryToGetProcAddress(const char *proc_name) throw(error_type<VIDEO>)
{
proc_type address = reinterpret_cast<proc_type>(::SDL_GL_GetProcAddress(proc_name));
if (!address)
BWT_THROW_VIDEO_ERROR(UNDEFINED_ERROR, "OpenGL version does not supported");
return address;
}
GLAPI void APIENTRY glCullFace (GLenum mode)
{
BWT_DECLARE_OPENGL_PROC_IMPL(glCullFace, PFNGLCULLFACEPROC, mode);
}
...
+144
void addSlash( const char* command, char* sdo )
{
int command_length;
char *command_line = command;
command_length = strlen(command);
while(command_length>0){
switch(*command_line){
case '"':
strcpy(sdo+strlen(sdo),"\\");
default:
strcpy(sdo+strlen(sdo), command_line);
}
command_line++;
command_length--;
}
}
Должно быть добавление слешей перед двойными кавычками.
+169
/* создать задачу */
function add_problem($value) {
...
}
+1001
string GetStringHash(string S)
{
MD5 md = MD5.Create();
byte[] B = md.ComputeHash(Encoding.UTF8.GetBytes(S));
return string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}",
B[0x00], B[0x01], B[0x02], B[0x03], B[0x04], B[0x05], B[0x06], B[0x07],
B[0x08], B[0x09], B[0x0A], B[0x0B], B[0x0C], B[0x0D], B[0x0E], B[0x0F]);
}
Запостил: 4eburashka, прямо перед выпилом ресурса.
+157
# Количество эл. массива
$count = count($arr);
echo "<p class='code'>( ";
# Разбиваем массив на ключи и значения
foreach ($arr as $key=>$value) {
echo $value;
# Проверяем если это последний эл. массива
if(!next($arr)){
echo " ) / ".$count;
# Считаем среднее арифметическое
$average = array_sum($arr)/$count;
echo " = ".$average."</p><p class='info'>Сурженко Дмитро<br>402 група</p>";
# Выход
exit();
}
echo " + ";
}
+158
$dest = preg_replace( '#[^\\w\\d]+#', '', $source );
Ответ автора сего творения: "\\d - да, наверное лишнее, но не помешает"
+161
/*
[... выдержки из файла search.php ...]
*/
//Создание коротких переменных
$q = $_GET['q'];
if(intval($q)) {
//если в поле поиска введено число, перенаправить на просмотр заметки с этим id
echo "<meta http-equiv=\"refresh\" content=\"0; url=view.php?id=$q\" />";
exit();
}
//Приведение типа входных данный в строковый
$q = strval($q);
$q = secure_input_string($q);
if (!isset($q) || empty($q) || !is_string($q)) {
//Неверные входные данные, скорее всего пользователь не ввел никаких данных в форму поиска
echo '<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link href="style/generalstyle.css" rel="stylesheet" /></head><body>';
echo '<div class="error_window" align="center">Ошибка.<br />Вы не ввели данные для поиска.</div>';
echo "<meta http-equiv=\"refresh\" content=\"1; url={$_SERVER['HTTP_REFERER']}\" />";
//Выход из сценария
exit('</body></html>');
}
Тонкости надмозгового мироздания из серии http://govnokod.ru/4278
Орфография и пунктуация сохранены