Skip to content

Instantly share code, notes, and snippets.

@IskenHuang
IskenHuang / local.js
Created October 10, 2013 15:37
sails.js deploy to openshift setup
module.exports = {
host: process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1',
// port: process.env.PORT || 1337,
port: process.env.OPENSHIFT_NODEJS_PORT || 80,
// environment: process.env.NODE_ENV || 'development'
// environment: process.env.NODE_ENV || 'production'
environment: process.env.NODE_ENV || 'development'
@IskenHuang
IskenHuang / README.md
Last active December 26, 2015 20:39
grunt-contrib-connect middleware redirect function

GOAL

grunt-contrib-connect middleware redirect function. easy to use make fake api for front-end. This sample used yeoman generator gruntfile.

how to use

  • download redirect.js to project root.
  • edit Gruntfile.js
var redirect = require('./redirect');
@IskenHuang
IskenHuang / local.js
Created December 3, 2013 07:26
sails.js config/local.js default
/**
* Local environment settings
*
* While you're developing your app, this config file should include
* any settings specifically for your development computer (db passwords, etc.)
* When you're ready to deploy your app in production, you can use this file
* for configuration options on the server where it will be deployed.
*
*
* PLEASE NOTE:
# Load balancer configuration
upstream exampleApp {
# Directs to the process with least number of connections.
least_conn;
# One failed response will take a server out of circulation for 20 seconds.
server 127.0.0.1:10080 fail_timeout=20s;
#server 127.0.0.1:10081 fail_timeout=20s;
#server 127.0.0.1:10082 fail_timeout=20s;
#server 127.0.0.1:10083 fail_timeout=20s;
(function($){
var I18N = function(){};
I18N.prototype.lng = function lng() {
return $('html').attr('lang').toUpperCase() || 'EN-US';
};
I18N.prototype.t = I18N.prototype.translate = function translate(key) {
if(!key) {
return this;
@IskenHuang
IskenHuang / inject.bookmark.js
Created December 27, 2013 05:37
inject script to html
javascript:!function(d,script){script=d.createElement("script"),script.type="text/javascript",script.async=!0,script.onload=function(){return TogetherJS(this),!1},script.src="https://togetherjs.com/togetherjs-min.js",d.getElementsByTagName("head")[0].appendChild(script)}(document);
#!/bin/bash
sudo apt-get remove phantomjs
sudo unlink /usr/local/bin/phantomjs
sudo unlink /usr/local/share/phantomjs
sudo unlink /usr/bin/phantomjs
cd /usr/local/share
@IskenHuang
IskenHuang / post-receive.sh
Created February 10, 2014 06:30
git hooks deploy
#!/bin/sh
echo "Deploy beign"
# 設定 nodejs 環境(如果是用 nvm 管理 nodejs 才需要)
. "$HOME/.nvm/nvm.sh"
# 設定 project 路徑
export PROJECT_DIR=$HOME/PROJECT
@IskenHuang
IskenHuang / LoadingView.h
Created February 23, 2014 05:15
iOS Loading view. popup an loading view and covered all layout.
//
// LoadingView.h
//
//
// Created by Isken on 3/16/11.
// Copyright 2011 Isken. All rights reserved.
//
#import <UIKit/UIKit.h>
@IskenHuang
IskenHuang / cal.js
Last active August 29, 2015 13:56
translate salary
// http://40era.com/2641/
var calTW = function(salary, mo) {
var range = {
r1: {
off: 0,
tax: 3,
range: 1500
},
r2: {
off: 105,