Skip to content

Instantly share code, notes, and snippets.

View piratefsh's full-sized avatar

Sher Minn Chong piratefsh

View GitHub Profile
@piratefsh
piratefsh / cracklepop.js
Last active August 29, 2015 14:20
Crackepop
// Write a program that prints out the numbers 1 to 100 (inclusive).
// If the number is divisible by 3, print Crackle instead of the number.
// If it's divisible by 5, print Pop. If it's divisible by both 3 and 5, print CracklePop.
// Note, process.stdout.write prints without newline
for(var i = 1; i <= 100; i++){
if(i % 3 == 0){
process.stdout.write('Crackle');
@piratefsh
piratefsh / tree_searcher.py
Created May 3, 2015 02:39
Depth-first searcher
# Task: Depth-first searcher
class Node():
def __init__(self, id):
self.id = id
self.children = []
def add_child(self, node):
self.children.append(node)
def __repr__(self):
@piratefsh
piratefsh / tictactoe.py
Created September 14, 2015 15:59
Simple command-line tic-tac-toe game in Python. Kinda TDD-ed.
import re
EMPTY = '-'
PLAYER_X = 'X'
PLAYER_O = 'O'
def init_board(n):
board = {}
for x in range(n):
char_map = ['#', '=', '-', '.']
def flood(grid, node, target, depth):
x, y = node
color = char_map[depth] if depth < len(char_map) else None
if target == color:
return
from flask import Flask, request, redirect, url_for, jsonify
import requests
import urllib.parse
import os
app = Flask(__name__)
app.config.from_envvar('RC_OAUTH_CLIENT_SECRETS')
app.config['RC_OAUTH_AUTH_URI'] = 'http://recurse.com/oauth/authorize'
app.config['RC_OAUTH_TOKEN_URI'] = 'http://recurse.com/oauth/token'
command prompt:
cmd+p
package command prompt:
cmd+shift+p
select lines:
shift+ up/down
moving lines:
function onGLC(glc) {
glc.loop();
// glc.size(400, 400);
// glc.setDuration(5);
// glc.setFPS(20);
// glc.setMode('single');
// glc.setEasing(false);
var list = glc.renderList,
width = glc.w,
height = glc.h,
function onGLC(glc) {
glc.loop();
// glc.size(400, 400);
glc.setDuration(4);
// glc.setFPS(20);
glc.setMode('single');
glc.setEasing(false);
var list = glc.renderList,
width = glc.w,
height = glc.h,
function onGLC(glc) {
glc.loop();
// glc.size(400, 400);
glc.setDuration(3);
// glc.setFPS(20);
glc.setMode('single');
glc.setEasing(false);
var list = glc.renderList,
width = glc.w,
height = glc.h,