Skip to content

Instantly share code, notes, and snippets.

@npatmaja
npatmaja / new_gist_file.md
Last active August 29, 2015 14:06
Change tab size in Sublime Text2

There are two ways to change the default tab size in Sublime Text2:

  1. Go to Preferences -> Setting - Default and change the value of tab_size to whatever you want. In my case it was 2.

  2. Go to Preferences -> Setting - User and add lines below:

{
	"tab_size": 2,
	"translate_tabs_to_spaces": true
@npatmaja
npatmaja / work_around.md
Created August 25, 2014 21:17
Work around of Errno::EPIPE: Broken pipe while inserting a file through google drive ruby api client

Error found while inserting a file to Google Drive ruby API client:

Errno::EPIPE: Broken pipe
from /Users/nauval/.rbenv/versions/2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:326:in `syswrite'

Work around: Tell the API client to use HTTPClient as Faraday's default adapter after the require google api

@npatmaja
npatmaja / ruby-hash.md
Created August 20, 2014 17:47
Ruby Hash

Several ways to define a hash in ruby:

hash = { 
  :key1 => "value1",
  :key2 => "value2"
}

or with syntactic sugar:

@npatmaja
npatmaja / nil-empty-blank.md
Created August 20, 2014 00:27
nil? empty? blank?

.nil?

  • It is Ruby method
  • It can be used on any object and is true if the object is nil.
  • "Only the object nil responds true to nil?" - RailsAPI
nil.nil? = true
anthing_else.nil? = false
a = nil
@npatmaja
npatmaja / 0_reuse_code.js
Created August 20, 2014 00:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@npatmaja
npatmaja / comment-mult-lines-vim.md
Created June 13, 2014 08:06
Comment multiple lines at a time in Vim
  1. hit ctrl+v (visual block mode)
  2. use the down arrow keys to select the lines you want (it won't highlight everything)
  3. Shift+i (capital I)
  4. insert the text you want, i.e. '% '
  5. Press ESC

[taken from stackoverflow] (http://stackoverflow.com/a/15588798)