Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

post bits of code you like

Name: Anonymous 2005-08-02 1:52

i shall start:

open(F,"find -type f|");
while (<F>) {
 $_ = substr($_,2,-1);
 print "$_\n" if $v;
 push @{$dups{substr(`md5sum -b "$_"`,0,31)}}, $_;
}
close(F);

for every file in a directory it checksums the file, then adds the checksum as a key to a hash, the value being an array reference. the filename is then added to the array.

so basically the arrays have a list of files with the same checksum. i use this to find duplicates files.

Name: Anonymous 2005-08-02 5:34

hmm, i just realized this might not be very portable. so:

use File::Find;

sub wanted {
  print "$_\n" if $v;
  push @{$dups{substr(`md5sum -b "$_"`,0,31)}}, $File::Find::name if -f;
}

find \&wanted, ('.');

Name: Anonymous 2005-08-03 5:25

Mail::RFC822::Address: regexp-based address validation

(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\0
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\
r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[
 \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)
?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
)*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[
 \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:
\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031
]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](
?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?
:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?
:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?
:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?
[ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".[\]
\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|
\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>
@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"
(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]
)*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\
".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?
:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[
\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".[\] \000-
\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(
?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;
:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([
^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
.[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\
]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\
r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\]
\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]
|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".[\] \0
00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\
.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]]))|"(?
:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".
[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\]
]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
?:(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\
".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
["()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
])+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".[\
]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
?[ \t])*(?:@(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["
()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>
@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
 \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,
;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
)*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\
".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[["()<>@,;:\\".
[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[[
"()<>@,;:\\".[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
+|\Z|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[["()<>@,;:\\".[\]]))|[([^[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
?:\r\n)?[ \t])*))*)?;\s*)

Name: Anonymous 2005-08-03 21:00

>>3
what the fuck?

Name: Anonymous 2005-08-03 21:00

>>3
what the fuck?

Name: Anonymous 2005-08-03 21:32

>>3
copy paste, copy paste

Name: Anonymous 2005-08-04 3:27

>>3
more like line noise am I rite

Name: Anonymous 2005-08-04 4:12

>>7
do the same thing in any language and it will be equally understandable

Name: DarkPenguin 2005-08-04 9:02

>>4 >>5 >>6 >>7 >>8
Actually it's real code. It's a perl module that checks an email address for validity or something similar.

Link here: http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

Name: Anonymous 2005-08-04 12:10

Why is it so complex? It only has to match the form <user>@<host>

Name: Anonymous 2005-08-04 15:31

http://www.ietf.org/rfc/rfc0822.txt?number=822 look at the rfc and quit whining, it is a little much yes..

Name: Anonymous 2005-08-04 18:35

6.  ADDRESS SPECIFICATION

6.1.  SYNTAX

address     =  mailbox                      ; one addressee
            /  group                        ; named list

group       =  phrase ":" [#mailbox] ";"

mailbox     =  addr-spec                    ; simple address
            /  phrase route-addr            ; name & addr-spec

route-addr  =  "<" [route] addr-spec ">"

route       =  1#("@" domain) ":"           ; path-relative

addr-spec   =  local-part "@" domain        ; global address

local-part  =  word *("." word)             ; uninterpreted
                                            ; case-preserved

domain      =  sub-domain *("." sub-domain)

sub-domain  =  domain-ref / domain-literal

domain-ref  =  atom                         ; symbolic reference

Name: Anonymous 2005-08-04 18:38

>>12
i think prolog or some BNF grammar thingy could translate that directly

Name: Anonymous 2005-08-05 5:21

>>13
Truth, regexps are not nearly as powerful as grammars.

Name: Anonymous 2005-08-10 7:46

change :: Integer -> [Integer] -> [[Integer]]
change _ [] = []
change a [t] = let (d,m) = divMod a t in -- optimization
  case m of
  0 -> [[d]]
  _ -> []
change a s@(t:ts) =
  case compare a 0 of
  LT -> []
  EQ -> [map (const 0) s]
  GT -> map (\(x:xs) -> (succ x):xs) (change (a-t) s) ++
        map (0:) (change a ts)

shows all the ways to add up the list to numbers to form the first number

ex:
change 40 [7,9,10] = [[3,1,1],[0,0,4]]
you can have 3 7s, 1 9, and 1 10 to form 40
or 0 7s, 0 9s, and 4 10s to form 40.

i copied the general idea form somewhere

Name: Anonymous 2005-08-10 16:50

CLI
HLT

Name: Anonymous 2005-08-12 13:18 (sage)

CLS

Name: Anonymous 2005-08-19 11:26

if ($ENV{"HTTP_USER_AGENT"} =~ /MSIE/) {
    print "Location: http://www.mozilla.org/products/firefox/\n\n";
    exit 0;
}

Name: Anonymous 2005-08-20 8:08

>>18

This is the most you can ever get of 4 lines of code. Everybody should do that. In fact, I /r/ that everybody does this immediately.

If your site uses PHP, here's the equivalent code:

if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
    header('Location: http://www.mozilla.org/products/firefox/';);
    exit(0);
}

Name: Anonymous 2005-08-20 8:09

>>19
For some reason there's a semicolon before closing parenthesis in that code. Of course, it's not to be there.

Name: Anonymous 2005-08-20 9:30

if (... !== FALSE) {
lol

Name: Anonymous 2005-08-20 9:34

>>21
Yes, because 0 evals to FALSE too (as in C) and you don't want to risk having the needle at the beginning of the haystack. If you think you're so cool type comparisons are forbidden by your religion, use strstr, which will work as long as you're not matching a string that's '0' against '0'.

Name: Anonymous 2005-08-20 10:21

PHP is for retards

Name: Anonymous 2005-08-20 10:37

Yes. /prog/ is the new VIP. I'm outta here.

Name: Anonymous 2005-08-20 11:47

Examples of obfuscated variable names (from http://www.mindprod.com/jgloss/unmainnaming.html)
typedef struct { int i; } ínt;

Name: Anonymous 2005-08-20 12:03

>>23
This troll is VIP quality.

Name: Anonymous 2005-08-20 15:27

http://www.world4ch.org/read/prog/1105741677/l40

There was an old thread with someone posting some C++ code and challenging people to parse it.  There was a neat bit of pseudo-run-time-type-identification code that I thought was pretty clever, involing the usage of templates.

template<typename T> inline pszint TypeId() { static T tag; return (pszint) &tag; }

Name: Anonymous 2005-08-20 16:45

>>27
I don't speak Hungarian.

Name: Anonymous 2005-11-02 16:21

>>28
it doesn't do anything real, faggot

Name: Anonymous 2005-11-02 19:07

>>27
Ugh, templates. During an internship at MS (yes, that MS), my coworker showed me some code that used templated about 20 layers deep. Why anyone in their right mind would do such a thing was beyond us, but being MS employees, we left it as is. :)

Name: Anonymous 2005-11-02 20:12

>>27
Hungarian notation sucks and fails. Tell you what, I'd rather have Basic's horrible $, %, &, !, # stuff than Hungarian notation, and I'd rather have anything else than Basic's horrible stuff.

Name: Anonymous 2005-11-02 21:22

>>31


43   
Anonymous at 31 Oct 2005: 12:07
>>42
underscores > fagHungarianNotationLoLoLoL
44 (sage)   
Anonymous at 31 Oct 2005: 15:36
>>43
You don't know what hungarian is do you?
45   
Anonymous at 31 Oct 2005: 15:48
http://www.joelonsoftware.com/articles/Wrong.html

Name: Anonymous 2005-11-02 23:18

HUNGARIAN NOTATION WAS USED TO MAKE IT HARDER TO READ, RETARDS.

ALSO WHAT THE CODE DOES IS NOT MEANT TO BE KNOWN. THEREFORE HUNGARIAN NOTATION.

FUCK FUCKFUCKFUCKCUFJDKSFHLFKJDSAAAAAAAAARRRRRRGGGHH

Name: Anonymous 2005-11-05 18:51

___________LOOK_DONT_CHANGE___THIS_IS_PYTHON_______-

Name: Anonymous 2005-11-06 7:49

>>34
Signed. Fucking underscores everywhere, just one of the things that ruin what could have been a great language.

Name: Anonymous 2005-11-06 10:23

It could be worse.

@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print

Name: Anonymous 2005-11-06 14:11

>>36
Deliberately obfuscated code proves that a language is unreadable!

Name: Anonymous 2005-11-06 23:30

Yep. It's quite obvious C sucks too: http://www.ioccc.org/

Clearly it must be an unreadable language.

Name: Anonymous 2005-11-07 8:11

Python is also unreadable:
#Mandelbrot set
print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or(x*x+y*y
>=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)

Name: Anonymous 2005-11-08 22:28

>>39
this is awesome.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List