Skip to content

Instantly share code, notes, and snippets.

View drevantonder's full-sized avatar
🎧
Probably making something cool but somewhat useless...

Andre van Tonder drevantonder

🎧
Probably making something cool but somewhat useless...
View GitHub Profile
def move_to_dir(old, new):
"""Converts using e.g. old position (1,1) and new position (2, 1) to a direction (RIGHT)"""
if old[0] < new[0]:
return "RIGHT"
if old[1] < new[1]:
return "DOWN"
if old[0] > new[0]:
return "LEFT"
return "UP"
@drevantonder
drevantonder / button.py
Last active October 1, 2015 06:54
Simple pygame button drawer borrowed some code from Simon H. Larsen program Button Drawer
import pygame
class Button(pygame.sprite.Sprite):
def __init__(self,text,x,y,width=100,height=100,color=[230,230,230]):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface([width, height])
self.image.fill(color)
font_size = int(width//len(text))
myFont=pygame.font.SysFont("Calibri",font_size)
myText = myFont.render(text, 1, (0,0,0))
@massahud
massahud / Portable Node.js andNPM on windows.md
Last active December 24, 2025 14:21
Portable Node.js and NPM on windows
  1. Get node binary (node.exe) from http://nodejs.org/download/
  2. Create the folder where node will reside and move node.exe to it
  3. Download the last zip version of npm from http://nodejs.org/dist/npm
  4. Unpack the zip inside the node folder
  5. Download the last tgz version of npm from http://nodejs.org/dist/npm
  6. Open the tgz file and unpack only the file bin/npm (without extension) directly on the node folder.
  7. Add the the node folder and the packages/bin folder to PATH
  8. On a command prompt execute npm install -g npm to update npm to the latest version

Now you can use npm and node from windows cmd or from bash shell like Git Bash of msysgit.

@ubermuda
ubermuda / nginx.conf
Created November 5, 2013 22:13
Proxy a unix socket HTTP server to a tcp port using nginx.
server {
listen 127.0.0.1:9000;
location / {
proxy_pass http://unix:/var/run/docker.sock:/;
}
}
@viola
viola / gist:1070410
Created July 7, 2011 20:00
Example of fetching Hash (key,value) to the simple_form collection.
-- model
some sort of constant hash:
HASH_NAME = {
0 => "Choose:",
1 => "On-Campus Recruiting - CSO",·
2 => "CSO Staff Referral",
3 => "Faculty Contact",·
4 => "Career Day",·
5 => "CSO Summer Job Listing",·
6 => "Alumni Contact",·