Live data from Hacker News

Confess HN: Share your Immoral Hacks, Codes or Tweaks

news.ycombinator.com

11–20 of 70 posts

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#11
I wanted to adapt someone's command-line-based program into a library, but it wasn't designed as such. The program was strewn with calls to exit(), and on encountering one of these I would just want to return to the function that called into the library rather than exiting the whole program. So I did a setjmp() prior to calling into it, and used the preprocessor to turn exit() into longjmp().

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#12
A year ago I wrote a half-assed map/reduce in PHP. I partitioned a day's worth of logs across hundreds of gzipped CSV files by key hash, so I could run four reducers (the box has four cores) and each could suck a partition into 1/4 of physical memory.

After about six months of pathological random access (and what I assume to be epic fragmentation), the disk failed. I hope to migrate to our shiny new Hadoop cluster while the replacement disk lasts.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#13
Damnit, most of my best hacks could be considered proprietary, though I seriously doubt any of the companies involved would care. One that I can share:

I architected a game-creation platform so that all the game runtime code was both legal Flash and legal JavaScript, such that the same code could be inserted verbatim in both the JavaScript editor and the Flash compiled version.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#14
Well, here's one that, erhm a friend of mine, did.

dating has moved online, and the key to getting laid is basically to get as many contacts going as you can. It's like a funnel: The more you put in at the top the more comes out at the bottom. The problem of course is that all that initial contact and writing back and forth with potential subjects is somewhat timeconsuming.

Enter the magic of webscraping and hacking.

It's not hard to make a program that will send a standard message to a chosen group of profiles on a dating site based on search criteria. It's not hard to make an interface that let's you do the initial round of communication with the people that respond in an interface that's somewhat more optimised for communicating with a lot of users at the same time. Once you get past the first three or four messages it's time to move on to the more personal aspects of communication. It saves a lot of time, and you only spend time on girls that have actually shown some interest.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#15
I used ctypes to change the base class of Python's GeneratorExit from Exception to BaseException because the official patch didn't make it in until 2.6.

import __builtin__, ctypes

class ImvuGeneratorExit(BaseException): pass

__builtins__['GeneratorExit'] = ImvuGeneratorExit

__builtin__.GeneratorExit = ImvuGeneratorExit

ctypes.c_void_p.in_dll(ctypes.pythonapi, 'PyExc_GeneratorExit').value = id(ImvuGeneratorExit)

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#16
#1

Using a negative index on an array in order to get around a signed 16 bit limitation. Just stuck another blank array of the same size in front of it in the memory map and kept going.

For all I know that code is still running :)

It was quite hard to convince the compiler that I wanted to keep the never referenced/read array.

Stupid mainframes and their limits...

#2

In the 386 days you could get a separate co-processor, the 387 for float work (or a weitek if you had the money). The clock line between the two of them was shared but I found out that you could disconnect the clock pin of the 387 and connect it to its own oscillator to overclock it. That way even if the rest of the board could not be overclocked at least the float processor was. By carefully interleaving float and co processor opcodes you could then run a lot faster than you would have been able to otherwise.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#17
...:: Hacking World Cup Tickets for Germany 06 ::...

Australia was a late qualifier for the tournament. The ticket submission was via email. Tickets were allocated on a first email received basis after 09:00. There was a countdown webpage which advertised the time.

--- Preparation

* I telneted to port 25 of the destination and saw via EHLO that the mail server clock was 1 minute faster than advertised on the webpage, giving a start time advantage

* I pre crafted the SMTP message into a text file. This had the sending time as 09:00:01

* Before the day I checked out how long the mail server would keep open any connections without any input (10 minutes)

---

Cometh the day:

* I opened up several telnet sessions to port 25 , 10 minutes before.

* when the time came, I did several EHLO messages to check my session was alive

* I cut'n'pasted my SMTP message into the server

* I closed all my connections (other people were bouncing at this point as the server connection pool was exhausted)

---

I got my tickets.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#18
I am writing PHP in Common Lisp, and my codebase is litered with the following:

  (defun make-record (&rest args) ; insert &allow-other-keys ;-)
    (let ((*db-auto-sync* t))
          (object (make-instance 'record args)))
       (when object
         (update-records-from-instance object))))
Both the LET binding of db-auto-sync and the update-records call do the EXACT same thing. However, due to weirdness I don't grok quite yet, the calls to the db driver get in only half the time, even with query caching disabled.

That's for record insertion.

For record update, I have something far more sinster. Every accessor has an :after method with explicit SQL inside. Allow me to explain this: Imagine if you had to write a function that does something as a side-effect everytime an assignment is made! E.g. I have a macro that generates explicit slot serializer for ever accessor; I managed this by wrapping defclass twice and now I program in a weird, session-oriented php-like dialect that's just too fucking brittle.

We will go over it after our first demo :-P

[Edit:

I wrote the following database agnostic routines and I deal with the db strictly through them.

LIST-OBJECTS type

LIST-OBJECTS-WHERE type slot value

FIND-OBJECT type slot value

FIND-OBJECT-WHERE type slot value

UPDATE-OBJECT-WHERE type slot value new-value

DELETE-OBJECT-WHERE type slot value

type is both a Lisp class and SQL table name. Slot and value are used in WHERE clauses, e.g. (select [*] type :where [= slot value])

]

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#20
post #14

Well, here's one that, erhm a friend of mine, did. dating has moved online, and the key to getting laid is basically to get as many contacts going as you can. It's like a funnel: The more you put in at the top the more comes out at the bottom. The problem of course is that all that initial contact and writing back and forth with potential subjects is somewhat timeconsuming. Enter the magic of webscraping and hacking.…

Some of my Israeli mates here in London tore through the JDate website selection.

They would have debriefings on successful strategies and accuracy of photo-to-reality. They took turns and had harsh debates about who was first with the hottest ones.

They analysed which girls knew each other so that they could keep disjoint social scenes going at the one time.

It was amazing how many they got through.

They eventually fucked themselves out (and JDate too). They're married now, to a man.

Post reply on HN