Skip to content

Instantly share code, notes, and snippets.

View hengkiardo's full-sized avatar

Hengki Sihombing hengkiardo

  • Jakarta, Indonesia
View GitHub Profile
@hengkiardo
hengkiardo / gist:9129379
Created February 21, 2014 05:38
How to prefetch video/audio files for uninterrupted playback in HTML5 video/audio
function e(id) {
return document.getElementById(id);
}
function loaded(blob_uri) {
// Clear progress indicator.
var container = e("container");
container.innerHTML = "";
var v = document.createElement("video");
v.src = blob_uri;
server {
listen 80;
server_name www.example.com;
root /var/www/vhosts/example.com/public/;
location /
{
index index.php index.html index.htm;
}
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install homebrew-dupes (required to install zlib, php54's dependency)
brew tap homebrew/dupes
# install nginx + mysql + php 5.4 + php-fpm + apc + xdebug
brew install nginx mysql

Contributing

If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.

How to make a clean pull request

Look for a project's contribution instructions. If there are any, follow them.

  • Create a personal fork of the project on Github.
  • Clone the fork on your local machine. Your remote repo on Github is called origin.
#!/bin/bash
#---------------------------------------
# Node.JS Raspberry Pi Package builder
# Raspbian
# http://nodejs-news.com
#---------------------------------------
echo "-> Getting fpm (Effing package managers) Ruby gem"
sudo gem install fpm --no-ri --no-rdoc
@hengkiardo
hengkiardo / gist:7465436
Created November 14, 2013 11:42
Remove a directory that is not empty in NodeJS
var deleteFolderRecursive = function(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.statSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
/** *********************************************************
* API - Model - User
********************************************************* */
module.exports = function (sequelize, DataTypes) {
return sequelize.define('User', {
username: DataTypes.STRING,
password: DataTypes.STRING,
firstName: DataTypes.STRING,
lastName: DataTypes.STRING,
'use strict';
// pick a random port between 1025 and 65535
// check using netstat to see if port is used
var exec = require('child_process').exec;
var port;
var _port;
var interval;