Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
tripwire
Nov 19, 2004

        ghost flow

Zakalwe posted:

3000 lines is :psyduck:, but there's nothing wrong with using the occasional goto. "Never ever use goto" is generally promulgated by people who've heard of Dijkstra's article but never read the drat thing.

Gotos have no place in OO (or really any kind of structured) programming. Maybe you'd feel more at home with fortran?

Adbot
ADBOT LOVES YOU

tripwire
Nov 19, 2004

        ghost flow
Ulillillia released the source code for a program he designed in C which converts the sampling rate of PCM wave files.
Check it out:
http://www.ulillillia.us/files/WAVFileSampleRateGeneratorV2Source.zip

tripwire
Nov 19, 2004

        ghost flow

TSDK posted:

Oh my.

Oh my-o-my.

Is that someone on the forums?
Nah, not from the forums, although I'm sure a lot of people here are familiar with him :)
Check out his website or youtubes for some flavour: http://www.youtube.com/ulillillia http://www.ulillillia.us


When he says "according to my calculations" he actually means it

tripwire
Nov 19, 2004

        ghost flow

mr_jim posted:

I think its pretty charming from the "how would a determined idiot make this work" perspective.

It's weird because his diction and tone seem to indicate some level of understanding and comprehension, probably enough to grasp why mountains of global variables are bad if he was taught.

Part of me wants to just email him and help him out, but another part of me knows it would be an effort in futility because of how set in his ways he seems to be.

Either way, very amusing code :)

tripwire
Nov 19, 2004

        ghost flow

floWenoL posted:

Some things are just complex and wouldn't benefit from trying to artificially split it up. That and C is pretty low-level so it can get verbose.

I guess I should qualify this by saying I'm a complete programming noob, but I've never seen a huge function that couldn't benefit in terms of legibility and ease of maintenance by being split up in an appropriate way. Whats an example of something for which this doesn't apply?

tripwire
Nov 19, 2004

        ghost flow

Rottbott posted:

It was poorly desgined to begin with, then maintained and added to over many years by bad programmers. There are also hundreds of global variables, many of which have incorrect hungarian prefixes where the type has been changed but not the variable name.

God I hate hungarian notation. How in the hell did anyone ever think it was a smart idea :psyduck:

tripwire
Nov 19, 2004

        ghost flow

Steampunk Mario posted:

Its original intent - to document the purpose and usage of the variable - was a great idea. Somehow it got perverted into being only the type, which is obviously useless.

At the risk of opening a can of worms, its retarded in either form. You are only adding more headaches for yourself later on.

tripwire
Nov 19, 2004

        ghost flow

hexadecimal posted:

I honestly don't know. I had a brain fart. I wanted to do x==y but forgot you could do == on boolean values. Why? No idea. So I used ! xor.

You are crazy. How can you forget the standard idiomatic way to do something so fundamental as comparing for equality and end up with the rubegoldberg-esque xor contraption?

tripwire
Nov 19, 2004

        ghost flow

royallthefourth posted:

Dude, you just pre-incremented in order to increment the post! It seems like a post-increment would have been better suited!:cool:

edit: Wow, that really wasn't funny, in retrospect.

I've got a solution for that

tripwire
Nov 19, 2004

        ghost flow

ryanmfw posted:

What would be the correct email regex?

Its tricker than it seems.
The regex suggested in RFC 2822 (printed below) matches some addresses that will cause most email clients to choke, like name@host.com.fake for example.

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

tripwire
Nov 19, 2004

        ghost flow

ryanmfw posted:

I was thinking more along these lines:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html :v:

There is no god

tripwire
Nov 19, 2004

        ghost flow

Contero posted:

My girlfriend :smug: wrote this:

code:
for (j = 0; j < 15; j = j++) {
   ...
}
Which took a while to explain why j = j++; is pretty much the same as saying j = j;.

The horror




The horror

tripwire
Nov 19, 2004

        ghost flow

Contero posted:

The real horror






is Java.


Ok how about :


:colbert:


Ah yes. The Thing class.

tripwire
Nov 19, 2004

        ghost flow

implicit posted:

