18
Jan

Python multiprocessing is fucking sweet

   Posted by: Swizec   in Uncategorized

CRAY-1 (no longer used, of course) displayed i...
Image via Wikipedia

You know how it is said every programmer needs to learn how to do parallelisation and funky stuff on multi-core multi-processor beast of machines? And how such machines aren’t even really beasts these days, they’re our run of the mill desktop and portable computers.

This is the world we live in.

It’s getting worse by the hour!

Very soon the first thing a young programmer will hear out of a lecturer’s mouth will be Thread-Safe.

But there’s something we can do about that even today. First of all, we can kiss threading good bye. Sure it’s sweet and yes it sort of works. But ew! It’s like trying to make a marine corps do their job with everyone’s finger in someone else’s arse. That’s the problem with threads you see, they keep picking each other’s arses and noses and then nobody can do any work.

Multi processing to the rescue!

Running an algorithm in several processes is the only thing that makes it run on several processesors in parallel and it gives each process its own memory space and everyone is nicely contained in their own little world. But fuck, now you can’t exactly pick another process’s arse when you need to … like when eating through a common queue of tasks.

And then python’s multiprocessing module, library, thingy, whatever it’s called, comes into play.

It. Just. Makes. Everything. So. Fucking. Easy!

This weekend I was working on a scrobbler for Delicious. Basically this thing is supposed to go through a user’s Delicious history, scrape every website it finds, send the results to three different semantic API’s and build connections between the tags those API’s return and the ones the user used to tag the particular link.

Now obviously there’s a lot of downtime involved here for every iteration. You’re easily looking at 10 solid seconds of waiting per website. This means that scrobbling 838 pages (my stress test) would take about two and a half hours. With multiprocessing it took something like 20 minutes.

The beauty of this approach is that I’ve never ever ever done anything in parallel. And yet I could do funky things like worker pools, queues, semaphoring and a bunch of other stuff I’ve only heard of in fairy tales until now … in an hour.

So there you go, an investment of a few hours for learning from scratch and some tweaking to create a ten-fold increase in speed.

Reblog this post [with Zemanta]
12
Jan

How ikigai has changed my style

   Posted by: Swizec   in Inspiration

This is the second post in the series of How <x> changed my style where I shall talk about tools and events that had a significant impact on my style of doing things. If you happen to like this idea, I would be very happy if you could help it spread like wildfire, because it’s a form of pay-it-forward where we say Thanks for cool stuff.

A few weeks ago, or was it days, I forget, I stumbled upon a rather fascinating video about living to be a hundred years old and more. But not just sitting around and waiting to die kind of 100+, the kind where at 100 you’re still happily running around, building fences and doing stupid crap most westerners really wouldn’t expect you to do anymore.

Everything in there is fine and good, but the most important bottom line I picked up on was the importance of having an ikigai. It’s all wonderfully explained in the video so I won’t go into what ikigai is, I’d rather say a little bit about what it feels like to discover one’s ikigai. (it doesn’t matter whether you know what it’s called or not, I didn’t for months)

As late as just last Spring my life revolved around going to a school I hated, having a job that was alright but not quite that and occasionally getting together with my girlfriend. I was doing some nifty stuff in the evenings and late at night, but mostly it was just another burden no matter how much I loved it and felt like I believed in it.

Then something changed, I can’t exactly put my finger on it, but it changed. The symptom of this change was that I quit my job and devoted most of my attention to the side-project, which evolved far far far away from what it was back then.

And suddenly much was different. School suddenly seemed interesting and awesome, I started learning exciting new things every day for the first time since being a kid. Getting up in the morning was … well it’s still fucking hard, I’m just not a morning person :P … but staying up at night was painless as hell. Meh, I won’t pretend like I can describe this, just try it.

Reblog this post [with Zemanta]

Last night I watched a bloody amazing video of a university professor who was just oozing awesome. Seriously, this guy is all kinds of cool and I would love to someday have a professor that structures his lectures and classes like this guy does.

Now watch the video, I’m not here to blab, I’m here to make you watch this :)

Reblog this post [with Zemanta]
11
Jan

How Lisp changed my style

   Posted by: Swizec   in Inspiration

IBM 402 Accounting Machine plug-board wiring. ...
Image via Wikipedia

This is the first post in the series of How <x> changed my style where I shall talk about tools and events that had a significant impact on my style of doing things. If you happen to like this idea, I would be very happy if you could help it spread like wildfire, because it’s a form of pay-it-forward where we say Thanks for cool stuff.

