- 1
http://www.jackrussell-italy.it/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
наткнулся в одной из либ на вот это
+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..
+82
public class ExceptionAction extends ActionImpl {
public void nullPointer() throws Throwable {
throw new NullPointerException();
}
}
Гениально же!
+125
(defun question-2 ()
(let ((b '(1 2 3))
(a '(1 2 3 4))
(com (make-hash-table :test #'equal)))
(labels ((put-sorted (x)
(let ((key
(sort
(flatten
(copy-tree x)) #'<)))
(if (gethash key com)
(incf (gethash key com))
(setf (gethash key com) 1)))))
(values (remove-if
#'(lambda (x)
(prog ((results
(do ((x x (cdr x)) (r))
(nil)
(setf r (append (cadar x) r))
(when (null (cdr x))
(return r)))))
(dolist (y a)
(when (not (member y results))
(go remove-it)))
(put-sorted results)
(go keep-it)
remove-it (return t)
keep-it nil))
(all-functions b (cartesian-product a))) com))))
Ну, чем бы еще порадовать. Вот, родилось во время проверки домашних заданий :)
−122
my (@data) = $content =~ m#href="/show/\d+.*?">(.*?)</a>.*?(Ep: \d+).*?(at \d{2}:\d{2}).*?</small>#gsi;
for (my $i; $i < @data;){
$data .= $data [$i++].' '.$data [$i++].' '.$data [$i++];
$data .= "\n" unless $i == @data;
}
Распарсил.
+96
OdbcCommand dist_cmd = ifx_conn.CreateCommand();
dist_cmd.CommandText = string.Format(@"select -1 as districtid, '-=ВСІ=-' as districtname from systables where tabname = 'systables' union all
select id as districtid , cpz_name as districtname from post_cpz where directorate_id = {0} and id != 0 ORDER BY 2", (String.IsNullOrEmpty(DDL_obl.SelectedValue))?"-1":DDL_obl.SelectedValue);
reader = dist_cmd.ExecuteReader();
в процессе рефакторинга, убирая NHibernate код был заменен на это
+78
private function isRussianCar($car){
# Определялка российских машин.
if ($car['make_id'] == '107') return true;
if ($car['make_id'] == '108') return true;
if ($car['make_id'] == '109') return true;
if ($car['make_id'] == '110') return true;
if ($car['make_id'] == '111') return true;
if ($car['make_id'] == '112') return true;
if ($car['make_id'] == '113') return true;
if ($car['make_id'] == '114') return true;
if ($car['make_id'] == '115') return true;
if ($car['make_id'] == '116') return true;
if ($car['make_id'] == '117') return true;
return false;
}
Нашёл в одном из проектов
+56
#/* */include<stdio.h>
/* */int/**/main(int/**/o,char**O){int y[4],
r[4] ,z[4],C,h,i,n,a,t,s,u[2][3][4]={{{6,9,0,3} ,
{ 1,10,4,7},{5,11,2,8}},{{3,0,6,9},{10,1,4,7},{ 8,2,5
,11}}}, M,I,R,A,K,U[2],RU[2],N[2],_=2;FILE*x[03] ; unsigned/*,
*/char/**/ p[2][3<<16],d[12],b[256][256];float/**/f,q [12];if((o<4)){
return!puts("<a.ppm>\40<b.ppm>\40<output.ppm>\40[odd]") ;}else{for(h=0;h<2;
h++){M=SEEK_SET;if(!(x[h]=fopen(O[h+1],"rb")))goto/**/e;if( (int)fread(*b,1,256,x[h
])<1||sscanf((char*)*b,*O="P6\n%d\40%d\n%d\n",&U[h],&N[h],&i)-3||i-255)goto/**/e;for(
i=C=RU[h]=0;i<256&&!RU[h];i++)if(b[0][i]=='\n')if(++C==3)fseek(x[h],RU[h]=i+1,M);if(!RU
[h]||U[h]<1||U[h]>(1<<16))goto/**/e;}if(*U-U[1]||*N-N[1])goto/**/s;for(h=0;h<256;h++)for(
i=0;i<256;b[h][i++]=0) ;for(i=0;i<*N;i++){for(h=0;h<2;h++)if(fread(p[h],3**U,01,x[h])!=1)
goto/**/e;for(h=0;h<3** U;h++)b[p[0][h]][p[1][h]]=1; }*y=*r=y[2]=r[2]=64;y[1]=r[1]=y[3]=r[
3]=192;A=(y[1]-*y)*(y[ 3]-y[2]);for(M=64;M>0; M/=2) {for(t=-1;t<=0;t++)if((*z=*r+t*M)>-1)
for(I=-1;I<1;I++)if((z [ 2]=r[2]+I*M)> (-1)) for (s=1;s>-1;s--)if((z[1]=r[1]+s*M)<257
)for(R=1;R>-1;R--)if( + 257>(z[3]=r [3]+R* M) )if((K=(z[1]-z[0])*(z[3]-z[2]))>A){
for(h=C=0;h<256&&C> -1 &&C<256; h ++)for (n=h*(z[1]-z[i=0])/256+*z;C>-1&&
i<256&&C<256;i++){a = i*(z[3]-z [2 ])/256+ z[2];if(b[h][i])C=(3*n-a)/2;}if
(C>-1&&C<256)for(C =0 , A= K ;C <4;++ C)y[C]=z[C];}for(C=0;C<4;C++)r
[C]=y[C];}if(!(x[2 ] =/* */ fopen (O[03],"wb+")))goto/**/e;else{
fprintf(x[2],*O,2* *U,2**N,+ 255);for(h= 0;h<(2);h++)fseek(x[h],RU[h],
SEEK_SET);C=(o<5)? 1/***/:00 ;/***/R=1+( 1<<16);for(i=0;i<*N;i++){for(h
=0;h<2;h++)if(fread (/****/p[ h/****/],+3 **U,1,x[h])!=1)goto/**/e;for(
M=0;M<7;M+=6)for(h =/**/0;* U/**/>h;h ++){for(n=0;n<3;n++){for(a=0;
a<2;a++)q[u[C][n] [a]]=p [a][h *3+n]*(r[a*2+1]-r[a*2])/256.f
+r[a*2];q[u[C][n] [2]]=q[u[C][n][3]]=(3*q[*u[C][
n]]-q[u[C][n][1]] )/2;}for(n=0;n<12;d[n++]=t<0?
0:(t>255?255:t)){ t = q[n];f=q[n]-t;_=(_*75)%R;if(_<f
*R)++ t;}fwrite(d +M,6,1, x[2]);}}}}for(h=0;h<3;h =h + 1
) t= fclose(x [h ]); return (t*1);s :
*O ="si" /* */ "ze "; printf (
* /*' P*/ O); ;e : return
! /*w*/ puts /*;
*/("error"); }
http://uguu.org/sources.html юзайте ребята.