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;
@aishfenton
aishfenton / serializer_benchmarks.rb
Created July 18, 2010 02:32 — forked from visfleet/performance_of_yaml_vs_marshal.rb
Performance comparison of different ruby serializer methods
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@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|
@pksunkara
pksunkara / config
Last active April 28, 2024 18:59
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
require 'eventmachine'
require 'socket'
require 'kgio'
server = Kgio::TCPServer.new('0.0.0.0', 4242)
module Dispatch
def notify_readable
io = @io.kgio_tryaccept or return
EventMachine.attach(io, Server)
@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
@chriseppstein
chriseppstein / readme.md
Created August 31, 2011 21:57 — forked from mislav/Gemfile
How to integrate Compass with Rails 3.1 asset pipeline

This gist is no longer valid. Please see Compass-Rails for instructions on how to install.

@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"