Skip to content

Instantly share code, notes, and snippets.

View larryzhao's full-sized avatar
🐱
Meow

Larry Zhao larryzhao

🐱
Meow
View GitHub Profile
@hipertracker
hipertracker / gist:214210
Created October 20, 2009 12:05
NGinx -> TorqueBox
/etc/hosts:
127.0.0.1 myhost jboss_server
NGINX:
server {
listen myhost:80;
server_name myhost;
location / {
proxy_set_header X-Real-IP $remote_addr;
@ratbeard
ratbeard / config.rb
Created May 23, 2011 20:19
Basic Implementation of Local Storage Adapter for Backup gem
# assuming running script from home dir, with local.rb inside the backup folder, load it:
require 'Backup/local'
Backup::Model.new(:my_backup, 'My Backup') do
archive :vim do |archive|
archive.add '/Users/mike.frawley/.vim'
end
store_with ::Backup::Storage::Local do |local|
@etrepat
etrepat / class_instance_vars.rb
Created July 26, 2011 10:56
Why I don't use class variables in Ruby (or try not to)
class Person
@name = nil
# class-level reader
# cattr_accessor is rails-specific not ruby, and uses class vbles so ...
# may be done like this too:
#
# class << self
# attr_reader :name
# end
#!/bin/sh
### BEGIN INIT INFO
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop JBoss AS v7.0.0
### END INIT INFO
#
@djones
djones / gist:2642094
Created May 9, 2012 05:26
Grape API being served with Goliath
#!/usr/bin/env ruby
# gem install grape --pre
# http://localhost:9000/hello.json
# => {"hello":"world"}
$:<< '../lib' << 'lib'
require 'goliath'
@prognostikos
prognostikos / app.js
Created September 11, 2012 13:45
AngularJS & Rails
/**
* Angular needs to send the Rails CSRF token with each post request.
*
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %>
* is present in your layout.)
*/
angular.module('myapp',[]).
// configure our http requests to include the Rails CSRF token
config(["$httpProvider", function(p) {
var m = document.getElementsByTagName('meta');
@enplotz
enplotz / tm2-shortcuts-osx.textile
Created September 11, 2012 13:41
Textmate 2 Shortcuts (Mac OS X)

Navigation in the File Browser

⌘⇡ Go to Enclosing Folder
⌘⇣ Open
⌘⇠ Go Back
⌘⇢ Go Forward
Rename
QuickLook
⇧⌘N New Folder
⌥⌘N New Tab
class A
class << self
def add(ele)
@array ||= []
@array << ele
end
def array
@array ||= []
end
@maccman
maccman / canvas.physics.coffee
Created April 11, 2013 02:52
A canvas physics engine in 160 lines of CoffeeScript.
class Point
constructor: (@x = 0, @y = 0) ->
if isNaN(@x) or isNaN(@y)
throw new Error('Invalid coords')
add: (point) ->
@x += point.x
@y += point.y
subtract: (point) ->
@jtescher
jtescher / gist:1487555
Created December 16, 2011 19:31
Capistrano task: Optimize images with pngcrush and jpegoptim
namespace :image_compression do
desc 'Optimize images with pngcrush and jpegoptim'
task :process do
# Check for pngcrush
if (!`which pngcrush`.empty? rescue false) # rescue on environments without `which` (windows)
# Crush all .png files
run "find #{shared_path}/assets/ -type f -name '*.png' -print0 | xargs -0 pngcrush -q -e .crushed"