Instantly share code, notes, and snippets.

View Breakout.js
import Phaser from 'phaser';
class Game extends Phaser.Game {
constructor (width, height, mode, domElement='content', arg=null) {
super(width, height, mode, domElement, arg);
this.state.add('Game', GameState, true);
}
}
class GameState extends Phaser.State {
View game_tictactoe.py
import pygame
import sys
import os
# SDL is the library which Pygame uses
# We use SDL to put the game window at the screen's centre
os.environ['SDL_VIDEO_CENTERED'] = '1'
SCREEN_SIZE = (800, 640)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
View pong.py
import pygame
import sys
import random
SCREEN_SIZE = WIDTH, HEIGHT = (800, 640)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (50, 255, 50)
BLUE = (50, 50, 255)
SCORE_LIMIT = 5
View pygame-circles.py
import pygame
import sys
SCREEN_SIZE = WIDTH, HEIGHT = (640, 480)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 50, 50)
GREEN = (50, 255, 50)
CIRCLE_RADIUS = 30
View solar-system.coffee
class Planet
constructor: (@radius, @colour, @baseX, @baseY, @orbitSpeed) ->
@x = @baseX
@y = @baseY
@startTime = Date.now()
@theta = 0
update: (sun) ->
newTime = Date.now()
View fsm.coffee
class Transition
constructor: (@currentState, @input, @nextState) ->
match: (currentState, input) ->
return @currentState is currentState and @input is input
getNextState: ->
return @nextState
View ttconnect_ministry_scraper.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''A web scraper for the Government of Trindad and Tobago's Ministry data. The
main link: http://www.ttconnect.gov.tt/'''
from lxml import html
import requests
import json
from collections import OrderedDict
from argparse import ArgumentParser
View sieve_of_eratosthenes.js
var populateSieve = function(N) {
'use strict';
var arr = [N+1];
arr[0] = false;
arr[1] = false;
for (var i = 2; i <= N; i++) {
arr[i] = true;
}
return arr;
};
View namis_scraper.py
from lxml import html
import requests
import time
date = time.strftime('%d-%m-%Y')
output = ''
try:
page = requests.get('http://www.namistt.com/')
except requests.exceptions.RequestException as e: