Skip to content

Instantly share code, notes, and snippets.

@siygle
siygle / google-cloud-storage.js
Created September 22, 2013 18:31
[Sample] Upload image to google cloud storage
var GAPI = require('node-gcs').gapitoken;
var GCS = require('node-gcs');
var fs = require('fs');
var path = require('path');
var format = require('util').format;
var config = require('../res/config.js').GCS;
const STATIC_URL = "https://storage.googleapis.com";
const BUCKET = config.BUCKET_NAME;
const FILENAME = "rock-cloud.png";
@siygle
siygle / new_gist_file
Last active December 19, 2015 00:09
Example of setup nodejs env on docker
# install dependency first
# http://www.docker.io/gettingstarted/
sudo apt-get install linux-image-extra-`uname -r`
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:dotcloud/lxc-docker
sudo apt-get update
sudo apt-get install lxc-docker
# Build your nodejs application
@siygle
siygle / dump
Created June 21, 2013 08:12
Dump npm global packages list
# Might have better command, but should work at least. ;p
npm list -g --depth=0 | awk '{print $2}' | awk -F '@' '{print $1}' | tr "\\n" " "
@siygle
siygle / index.html
Last active December 17, 2015 00:19
Typeahead Example
<!doctype html>
<html>
<head>
<title>AutoComplete Example</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form>
<!-- Don't forget disable chrome autocomplete -->
<input type="text" id="moz-test" autocomplete="off">
@siygle
siygle / duplex.js
Created March 14, 2013 16:36
example of stream2 new class
var Duplex = require('stream').Duplex;
var util = require('util');
function both() {
if (!(this instanceof both)) return new both();
Duplex.call(this);
}
util.inherits(both, Duplex);
@siygle
siygle / servant.js
Created March 11, 2013 09:15
Simple script to backup all my stuff
#!/usr/bin/env node
var fs = require('fs');
function help() {
var output = [
'servant - help you handle those tiny little things',
'',
'Usage:',
' servant config - Display servant config files',
@siygle
siygle / insert.go
Created February 13, 2013 19:10
sample of mgo
package main
import (
"fmt"
"labix.org/v2/mgo"
)
type Person struct {
Name string
Phone string
@siygle
siygle / defer-panic-recover.go
Last active December 12, 2015 07:28
go tech talk demo code
package main
import "fmt"
func main() {
f()
fmt.Println("Returned normally from f.")
}
@siygle
siygle / gist:4468676
Last active December 10, 2015 17:38 — forked from avimar/gist:3092732
Install nodejs with salt under ubuntu env
nodejs-deps:
pkg.installed:
- names:
- build-essential
- g++
- curl
- libssl-dev
- apache2-utils
- git
@siygle
siygle / grunt config
Created November 30, 2012 18:58
deploy to s3
grunt.registerMultiTask('deploy', 'deploy program to cloud', function() {
var pkgcloud = require('pkgcloud')
, walk = require('walk')
, fs = require('fs')
, done = this.async()
, self = this;
grunt.log.w