code:
subtreeExecuteWin32Op( Win32OpRestoreWin32WindowPosRectAndClearInternalWindowPosRectAuthorityLock );
Win32OpRestoreWin32WindowPosRectAndClearInternalWindowPosRectAuthorityLock was the only member of an enum that was only ever used as the argument to subtreeExecuteWin32Op() (which itself did not actually do any useful work, but that is an entirely different story)

Wow, very descriptive variable names! It's like you don't even need comments, it just explains itself :)

tripwire
Nov 19, 2004

        ghost flow

tef posted:

This would explain the response I got to this childish job advert.

I wrote them an email berating them for using popular languages like erlang and haskell and so sent them a prolog response to elicit the following reply:

What the hell kind of job advertisement is that!?

tripwire
Nov 19, 2004

        ghost flow

Ryouga Inverse posted:

Haha, I love their "fail" page. Someone submitted a GA program that evolves hello world.

Clearly not 1337 enough for these badass renegades of code

tripwire
Nov 19, 2004

        ghost flow
I was looking through some of those "fail"s and couldn't figure out how one of them was getting this text it operates on:
code:
import sys
import StringIO

stdout, sys.stdout = sys.stdout, StringIO.StringIO()

import this

sys.stdout, stdout = stdout, sys.stdout

import random
import subprocess
import time
import platform

cmd = 'clear'
if 'win' in platform.system().lower():
    cmd = 'cls'
cls = lambda : subprocess.Popen(cmd, shell=True).communicate()

sleeptime = 0.01
stdout.seek(0)
data = stdout.read()
inds = [1, 35, 42, 61, 122, 475, 512, 549, 568, 620, 696]
print data
time.sleep(sleeptime)                                                  ## Oh goodie, animated...
while [i for i,x in enumerate(data) if i not in inds and x.strip()]:   ## FAIL ( we accept only as statement modifier )
    x = random.choice([i for i,x in enumerate(data) if i not in inds and x.strip()])
    data = ''.join([data[:x], ' ', data[x+1:]])                        ## Looks like you know about slicing, suppose that's good.
    cls()
    print data
    time.sleep(sleeptime)
while len(data) != len(inds):                                          ## FAIL ( statement modifier.??? nope, so FAIL )
    x = random.choice([i for i,x in enumerate(data) if not x.strip()])
    data = ''.join([data[:x], data[x+1:]])
    cls()                                                              ## Reminds us of non-ninja programmer.
    print data
    time.sleep(sleeptime)

cls()
print data.replace('-',' ')
raw_input('\nPress ENTER to continue')
ugh those comments

Anyway at least I learned a neat trick: in python, "import this" prints the Zen of Python :)

tripwire
Nov 19, 2004

        ghost flow

Otto Skorzeny posted:

Oh, I think I do.

