Skip to content

Instantly share code, notes, and snippets.

View shiawuen's full-sized avatar

Tan Shiaw Uen shiawuen

View GitHub Profile
@shiawuen
shiawuen / index.html
Created April 16, 2014 03:33
Scroll hash change
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.block {
border: 1px solid #666;
box-shadow: 2px 2px 2px #333;
background: #f1f1f1;
{
elType: [
{ type: 10, el: 'h1' },
{ type: 11, el: 'h2' },
{ type: 12, el: 'h3' },
{ type: 13, el: 'h4' },
{ type: 14, el: 'h5' },
{ type: 15, el: 'h6' },
{ type: 2, el: 'p' },
{ type: 3, el: 'a' },
class FileSystem {
constructor () {
this.tree = {}
this.binaries = {}
}
add ({ type, name, path = '/'}) {
if (! (type && name))
throw Error('missing required parameters')
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width"/>
<title>Modular Template Patterns</title>
<!--
This email is an experimental proof-of-concept based on the
idea that the most common design patterns seen in email can
@shiawuen
shiawuen / email-large.json
Last active September 16, 2015 05:33
test
This file has been truncated, but you can view the full file.
{
"tree": [
{
"id": "cid73x8k0003x3k5959csf4tn",
"type": "Row",
"size": 1,
"children": [
{
"id": "cid73x8k0003y3k59hgnr1vp1",
"type": "Column",
require 'open3'
command = "tail"
target = "x" * 65535
out = ""
Open3.popen3(command) do |stdin, stdout, _|
stdin.puts target
stdin.close
out = stdout.read
@shiawuen
shiawuen / depot.add.js
Created March 17, 2011 03:56
Problem with using Depot.add, callback never get trigger and the line after the add never get executed. Failed silently…
var db = new Mojo.Depot(
{ name: 'my_wordpress_db', version: 1, estimatedSize: 25000, replace: false },
function() { Mojo.Log.info('Success'); },
function(error) { Mojo.Log.warn('Unable to open database (#' +error+ ')' ); }
);
// NOT WORKING
db.add(
'address', 'address',
function(){ Mojo.Log.info('Address Added'); },
@shiawuen
shiawuen / path.js
Created September 1, 2011 17:46
prevent access /etc/passwd
var path = require('path')
var userPath = path.normalize('/var/www/app/abc/../../../../../../../../../../etc/passwd')
if (userPath.indexOf(__dirname) == 0 ) {
// Valid path
} else {
// Invalid path
}
@shiawuen
shiawuen / crunchbase-api-v1.md
Created November 22, 2011 14:52 — forked from dominicsayers/crunchbase-api-v1.md
CrunchBase API v1

NOTE: This documentation has been put here because I couldn't find it anywhere else. I am not associated with Crunchbase in any way. I cannot help you with your Crunchbase API problems. If you need help try here: https://groups.google.com/forum/#!forum/crunchbase-api

CrunchBase API v1 Documentation

Overview

The CrunchBase API provides JSON representations of the data found on CrunchBase. The API currently supports three actions: "show", "search", and "list", which are each described below.

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Combination – slooow way</title>
</head>
<body>
<script src="index.js"></script>
</body>