Some months ago, fuck has it been two? three? four?,  I attended a series of lectures on Lisp and functional programming and some other useful thingies by Simon Belak. At first it all felt like just another useful tool under my belt. Cool, Lisp, yeah, so what do I do with this? Meh, it’s cool, knowing this can’t do any more harm than a parenthesis thrown at a boomerangual trajectory smashing the windscreen of our hapless programmer.

However it did do damage, dear god it did so much damage! It fucked with my mind man, it fucked with everything. Nothing has been the same since!

No not really, but lately I have started noticing some pretty remarkable changes in the way I write code and more importantly, the way I think about code. Suddenly everything is a function is a function is a function! It’s quite remarkable really, sure I’ll often still code the very obvious object as an object, but I’m no longer forcing object oriented programming where it doesn’t belong.

And then there are even more radical examples of my brain changing, for the better I believe. Let’s take a simple comparison of writing a function that calculates the average of a list of numbers. In the old days I’d write it like so:

avg = 0
for key in self.tags:
	avg += self.tags[key]
avg /= len(self.tags)

These days, and it was fucking surprising when I noticed myself doing this, the same function gets written with a much bigger lisp:

avg = reduce(lambda a,b: a+b, tags.itervalues())/len(tags)

I really couldn’t go so far as to say whether this change in style and thinking is good or bad, but it certainly is interesting to just sit back and watch yourself from a distance as you morph and change before your very eyes.

So what’s changed your style lately?

Reblog this post [with Zemanta]

After tonight’s midterm I simply couldn’t resist driving around and about Ljubljana in this magnificent snowy weather we’re having. It’s very rare to get a chance to drive in conditions where everyone is nice and calm. Nobody honks at you, nobody tries to swerve around you and do stupid things, nobody is in a hurry. It’s just fucking awesome!

Not to mention the snow and the occasional drift around a corner! Orgasmic! Oh!

Although winter services could be a little more vigilant, I got thrown all over the place driving through tracks others made. There was snow up to 20 centimeters deep someplaces! On main roads!!

Anyway, had fun, was awesome, got stuck in the snow on the parking lot at home. That was a big lol, but a surprisingly large amount of people I don’t know decided to be helpful and we got the car into a parking space in no time.

IMG00156IMG00153IMG00152

Reblog this post [with Zemanta]
8
Jan

The best copypasta ever copy pasted

   Posted by: Swizec   in Insanity

Erotic art by Édouard-Henri Avril.
Image via Wikipedia
OMFG Guys… I seriously always thought that those wincest stories were bullshit, I have two sisters, though one’s a baby and the other is two years older than me. The thought of having sex with her was both simultaneously really creepy and in the realm of ‘would-never-happen-to-me’. My sister’s sort of a flower child, garlands and stuff all around her room. So I’m sound asleep one night, I’m a junior in High School and she’s at community college, she hasn’t moved out yet… and she knocks on my door much louder than she needed to, but she whispers through my door ‘Can I come in?’…
Well of course she can, she’s my sister. Anyway, she comes in in the skimpiest fucking night gown I’ve ever seen. I didn’t know she even had a night gown. She tells me that she thought she heard a gunshot in the woods and she doesn’t want to be alone. She asks if she can sleep with me, and before my mind gets out of the gutter, I recoil… but realizing what she means, I tell her of course and I let her into the bed. As she climbs in, I can smell honey on her breath, it’s mesmerizing. That sweet smell brings me closer to her and I curl up next to her like we were just little kids again.
Her snoring has always been loud, especially deep into the nights, but half-an-hour into trying to get some winks, she’s still not snoring. “What do you think of us?” she says randomly. I stammer because I’m fighting the fact that I’m turned on right now AND what she just asked. I tell her that she’s a wonderful sister and I loved her. She told me “What if I was more than her sister? Something much more?” And I shit bricks… It all became so clear to me now.
All those years of wondering, staring at her door, waiting for her, laying awake at night just thinking, rolling crazy suspicions around in my head, all of it came down to this Wednesday night, this very moment, everything I had wondered about her became very… very clear. It was an epiphany at its purest and most tense, most… terrifying in its own way. I could finally say it with no regret, no fear, only truth.
“You’re a bear, aren’t you?” I say. The honey, the gunshot in the woods… there are NO WOODS around here, the berries strung up all around her room. She lept out of bed and ripped off her mask, roaring and making other bear noises! I jumped out of my window and it gave chase, out into the streets! Moving as fast as my legs will let me, eventually she gives up and moves back into the house. Standing on the street, I know it in my heart… she’d always be my special bear.

OMFG Guys… I seriously always thought that those wincest stories were bullshit, I have two sisters, though one’s a baby and the other is two years older than me. The thought of having sex with her was both simultaneously really creepy and in the realm of ‘would-never-happen-to-me’. My sister’s sort of a flower child, garlands and stuff all around her room. So I’m sound asleep one night, I’m a junior in High School and she’s at community college, she hasn’t moved out yet… and she knocks on my door much louder than she needed to, but she whispers through my door ‘Can I come in?’…

