Skip to content

Instantly share code, notes, and snippets.

View inscapist's full-sized avatar

Felx inscapist

  • Penang, Malaysia
View GitHub Profile
/*
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 / 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.
;;
@inscapist
inscapist / compress-pdf-with-gs.md
Created January 19, 2016 10:19 — forked from guifromrio/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@inscapist
inscapist / gist:608d3c52a84cac6a254c
Created February 23, 2016 03:30
logrotate for production log
/home/ubuntu/lending_platform/log/production.log {
weekly
missingok
rotate 5
compress
delaycompress
notifempty
create 0644 ubuntu ubuntu
maxsize 2M
}