Skip to content

Instantly share code, notes, and snippets.

@freizl
freizl / promise.js
Created October 12, 2011 05:02 — forked from jcoglan/promise-monad.js
Monad in JS
/*
jsclass
http://jsclass.jcoglan.com/
npm install jsclass
*/
require('jsclass');
JS.require('JS.Deferrable');
Promise = new JS.Class({
include: JS.Deferrable,
@freizl
freizl / html5-showcase.html
Created June 8, 2012 05:50
HTML 5 Elements Showcase
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- <script type="text/javascript" src="/home/haiswu/Downloads/jquery-1.7.1.js"></script> -->
<style>
form div label {
width: 100px;
}
@freizl
freizl / bad-monad
Created June 30, 2012 01:39
Bad or Incorrect Monad example?
module Main where
main = do let p = Position 0
print (treasureMap p == treasureMap2 p)
data Position t = Position t deriving (Show, Eq)
stagger (Position d) = Position (d + 2)
@freizl
freizl / nginx-subdomain-proxy-conf
Created July 3, 2012 09:01
nginx-subdomain-proxy-conf
## Sample config for setting nginx as a gateway to local services.
upstream demosnap {
server localhost:9898;
server localhost:8080;
}
server {
listen 80;
@freizl
freizl / Browser.md
Created July 10, 2012 01:36
Quick Notes

Browser

HTML Parser

  • The HTML grammar definition (HTML DTD)

  • DOM, The output tree - the "parse tree" is a tree of DOM element and attribute nodes. Document Object Model

  • The parsing algorithm

    • consists of two stages - tokenization and tree construction.
  • state machine
@freizl
freizl / hello-state-monad.hs
Created November 16, 2012 12:35
Hello State Monad
module Main where
import Control.Monad.Trans.State.Lazy
-- | The state
type S = String
sayHello :: S -> S
sayHello = (++ "Hello, ")
@freizl
freizl / bb-extend-bad.js
Last active December 19, 2015 11:09
Two practices to extend Backbone model
var Parent = Backbone.Model.extend({
age : 3,
ref: []
});
var Child1 = Parent.extend(),
Child2 = Parent.extend();
var c1 = new Child1(),
c2 = new Child2();
@freizl
freizl / PPTPD-VPN-in-CentOS6.md
Last active April 10, 2019 10:48
PPTPD VPN in CentOS 6

Install packages

yum install ppp iptables
rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
yum install pptpd

Route config

<!-- This is a Node+WebSocket powered demo to sync videos
across different browsers. This file is the client,
the other one is the Node server. Powered by Node and
http://github.com/miksago/node-websocket-server -->
<style>
.inactive { display: none; }
.active { display: block; }
</style>
<script>