code:
print eval '"'.


                                      ('{'^"\[").(
           ('{')^                   '[').('{'^'[').
        ('{'^'[').                ('{'^'[').('{'^'['
 ).('{'^'['  ).('{'              ^'[').('{'^'[').('{'
^'[').('{'^'[').('{'            ^'[').'_'.('{'^"\[").(
'{'^'[').('{'^"\[").(          '{'^'[').('{'^'[').('{'
  ^'[').('{'^('[')).(        '{'^'[').('{'^'[').('_').(
       '{'^'[').('{'^      '[').('{'^'[').('{'^'[').('{'
      ^'[').'_'.('{'     ^'[').'_'.('{'^'[').('{'^"\[").(
     '{'^'[').("\{"^   '[').('{'^'[').'_'.('{'^'[')."\_".(
    '{'^'[').("\{"^   '[').('{'^'[').('{'^'[').('{'^('[')).(
    '{'^'[').("\{"^  '[').('{'^'[').('{'^'[').('{'^'[').('{'^
    '[').('{'^'[')  .('{'^'[').('{'^'[').('{'^'[').('{'^'[').
    ('{'^'[').('{'  ^'[').('{'^'[').('{'^'[').('{'^'[').("\{"^
    '[').('!'^'+').('{'^'[').('{'^'[').'_'.'_'.'_'.('{'^'[').(
    '{'^'[').'_'.'_'.('{'^'[').'_'.'|'.('{'^'[').'|'.'_'.("\{"^
     '[').('{'^'[').('{'^'[').'_'.'_'.'_'.'|'.('{'^'[').'|'.'_'
     .'_'.('{'^'[').'('.'_'.')'.('{'^'[').'|'.'_'.('{'^'[').('{'
      ^'[').'|'.('{'^'[').'('.'_'.')'.'_'.('{'^'[').'_'.'_'.('{'^
       '[').'_'.'_'.'_'.('{'^'[').('{'^'[').('{'^'[').'_'.'_'.'_'
        .('{'^'[').'_'.('{'^'[').('{'^'[').('{'^'[').'_'.('{' ^((
         '['))).('!'^'+').('{'^'[').'/'.('{'^'[').'_'.("\{"^  '['
          ).'\\'.'\\'.'/'.('{'^'[').'_'.'`'.(('{')^ '[').'|'  .+(
            '{'^'[').'_'.'_'.'|'.('{'^'[').('/').(  '{'^'['   ).+
             "\_". '_'.'|'.('{'^'[')."'".'_'.('{'   ^"\[").   (((
                   '\\'))).'\\'.'|'.('{'^('[')).    ('|').(   '{'
                   ^('[')).    '_'.('_'). "\|".(     ('{')^   ((
                   '['))).     '|'.('{'   ^'[').     "\|".(  ((
                   "\{"))^     '[').'|'   .('{'       ^'[')  .
                   ("'").      '_'.('{'   ^'['         ).((
                   '`')).     ('{'^'[')   .'_'         .''.
                    ('{'^     '[').''.    '\\'         .''.
                    '\\'.     (('{')^     '[')         .'/'
                    .''.     ("\{"^       '[')         .'_'
                    .''.     (((          '{')         )^((
                    '[')      )).         (((          (((
                    (((        (((       (((           (((
                    (((         (((     (((            (((
                    (((          (((   (((              ((
                    ((             '\\'))               ))
                    ))              )))))               ))
                    ))             ))))))))             ))
                   )))            )))) )))))            ))
                  )))           ).'\\'  .''.           (((
                 '{')         )^"\[").   '|'          .''.
               ("\{"^                                "\[").
             '|'.('{'                               ^"\[").
                                      '|'.('!'^'+'
           ).'|'.                   ('{'^'[').('{'^
        '[')."\_".                '_'.'/'.('{'^'[').
 '('.('_').  "\|".(              '{'^'[').'|'.(('{')^
'[').'|'.'_'.(('{')^            '[').('{'^'[').('\\').
'\\'.'_'.'_'.('{'^'['          ).'\\'.'\\'.('{'^"\[").
  '|'.('{'^'[').'|'.(        '{'^'[').'|'.('{'^'[').'|'
       .('{'^'[').'|'      .'_'.('{'^'[').('{'^'[').'|'.
      ('{'^'[').'|'.     ('{'^'[').'|'.('{'^'[').'|'.('{'
     ^'[').'|'.('{'^   '[').'|'.('{'^'[').'|'.('{'^('[')).
    '|'.('{'^'[').(   '{'^'[').'_'.'_'.'/'.('{'^'[').'|'.'_'
    .'|'.('{'^'[').  '|'.('!'^'+').('{'^'[').'\\'.'\\'.('_').
    '_'.'_'.('|').  '\\'.'\\'.'_'.'_'.','.'_'."\|".'\\'.'\\'.
    '_'.'_'."\|".(  '{'^'[').'|'.'_'.'_'.'_'.'/'.'_'.'|'.('{'^
    '[').'|'.'_'.'|'.'_'.'|'.'\\'.'\\'.'_'.'_'.'|'.('{'^"\[").
    '|'.'_'.'|'.'_'.'|'.'_'.'|'.('{'^'[').'|'.'_'.'|'.('{'^'[')
     .'|'.'_'.'|'.'\\'.'\\'.'_'.'_'.'_'.'|'.'\\'.'\\'.'_'."\_".
     ','.('{'^'[').'|'.('!'^'+').('{'^'[').('{'^'[').('{'^'[').(
      '{'^'[').('{'^'[').('{'^'[').('{'^'[').('{'^'[').('{'^'[').
       ('{'^'[').('{'^'[').('{'^'[').('{'^'[').('{'^'[').('{'^'['
        ).('{'^'[').('{'^'[').('{'^'[').('{'^'[').('{'^'[').( '{'
         ^'[').('{'^'[').('{'^'[').('{'^'[').('{'^'[').('{'^  '['
          ).('{'^'[').('{'^'[').('{'^'[').('{'^'[') .(('{')^  '['
            ).('{'^'[').('{'^'[').('{'^'[').("\{"^  "\[").(   '{'
             ^'[') .('{'^'[').('{'^'[').('{'^'[')   .("\{"^   '['
                   ).('{'^'[').('{'^'[').(('{')^    "\[").(   '{'
                   ^"\[").(    '{'^'[').( ('{')^     '[').(   ((
                   "\{"))^     ('[')).(   ('{')^     '[').(  ((
                   "\{"))^     ('[')).(   "\{"^       '[').  (
                   ('{')^      ('[')).(   '{'^         '[')
                   .('{'^     '[').('{'   ^'['         ).+(
                    "\{"^     '[').'|'    .'_'         .'_'
                    .'_'.     ('/').(     '{'^         '[')
                    .''.     ("\!"^       '+')         .'"'
                    ;$:=     '.'          ^'~'         ;$~=
                    '@'|      '('         ;$^          =((
                    ')'        ))^       '['           ;$/
                    =((         '`'     ))|            '.'
                    ;$,          =((   '('              ))
                    ^+             '}';$\               =(
                    ((              '`'))               )|
                    ((             '!'));$:             =(
                   ')'            )^(( '}'))            ;(
                  $~)           ="\*"|  '`';           $^=
                 '+'^         "\_";$/=   '&'          |'@'
               ;($,)=                                ('[')&
             "\~";$\=                               ','^'|'
                                                                     
