Skip to content

Instantly share code, notes, and snippets.

View alexpchin's full-sized avatar

Alex Chin alexpchin

View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@albrow
albrow / Rakefile
Last active December 10, 2015 05:08
An excerpt from the Rakefile I use to deploy my blog. http://blog.alexbrowne.info
# ...
desc "Deploy website to s3/cloudfront via aws-sdk"
task :s3_cloudfront => [:generate, :minify, :gzip, :compress_images] do
puts "=================================================="
puts " Deploying to Amazon S3 & CloudFront"
puts "=================================================="
# setup the aws_deploy_tools object
config = YAML::load( File.open("_config.yml"))
@lfborjas
lfborjas / session_counter.rb
Created October 20, 2010 02:00
A simple script to decode sinatra sessions and tamper them
require 'sinatra'
enable :sessions
#cf: http://rack.rubyforge.org/doc/Rack/Session/Cookie.html
class Visits
@@global = 0
def self.global; @@global; end
def self.add
@@global +=1
end
@Nimster
Nimster / ringbuffer.rb
Created November 15, 2012 11:21 — forked from eerohele/ringbuffer.rb
A simple ring buffer for Ruby.
class RingBuffer < Array
attr_reader :max_size
def initialize(max_size, enum = nil)
@max_size = max_size
enum.each { |e| self << e } if enum
end
def <<(el)
if self.size < @max_size || @max_size.nil?
@lucasallan
lucasallan / install_postgis_osx.sh
Created September 6, 2011 21:03 — forked from klebervirgilio/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@maruf89
maruf89 / Script.coffee
Last active January 12, 2017 23:48
Angular ng-flow + jcrop + Cloudinary upload
'use strict'
angular.module('uploadApp', [
'flow'
'ngJcrop'
]).config [
'flowFactoryProvider'
'ngJcropConfigProvider'
(flowFactoryProvider, ngJcropConfigProvider) ->
@cheeyeo
cheeyeo / temp.rb
Created April 6, 2014 20:47
Using ruby tempfile to fetch a remote resource for custom formatting
class LocalResource
attr_reader :uri
def initialize(uri)
@uri = uri
end
def file
@file ||= Tempfile.new(tmp_filename, tmp_folder, encoding: encoding).tap do |f|
io.rewind
@bensie
bensie / base.rb
Created December 6, 2012 17:53
Sinatra API Helpers
require "sinatra/base"
require "sinatra/namespace"
require "multi_json"
require "api/authentication"
require "api/error_handling"
require "api/pagination"
module Api
class Base < ::Sinatra::Base
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet
@maciekish
maciekish / resetXcode.sh
Created August 10, 2016 10:13
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app