Skip to content

Instantly share code, notes, and snippets.

View sntran's full-sized avatar

Sơn Trần-Nguyễn sntran

View GitHub Profile
@sntran
sntran / physics.js
Last active August 29, 2015 14:07
Physics System with makr.js and p2.js
function Physics(bodyConfs, shapeConfs) {
this.body = bodyConfs;
this.shape = shapeConfs;
}
function PhysicsSystem(gravity) {
makr.IteratingSystem.call(this);
this.registerComponent(ComponentRegister.get(Position));
this.registerComponent(ComponentRegister.get(Rotation));
this.registerComponent(ComponentRegister.get(Physics));
defmodule XmlNode do
require Record
Record.defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl")
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")
def from_string(xml_string, options \\ [quiet: true]) do
{doc, []} =
xml_string
|> :binary.bin_to_list
|> :xmerl_scan.string(options)
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline;}html{line-height:1;}ol,ul{list-style:none;}table{border-collapse:collapse;border-spacing:0;}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle;}q,blockquote{quotes:none;}q:before,q:after,blockquote:before,blockquote:after{content:"";content:none;}a img{border:none;}#header_features{position:relative;z-index:1;}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{display:block;}* html{font-size:93.75%;}html{font-size:15px;line-height:1.73333em;}html *{-webkit-box-sizing:borde
@sntran
sntran / fisherYates.coffee
Created January 31, 2012 02:09
CoffeeScript Implementation of the Fisher-Yates array sorting algorithm
# Refactored from git://gist.github.com/859699.git by ddgromit for swapping
fisherYates = (arr) ->
i = arr.length
if i is 0 then return false
while --i
j = Math.floor(Math.random() * (i+1))
[arr[i], arr[j]] = [arr[j], arr[i]] # use pattern matching to swap
@sntran
sntran / echo_client_example.py
Created April 10, 2012 04:18
Sample XMPP client on Sublime Text
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
SleekXMPP: The Sleek XMPP Library
Copyright (C) 2010 Nathanael C. Fritz
This file is part of SleekXMPP.
See the file LICENSE for copying permission.
"""
@sntran
sntran / Makefile
Last active December 12, 2015 09:38
Makefile for Erlang projects based on Rebar
REBAR=$(shell which rebar || echo ./rebar)
REBAR_URL=https://github.com/rebar/rebar/wiki/rebar
.PHONY: all test deps clean
all: $(REBAR) deps compile start
start:
./start.sh
app: $(REBAR)
/* Transparent Tabs */
.tabs {
list-style: none;
padding: 0;
overflow: hidden;
}
.tab {
display: block;
float: left;
@sntran
sntran / Conway's Game of Life in Erlang.md
Last active December 15, 2015 01:29 — forked from jszmajda/Readme.md
Conway's Game of Life in Erlang Conway's Game of Life in Erlang, in 2 hours, with 0 Erlang experience, in 22 lines of code.

sadsadasd

sadasd

<%= files["Flick.png"] %>

  • @sntran
  • @sdfippinger
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@sntran
sntran / arrows.css
Last active December 17, 2015 19:48 — forked from danott/entities.css
Separated to reusable CSS classes, with support for IE.
/* Daniel Ott
* entities.css
* 31 January 2011
*
* Updated: 28 May 2013
* Son Tran
*
* Adding arrows to thinks makes them more clickable. Right?
* Use CSS's :after pseudo-selector to insert hexadecimal values
* of html entities into the document. Less markup. More awesome.