Skip to content

Instantly share code, notes, and snippets.

View msanatan's full-sized avatar
🏠
Working from home

Marcus Sanatan msanatan

🏠
Working from home
View GitHub Profile
@msanatan
msanatan / down1.sh
Created January 7, 2020 19:54
Docker down one container
docker-compose rm -f -s -v yourService
@msanatan
msanatan / Breakout.js
Last active November 7, 2017 04:12
Breakout in ES2015
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 {
@msanatan
msanatan / game_tictactoe.py
Last active September 10, 2017 04:24
Tic Tac Toe with Pygame
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)
@msanatan
msanatan / pong.py
Created June 1, 2017 04:57
Pygame Pong - not the way I would naturally code this, to be used in a class for teaching
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
@msanatan
msanatan / pygame-circles.py
Created May 31, 2017 18:22
Pygame example with moving circles
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
@msanatan
msanatan / coin-sprite-sheet.png
Last active March 26, 2016 23:05
Animate a coin sprite with ES2015
coin-sprite-sheet.png
@msanatan
msanatan / solar-system.coffee
Created September 25, 2015 03:23
HTML5 solar system - definitely not drawn to scale lol. Orbit speeds are roughly to scale :)
class Planet
constructor: (@radius, @colour, @baseX, @baseY, @orbitSpeed) ->
@x = @baseX
@y = @baseY
@startTime = Date.now()
@theta = 0
update: (sun) ->
newTime = Date.now()
@msanatan
msanatan / fsm.coffee
Last active August 29, 2015 14:17
FSM implementation in CoffeeScript
class Transition
constructor: (@currentState, @input, @nextState) ->
match: (currentState, input) ->
return @currentState is currentState and @input is input
getNextState: ->
return @nextState
@msanatan
msanatan / ttconnect_ministry_scraper.py
Last active August 29, 2015 14:15
Scraper for ttconnect Government Ministry page
#!/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
@msanatan
msanatan / sieve_of_eratosthenes.js
Last active August 29, 2015 14:09
Sieve of Eratosthenes
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;
};