Skip to content

Instantly share code, notes, and snippets.

@sli
sli / google_music.py
Created August 22, 2011 14:19
Google Music invitation contest script.
import random
participants = [
# Participants here
]
winners = []
while len(winners) < 4:
c = random.choice(participants)
@sli
sli / block-sprites.css
Created October 28, 2011 02:34
Minecraft item/block CSS sprites (1.0)
/* Uses this image: http://dl.dropbox.com/u/5768678/minecraft-sprites/blocks.png */
.block {
background-image: url('blocks.png');
width: 32px;
height: 32px;
}
#cobblestone { background-position: 0px 0px; }
#stone-bricks-1 { background-position: 0px -32px; }
#lapis-lazuli-block { background-position: 0px -64px; }
@sli
sli / hexmap.htm
Created November 24, 2011 09:35
Hexmap Generator
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Hexmap Test</title>
</head>
<body>
<canvas width="500" height="500" id="board" style="border:1px solid black; padding: 1em;"></canvas>
<script src="hexmap.js"></script>
</body>
@sli
sli / hexmap.py
Created November 24, 2011 22:14
Hexmap Generator (PyGame)
import sys
import pygame
from pygame.locals import *
##### Rendering Fuctions #####
def drawGrid(context, width, height, cell_size):
column = 1
row = 0
at = 0
@sli
sli / hexmap-raphael.js
Created December 22, 2011 18:48
Raphael Shapes hexmap generator.
var hexmap = function(paper_x, paper_y, width, height, hex_radius) {
var paper = Raphael(paper_x, paper_y, width, height);
var grid_width = Math.round(paper.width/(hex_radius*2));
var grid_height = Math.round(paper.height/(hex_radius*2));
var x, y, column_mult;
var row_mult = 0;
for (var row=1;row<=grid_height;row++) {
@sli
sli / rpg.py
Created December 27, 2011 04:22
Silly RPG stuff.
import textwrap
wrapper = textwrap.TextWrapper(width=50,subsequent_indent=' '*13)
class Item(object):
def __init__(self, name, description='No description.'):
self.name = name
self.description = description
def display(self):
@sli
sli / kana.htm
Last active April 20, 2016 23:08
A Hiragana/Katakana trainer, similar to (but slightly smarter than) Realkana.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Kanagrinder</title>
<!-- Styles -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/1.4.0/css/bootstrap.min.css">
<style type="text/css">
td { text-align: center; }
@sli
sli / dijkstra.py
Created January 25, 2012 01:06
Dijkstra's algo implementation for Arkham Asylum
from __future__ import generators
class priorityDictionary(dict):
def __init__(self):
'''Initialize priorityDictionary by creating binary heap
of pairs (value,key). Note that changing or removing a dict entry will
not remove the old pair from the heap until it is found by smallest() or
until the heap is rebuilt.'''
self.__heap = []
dict.__init__(self)
@sli
sli / todo-ls.htm
Created March 25, 2012 01:59
localStorage-based todo list
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Todo Demo</title>
<script>
window.onload = function() {
var item, complete, list;
list = document.getElementById('list');
@sli
sli / TropiaryStart.java
Created April 1, 2012 01:08
I hate OCL.
package com.signedlongint.tropiary;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class TropiaryStart extends Activity implements View.OnClickListener {
Button bSearch, bSaved, bRandom;