Skip to content

Instantly share code, notes, and snippets.

@natw
natw / fizzbuzz.py
Created November 15, 2012 16:22
best fizzbuzz
import random
for i in range(0, 100):
if not i % 15:
random.seed(1178741599)
print [i+1, "Fizz", "Buzz", "FizzBuzz"][random.randint(0,3)]
@jaseg
jaseg / README.md
Created August 27, 2012 10:10
Windows XP as your screensaver!

Windows XP as your screensaver!

Overview

When xscreensaver starts screen saving, instead of a boring screen saver it spawns a small shell script. This shell script starts a new X server with a very minimal awesome window manager and unfreezes a kvm virtual machine containing a Windows XP on that X server, ready to be used by any passersby. To unlock the screen, you need to switch back to the VT where your usual X is running. As soon as the screen is unlocked, xscreensaver sends a SIGTERM to the shell script which in turn stops all the X servers, window managers and virtual machines it launched and resets the VM image. Should the VM exit before the screen is unlocked because somebody pressed "Shut down" the VM image is reset and the VM restarted.

Setup

@jaseg
jaseg / gist:3334991
Created August 12, 2012 22:32
Password manager without a password manager

Prelude

Since password managers are big and complicated and I currently am pretty bored since I am sitting in a car for a few hours, here is a simple algorithm to generate resource-specific, unique passwords using a master password and no password database.

WARNING

As pointed out here: http://news.ycombinator.com/item?id=4374888 this method is broken.

Usage

@aperson
aperson / overviewer_filters.py
Created May 9, 2012 11:57
A set of marker filters for the Minecraft Overviewer
def screenshotFilter(poi):
'''This looks for signs that have their first line in the 'Image:<id>' format, where <id> is an
id from an Imgur.com image.'''
if poi['id'] == 'Sign':
if poi['Text1'].startswith('Image:'):
poi['icon'] = "painting_icon.png"
image_html = "<style>.infoWindow img[src='{icon}'] {{display: none}}</style><a href='http://imgur.com/{id}'><img src='http://imgur.com/{id}s.jpg' /></a>".format(icon=poi['icon'], id=poi['Text1'][6:])
return "\n".join([image_html, poi['Text2'], poi['Text3'], poi['Text4']])
def playerFilter(poi):