Live data from Hacker News

Confess HN: Share your Immoral Hacks, Codes or Tweaks

news.ycombinator.com

31–40 of 70 posts

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

#33
post #28

Earlier quoted context omitted.

What you really want are continuations.

Pardon my presumed ignorance, but how is that?

You implement your loop macro such that it binds some variable to a continuation, that when invoked, exits the loop. Then when you want to exit the loop, you invoke the continuation.

(Loop exits, exceptions, returns from functions, etc. are all special cases of continuations.)

This is an improvement over something like Perl's "last LABEL" statement, because you can pass the continuation around and exit the loop from anywhere you desire.

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

#35
post #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().

I don't get it. Why not just remove the exit() and have the function return to where it was called, as standard?

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

#37
post #22
post #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 d…

I've always wanted to do sort of the opposite... That is to say, I've always wanted to compile Scheme to PHP. I make the claim that PHP is the web's assembly language. Or, at least it's portable assembly language.

You need varnish!

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

#38
I didn't have very many permissions from my sysadmin to do inserts (I'm a BI guy) but I had create temporary table permissions. I needed to take about 5000 system ids with corresponding region identifiers from one system that I could only access via screen. So I wrote an auto hotkey script to screen scrap them all and place them into a notepad file. I then opened the notepad file with excel and added a column of

"union select " 233455 ", " "usa"

"union select " 233455 ", " "canada"

Then puttied into my linux shell, opened emacs and added "create temporary table select 23456 as 'systemid', 'usa' as 'region'

Then pasted the entire csv of union selects. Did my joins, etc... Got the report out on time. I know now that I could have done it with an emacs macro, but just didn't have time to figure it out.

shudder

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

#39
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.…

Sounds marketable, especially if you include a markov chain to grab variables off the scraped page and insert them into your email (ie, "I love #{favorite_band} too!").

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

#40
Signing up for classes at FSU was always a huge pain. The session started at 8am and good classes filled up quickly. If a class was full you had to continually type in the registration number and submit the form to see if anyone had dropped it (there was a lot of turnover as people loaded up their schedule and then called their friends to see what timeslots they were in.)

I had just taught myself php and wrote a curl script with the classes I wanted, and the few timeslots I wanted, in order. After a brief struggle I finally realized I needed to hit port 443 instead of 80 and, voila, my initial class registration was complete. A few were full but it kept hammering the site every 10 seconds and over the next few hours I got emails whenever it successfully registered me with a class.

I actually thought about charging $5 to handle other students' registrations because they hated dragging out of bed at 8am and refreshing their browser for an hour. Somehow I decided the university wouldn't approve....

Post reply on HN