Well of course she can, she’s my sister. Anyway, she comes in in the skimpiest fucking night gown I’ve ever seen. I didn’t know she even had a night gown. She tells me that she thought she heard a gunshot in the woods and she doesn’t want to be alone. She asks if she can sleep with me, and before my mind gets out of the gutter, I recoil… but realizing what she means, I tell her of course and I let her into the bed. As she climbs in, I can smell honey on her breath, it’s mesmerizing. That sweet smell brings me closer to her and I curl up next to her like we were just little kids again.

Her snoring has always been loud, especially deep into the nights, but half-an-hour into trying to get some winks, she’s still not snoring. “What do you think of us?” she says randomly. I stammer because I’m fighting the fact that I’m turned on right now AND what she just asked. I tell her that she’s a wonderful sister and I loved her. She told me “What if I was more than her sister? Something much more?” And I shit bricks… It all became so clear to me now.

All those years of wondering, staring at her door, waiting for her, laying awake at night just thinking, rolling crazy suspicions around in my head, all of it came down to this Wednesday night, this very moment, everything I had wondered about her became very… very clear. It was an epiphany at its purest and most tense, most… terrifying in its own way. I could finally say it with no regret, no fear, only truth.

“You’re a bear, aren’t you?” I say. The honey, the gunshot in the woods… there are NO WOODS around here, the berries strung up all around her room. She lept out of bed and ripped off her mask, roaring and making other bear noises! I jumped out of my window and it gave chase, out into the streets! Moving as fast as my legs will let me, eventually she gives up and moves back into the house. Standing on the street, I know it in my heart… she’d always be my special bear.

Reblog this post [with Zemanta]
6
Jan

Came up with a wisdom

   Posted by: Swizec   in Quotables

If the leader of a dictatorship is a wolf then the leader of a democracy is a wolfpack.

6
Jan

The greatest casual game ever devised

   Posted by: Swizec   in Uncategorized

Machinarium 2009-10-20 02-22-26-27
Image by deadman009 via Flickr
Machinarium 2009-10-21 03-01-19-71
Image by deadman009 via Flickr
Machinarium 2009-10-20 03-35-26-50
Image by deadman009 via Flickr
Machinarium 2009-10-20 02-42-19-66
Image by deadman009 via Flickr
Machinarium 2009-10-21 02-57-02-40
Image by deadman009 via Flickr
Machinarium 2009-10-20 01-28-26-39
Image by deadman009 via Flickr

Now and anon I like to fire up a game when I’m feeling a dash unmotivated to do pretty much anything. Most often I simply don’t have time to play, so when I do play I want the game to be something fascinatingly epic but in such a way as can be enjoyed ten minutes here, twenty minutes there, an hour over yonder. NOT something you have to play for three hours straight before you get in the groove.

Two nights ago I discovered Machinarium through a hapless link in a msn chat.

I was instantly hooked, the art is simply amazing, the level of detail beyond all comparison. The gameplay itself. Oh! Don’t get me started, I could *gasm all over at the mere thought of the brilliance therein.

Basically you play a robot that goes through a few adventures and solves many a puzzle in a beautifully designed world to, well I dont’ know what yet, haven’t gotten that far. It would seem though that it’s got something to do with love because whenever his memories are shown they’re about a lady robot.

It is also one of the hardest puzzle games I’ve ever had the pleasure of playing. Shivers, Monkey Island, Abe’s Oddysee/Exoddus? Don’t get me started, weaksauce in comparison to Machinarium! Downright bloody weaksauce! Often you will encounter a proper logic game, one as can be bought in stores sometimes, you’ve got to solve just to open a door.

Other times you are left solving five puzzles just to get to an item that solves a previous puzzle.

The best thing though? It’s absolutely DRM and any and all copy protection free. Buy the game, get the downloads for all OS’s and a soundtrack! Yay! How could I resist? So I didn’t, I shelved out the few euro it takes and it was possibly one of the best moneys ever spent.

Big game publisher, if you are reading this, yes, yes I do only buy games if they come without DRM. Sometimes I consider buying a big-name game, but usually get disappointed by the process half-way through and bail.

Reblog this post [with Zemanta]
4
Jan

3 pikchurs of a pretty goat

   Posted by: Swizec   in Insanity

While I was browsing through my blackberry a few moments ago to find a certain photo I stumbled upon some photos I took this Christmas.

They’re of a very bloody cute small boy goat thing. My grandmother says this is as big as they get and by god the little rascals are awesome. Soon as I came into the barn this guy jumped on me and demanded petting!

