Skip to content

Instantly share code, notes, and snippets.

View inscapist's full-sized avatar

Felx inscapist

  • Penang, Malaysia
View GitHub Profile
@inscapist
inscapist / template_controller.rb
Created April 28, 2013 07:46
template service
def design
@template = Template.find_or_create_by_name(params[:name])
end
def design_image
@template = Template.find_by_name(params[:name])
render layout: false
end
def save_design
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"

Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:
@inscapist
inscapist / .bash_profile
Last active December 21, 2015 02:29
a ruby script to simplify git tasks
export PATH=${PATH}:/Users/felixtioh/Development/adt-bundle/sdk/platform-tools:/Users/felixtioh/Development/adt-bundle/sdk/tools
export PATH=${PATH}:/Users/felixtioh/bin
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
/*
This is an extension of the famo.us Surface type. It behaves the exact same except that the content
property holds a ProxyConstructor object (the type that gets returned by any of the React component
functions such as those in React.DOM or created by React.createClass) instead of a string or Node.
One thing to note is that the component fed in to content will get an extra prop, _surface, which
is the surface object that holds it
example usage
var TestComponent = React.createClass({
@inscapist
inscapist / EasyScrollView
Last active August 29, 2015 14:05
Famous EasyScrollView (pagination, supports X/Y direction, and ScrollBar!)
Famous.EasyScrollview = class EasyScrollview extends Famous.CView
@DEFAULT_OPTIONS:
containerSize: [300,300]
itemSize: [300,300]
direction: 0
paginate: true
scrollBarThickness: 26
@DIRECTION_X: 0
@DIRECTION_Y: 1
@inscapist
inscapist / readme.md
Created October 7, 2015 21:47
extract pdfs from nested folders

Say i want to extract my ebooks(PDF) from nested folders to a flattened format

  1. mkdir ~/mybooks
  2. cd ~/nested-books-folder
  3. run the command below
find . -iname '*.pdf' -exec cp {} '../mybooks/.' \;
@inscapist
inscapist / ovpn-writer.sh
Created October 25, 2015 15:42 — forked from renatolfc/ovpn-writer.sh
Script to generate an OpenVPN client configuration file in the unified format
#!/bin/sh
##
## Usage: ./ovpn-writer.sh SERVER CA_CERT CLIENT_CERT CLIENT_KEY SHARED_SECRET > client.ovpn
##
server=${1?"The server address is required"}
cacert=${2?"The path to the ca certificate file is required"}
client_cert=${3?"The path to the client certificate file is required"}
client_key=${4?"The path to the client private key file is required"}