Skip to content

Instantly share code, notes, and snippets.

View hlxwell's full-sized avatar
⛷️
Focusing

Michael He hlxwell

⛷️
Focusing
View GitHub Profile
@vasanthk
vasanthk / System Design.md
Last active May 23, 2024 18:22
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

#!/bin/bash
# Interactive PoPToP install script on a OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# 2011 v1.1
# Author: Commander Waffles
# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/
echo "######################################################"
echo "Interactive PoPToP Install Script for OpenVZ VPS"
echo "by Commander Waffles http://www.putdispenserhere.com"
@tanraya
tanraya / gist:7438337
Created November 12, 2013 20:44
Carrierwave auto orient image explained
module CarrierWave
module MiniMagick
# Rotates the image based on the EXIF Orientation
# According to http://jpegclub.org/exif_orientation.html
def auto_orient
manipulate! do |image|
case image['EXIF:Orientation'].to_i
when 2
image.flop
when 3
@afeld
afeld / gist:5704079
Last active November 27, 2023 15:43
Using Rails+Bower on Heroku
@ivanvanderbyl
ivanvanderbyl / gist:4222308
Created December 6, 2012 06:55
Postgres 9.1 to 9.2 upgrade guide for Ubuntu 12.04
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
@shmatov
shmatov / deploy.rake
Created November 15, 2012 13:17
rails + mina + unicorn
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
@stefanobernardi
stefanobernardi / application_controller.rb
Created September 23, 2012 07:07
Multiple omniauth providers and omniauth-identity on the main user model
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
def signed_in?
@hlxwell
hlxwell / mysql-to-mongo
Last active October 4, 2015 14:27 — forked from shenzhaoyan/gist:824583
MySQL to MongoDB
MySQL: SELECT * FROM user WHERE name = "foobar"Mongo: db.user.find({"name" : "foobar"})
MySQL: INSERT INOT user (`name`, `age`) values ("foobar",25)
Mongo: db.user.insert({"name" : "foobar", "age" : 25})
MySQL: DELETE * FROM user
Mongo: db.user.remove({})
MySQL: DELETE FROM user WHERE age < 30
Mongo: db.user.remove({"age" : {$lt : 30}}) $gt : > ; $gte : >= ; $lt : < ; $lte : <= ; $ne : !=
MySQL: UPDATE user SET `age` = 36 WHERE `name` = "foobar"
Mongo: db.user.update({"name" : "foobar"}, {$set : {"age" : 36}})
MySQL: UPDATE user SET `age` = `age` + 3 WHERE `name` = "foobar"
@shapeshed
shapeshed / nginx_rails_3_1
Created October 10, 2011 19:13
Nginx Config for Rails 3.1 with Unicorn and Asset Pipeline
upstream app {
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.app.com;
rewrite ^/(.*) http://app.com/$1 permanent;
}
server {