:psyduck:

tripwire
Nov 19, 2004

        ghost flow

Otto Skorzeny posted:

Oh, I think I do.

code:
perl camels
Did you write this yourself or just copy+paste it from somewhere? I'm curious how it was made... I only understand perl a tiny bit, but it seems like it would have had to be generated by another program. How/why does the program work, and how would you go about writing a program to generate it?

tripwire
Nov 19, 2004

        ghost flow

Otto Skorzeny posted:

There's a cpan module for everything, and several for most things; the one I used was Acme::EyeDrops


e: Did you really think there was a place on the internet where I could have copy+pasted an obfuscated/beautified perl program that outputs 'eat poo poo limeys' in block letters?
I didn't run the program I assumed it was "hello world" :downs:

tripwire
Nov 19, 2004

        ghost flow

Avenging Dentist posted:

And just think, you can actually do practical stuff that looks more-or-less like that. :c00l:

Please don't tell me that at this point in time :(

tripwire
Nov 19, 2004

        ghost flow

Nippashish posted:

This is from a math rendering module for mediawiki. It's a important to get rid of all those dangerous capital >'s.
code:
// circumvent certain security functions of web-software which
// is pretty pointless right here
$latex_formula = preg_replace("/>/i", ">", $latex_formula);
$latex_formula = preg_replace("/</i", "<", $latex_formula);
I don't understand this at all. At first I thought the angle brackets were being escaped but thats a forward slash, not a backslash. What does "/>/i" actually match?


edit: Ah its php. I guess /i is to ignore case. What the hell?

tripwire
Nov 19, 2004

        ghost flow

tef posted:

I wonder how you know this :v:

:q:

tripwire
Nov 19, 2004

        ghost flow
Whats so complicated :confused:

tripwire
Nov 19, 2004

        ghost flow

mr_jim posted:

code:
mr_jim@home:~/tmp/test$ cat tty.c
#include </dev/tty>
mr_jim@home:~/tmp/test$ gcc tty.c
#include <stdio.h>

int main(void)
{
        printf("holy poo poo\n");
        return 0;
}
mr_jim@home:~/tmp/test$ ./a.out
holy poo poo
mr_jim@home:~/tmp/test$
It's the only way to code.
whoa

