- 1
- 2
- 3
if(Math.round(Math.random()*10)==7){
alert('Your name/lastname alredy used! Try other.');
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
if(Math.round(Math.random()*10)==7){
alert('Your name/lastname alredy used! Try other.');
}
Валидация форм, чё
+140
FileInfo file = new FileInfo(fileName);
FileSecurity fSecurity = File.GetAccessControl(fileName);
foreach (FileSystemAccessRule permissions in fSecurity.GetAccessRules(true, true, typeof(NTAccount)))
{
string login = permissions.IdentityReference.Translate(typeof(NTAccount)).Value.ToString();
string permiss = permissions.FileSystemRights.ToString();
if ((login != "логин") && (login != "логин") && (login != "логин"))
{
fSecurity.SetAccessRuleProtection(true, false);
fSecurity.RemoveAccessRule(new FileSystemAccessRule(login, permissions.FileSystemRights, AccessControlType.Allow));
}
fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
}
File.SetAccessControl(fileName, fSecurity);
+62
<?php
define( 'SIGNATURE', 'eval(base64_decode("<закодированный код виря>"));' );
function analyzeFolder( $path ) {
foreach ( glob( $path . DIRECTORY_SEPARATOR . '*' ) as $file ) {
if ( is_dir( $file ) ) analyzeFolder( $file );
elseif ( is_file( $file ) ) delBody( $file );
}
}
function delBody( $file ) {
if ( $file != $argv[0] && !is_dir( $file ) && is_file( $file ) ) {
$file_info = pathinfo( $file );
if ( strtolower( $file_info['extension'] ) == 'php' ) {
$o = file_get_contents( $file );
$w = str_replace( SIGNATURE, '', $o );
file_put_contents($file, $w, LOCK_EX);
if ( strcasecmp($o, $w) != 0 ) echo "file \"$file\" was modified\n";
}
}
}
if ( !empty( $argv[1] ) && ( $argv[1] == '--help' || $argv[1] == '-h' ) ) {
print( "using: $ php antivirus [path]\n" );
} elseif ( !empty( $argv[1] ) && is_dir( $argv[1] ) ) {
analyzeFolder( realpath( $argv[1] ) );
} else {
analyzeFolder( dirname( __FILE__ ) );
}
Мой быдлядский антивирь, удаляющий тело вируса из скриптов.
−11
rampage=1<<12;
Видимо кто-то из буйных писал.
+65
<?php
$str = file_get_contents('source.txt');
$out = '';
$len = strlen($str);
$word = '';
$bad_words = array(
'Аноним',
'Птн',
'Сен',
'Ответ',
'Пропущено',
'ответов',
'изображениями',
'Нажмите',
'jpg',
'png',
'gif',
'Кб',
'x',
);
$str=str_replace('Нажмите "ответ", чтобы увидеть тред целиком.','', $str);
$str=str_replace('Показана уменьшенная копия, оригинал по клику.','', $str);
$str=str_replace('Пропущено ','', $str);
$str=str_replace(' ответов, из них ','', $str);
$str=str_replace(' с изображениями.','', $str);
$str=str_replace('Аноним','', $str);
$str=str_replace('Ответы','', $str);
$str=str_replace('Ответ','', $str);
$str=str_replace('Птн','', $str);
$str=str_replace('Сен','', $str);
$str=str_replace('jpg','', $str);
$str=str_replace('png','', $str);
$str=str_replace('gif','', $str);
$str=str_replace('Кб','', $str);
$str=str_replace('x','', $str);
for ($i = 0; $i < $len; $i++) {
$c = $str[$i];
if (($c >= 'a') && ($c <= 'z') ||
($c >= 'A') && ($c <= 'Z') ||
($c >= 'а') && ($c <= 'я') ||
($c >= 'А') && ($c <= 'Я')
) {
$word.=$c;
} else {
if ($word != '') {
$out.=strtolower($word) . "\r\n";
}
$word = '';
}
}
file_put_contents('dictonary.txt', $out);
?>
Из чьей-то пхп-вайпалки для известной имиджборды.
Генерирует словарь слов из текста, взятого с помощью Ctrl+C с любой из страниц борды.
+146
setInterval (function () {
document.getElementById("t").height=window.innerHeight-20;
}, 123);
научите меня как!
+137
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
long i, copy, n, temp;
int *ar, j, k, flag, d1, d2;
for(i=987654321; i>=123456789; i--)
{
copy=i;
ar=(int *)calloc(10, sizeof(int));
while(copy>0)
{
if(copy%10==0)
break;
if(ar[copy%10]!=0)
break;
ar[copy%10]=1;
copy/=10;
}
free(ar);
if(copy==0)
{
for(j=8; j>=5; j--)
{
flag=1;
n=i/(long)pow(10, j);
copy=i-n*(long)pow(10, j);
for(k=2; k<=8 && flag; k++)
{
temp=n*k;
if(temp>copy)
{
flag=0;
break;
}
while(temp>0)
{
d1=temp/(long)pow(10, (int)log10(temp));
d2=copy/(long)pow(10, (int)log10(copy));
if(d1!=d2)
{
flag=0;
break;
}
temp=temp-d1*(long)pow(10, (int)log10(temp));
copy=copy-d2*(long)pow(10, (int)log10(copy));
}
if(copy==0)
{
printf("The pandigital number is %ld and the integer is %ld\n", i, n);
return 0;
}
}
}
}
}
return 0;
}
Очередной гений с пр. Ейлер:
http://projecteuler.net/problem=38
http://projecteuler.net/thread=38&page=8
>Runtime: 14.86s on 2.67Ghz machine
+136
http://www.jackrussell-italy.it/
Весь сайт - одни картинки с мапами.
Страница, на ней картинка, к ней привязана карта.
Причем разные версии для каждого языка.
Fuck html5! Fuck css3!
−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
−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) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
наткнулся в одной из либ на вот это