PETTING!

A goat!!

:D

Here he is, now let’s make him famous just because he’s so cool.

IMG00104IMG00097IMG00090

2
Jan

Kids, shrooms are fucking cool

   Posted by: Swizec   in Uncategorized

Devils Punchbowl Waterfall at Arthurs Pass in ...
Image via Wikipedia

Perhaps it’s not the best of ideas to talk about one’s recreational drug experiences publicly, but everyone who reads this blog is a junkie anyway so it doesn’t matter. (ie. they’re caffeine drinkers! *gasp*)

So last night I gave my first ever proper try to psychoactive substances – namely shrooms – and kicked off my psychonaut carrier with a boom. Since I don’t know how much I actually took, I’ll just describe some of the experiences that stuck in my mind and perhaps someone can tell me what happened.

Before you get too excited, there were no religious revelations, no openings of the mind and I most certainly didn’t start climbing down any rabbit holes. But by god was it fucking amazingly awesome fun!

  1. A lot of the experience felt like it wasn’t happening in real time, but more like I was remembering it from a distant future – this happens to me almost every time I’m intoxicated though, the shrooms perhaps just intensified the whole experience.
  2. Time stopped. This might have been just because somebody put a large stopped clock in the middle of the room, but nevertheless it was exactly like we were all stuck in a time bubble and it would be 10:37 for all eternity.
  3. Perceived paralysis – don’t know what exactly caused this, but most of the time I couldn’t feel my extremities and felt quite odd from the waist down. This might be my deep phobia of paralysis popping up – but I didn’t perceive it as frightening, just as bloody exciting.
  4. Perspective distortion – this was quite … odd … everything was in a strange perspective and just plain wrong. It didn’t make sense and as a result I felt very strong vertigo whenever I tried to do anything.
  5. We are world – perhaps the most emotional sensation from the whole trip. Simply put I felt like I was always in a world of my own, or sometimes “our” own. When I went to get a drink, the faucet pulled me in and the sink felt like the whole world, like there is nothing else. Basically, whenever my visual surroundings changed it felt like the whole world became those surroundings.
  6. Extreme naivety – this was of course closely followed with extreme naivety. When somebody said that we’re in a mountain cabin, I was convinced, downright certain of it, that just on the other side of the door there was at least a meter of snow keeping us inside.
  7. A bit of paranoia – I’m often a fairly paranoid individual when I get into a bad train of thought, but this was different because it was backed by some pretty solid fears. Like when people made funny and sarcastic remarks of some sort I felt like bashing their head in and shouting Don’t tell me this things! Not now!
  8. But the worst was perceived incontinence – of course this ties into paralysis and paranoia, but I swear perceiving my legs’ warmth as something external and having wet socks from the leak  in the bathroom made me feel like I was constantly pissing all over myself. Luckily in the morning I didn’t find any evidence to back this perception. Phew.
  9. BOJONEGORO, EAST JAVA - DECEMBER 23:  Workers ...
    Image by Getty Images via Daylife
  10. Synesthesia – this was definitely the most fun. We were watching a movie and after a random comment from someone I discovered, to my surprise, that I wasn’t perceiving room temperature as a physical effect in my body, but rather as the colour hue of the movie. So when I was hot the movie was blazing red and when I was cold it was frozen blue. Quite funky.
  11. Complete and utter sensual overload – it sucked a bit to be forced into leaving the party just because I vomited a few times – knowing the very early physical symptoms of imminent vomiting was SO helpful, thank you House MD – but I just couldn’t take it anymore. There was too much everything. Too many sounds, too much music, too much television. Everything was moving in strange directions and being funky … like for example the edges of items buzzing around into a blur. Wtf was that.
  12. Pretty fractals – when I got home into a calm, dark and quiet environment and went to sleep all was well. There were many patterns and weird things flying around to keep me company and I could still hear the music.
  13. Sleep confusion – now granted I’ve often had this happen without being on drugs, but it’s still fun when it happens because of drugs as well. It’s the strange feeling when you notice your body falling asleep, but your brain does not. The sleep paralysis is a bit scary, but it’s still quite a lovely feeling. You’re both asleep and awake. Mindboggling!

There we are, that’s all of the experiences I can remember to write down. This list is going to be valuable to me in the future to help me kickstart these memories against because I don’t intend on doing psychonautics too often. Expensive and time consuming – two things I can’t afford.

PS: no hangover whatsover. Such, perfect, utter clarity the moment I woke up this morning at 3pm.

PPS: psychonautics are far more fun than sex … and I’m known far and wide as a total perv.

Reblog this post [with Zemanta]
Page 2 of 5512345...Last »