tripwire
Nov 19, 2004

        ghost flow
How did i not know that? Are there any other neat tricks in a similar vein to that?

tripwire fucked around with this message at 05:00 on Jan 14, 2010

tripwire
Nov 19, 2004

        ghost flow

mr_jim posted:

Cut out the middle man:
code:
echo "#include </dev/tty>" | gcc -x c - && ./a.out && rm ./a.out
I actually had no idea it would work until I tried it.

Wow, thats insane! It's almost like having an interactive c REPL console for loving around with. I could see that coming in handy for just testing snippets of code without bothering to build and make a big project.

tripwire
Nov 19, 2004

        ghost flow

Avenging Dentist posted:

I've just devised a new mathematical relation. Ruby on Rails = PHP.

From above in this thread:


From a fun rant:

:laugh:

tripwire
Nov 19, 2004

        ghost flow

rt4 posted:

I'm probably going to get poo poo on for asking this, but...
:psyduck:
...under what circumstances would anyone want to restart a server during daily operation?

When it crashes silly!

tripwire
Nov 19, 2004

        ghost flow

jandrese posted:

I must be crazy because even though those lines look complicated at first, they're quite straightforward when you get down to reading them. It just checks every space around the player that they could possibly see without going outside of the bounds of the map. Pretty much everything is well named and everything.

The only "horror" is the use of the ? : construct, but this is one of those cases where they actually work.

You are crazy.

tripwire
Nov 19, 2004

        ghost flow

manero posted:

I just reverted a developer's ASCII art figlet comments from an 800+ line HTML/JS mishmash. I assume he put them in because it was too hard for him to find the code he needed to modify.

Is it too late in the evening to start drinking?

Edit: I don't think he even used figlet. He could at least have chosen a decent font.

Spoilsport :(

tripwire
Nov 19, 2004

        ghost flow

No Safe Word posted:

It's the value for the LSRequiresIPhoneOS key

Shouldn't it be an attribute of the LSRequiresIPhoneOS tag and not its own tag then?

tripwire
Nov 19, 2004

        ghost flow

Crazy RRRussian posted:

Although there is something to be said about long names that are still loving confusing and too long.
Java Babey!!!!

tripwire
Nov 19, 2004

        ghost flow
:( Those aren't even good or descriptive.

And one of the variables has the word Audio in it, twice.

Sorry, three times.

tripwire
Nov 19, 2004

        ghost flow
Maybe he was into constructivism

tripwire
Nov 19, 2004

        ghost flow

Hammerite posted:

Hahaha

"Your PIN has been reset. Have a nice day!"

"What nooooo"

Ahahahahaha

tripwire
Nov 19, 2004

        ghost flow
Only in code tags though. I don't know if thats funny or not.

pre:
def ¡(n)
  return !!n
end

puts ¡"farts".reverse!

    
Array.class_eval do
  alias :∀ :each
  
  def Σ
    return self.reduce(0) {|k, i| k + i}
  end
  
  def ∋(obj)
    return !!self.find {|n| n == obj }
  end
    
end

π = Math::PI
def √(n)
  return Math.sqrt(n)
end

def ∀(obj)
  obj.each {|e| yield e}
end

arr = [1, 2, 3]

∀(arr) {|n| puts n } #=> 1 2 3
arr.∋ 2 #=> true
arr.push π
arr.∋ π #=> true
arr.Σ #=>9.141592653589793

√ π #=>1.7724538509055159

tripwire
Nov 19, 2004

        ghost flow
I'd like to see you program the game of life more tersely!

Only registered members can see post attachments!

tripwire
Nov 19, 2004

        ghost flow

Ahahaha people still use this language willingly

Adbot
ADBOT LOVES YOU

tripwire
Nov 19, 2004

        ghost flow

tef posted:

For what it is worth (not much), the talk that started this derail is online: http://vimeo.com/17675268

The first bit is james on why php isn't that great, and the second bit is me waffling on like an idiot. Finally there is some q&a where I'm rude to the audience.


I really liked your talk! It was funny how many people in the audience were irked by your slagging on drupal :)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply