Skip to content

Instantly share code, notes, and snippets.

View michaelchum's full-sized avatar

Michael Ho Chum michaelchum

View GitHub Profile
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
// The BankAcct function will execute when it is new'ed,
// so this.name and this.balance will be set
function BankAcct(name) {
this.name = name;
this.balance = 100; // starting money
}
// These functions will be available on any new BankAcct() objects
BankAcct.prototype.changeName = function(newName) {
this.name = newName;
@michaelchum
michaelchum / odd_even.ml
Created January 25, 2016 07:05
Mutually recursive functions to find if an input int is odd or even
let rec
is_even = function
| 0 -> true
| n -> is_odd (n-1)
and
is_odd = function
| 0 -> false
| n -> is_even (n-1)
;;
@michaelchum
michaelchum / trie.py
Created January 26, 2016 03:38
Trie implementation in Python
import collections
class TrieNode:
# Initialize your data structure here.
def __init__(self):
self.children = collections.defaultdict(TrieNode)
self.is_word = False
class Trie:
def __init__(self):
self.root = TrieNode()
@michaelchum
michaelchum / undistort.py
Created September 26, 2016 00:23
Undistort
#Cam_calib_web.py
#Created by Chris Rillahan
#Last Updated: 02/02/2015
#Written with Python 2.7.2, OpenCV 3.0.0 and NumPy 1.8.0
#This program calculates the distortion parameters of a GoPro camera.
#A video must first be taken of a chessboard pattern moved to a variety of positions
#in the field of view with a GoPro.
import cv2, sys
#include <mpi.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#define G 0.75
#define N 512
#define TAG 0
#define ETA 0.0002
#include <iostream>
#include <sstream>
#include <string>
#include <ctime>
#include <cstdio>
#include <cstdlib>
// For UDPSocket and SocketException
#include "PracticalSocket.h"
#include "config.h"