Skip to content

Instantly share code, notes, and snippets.

View umhan35's full-sized avatar

Zhao Han umhan35

View GitHub Profile
@umhan35
umhan35 / Gemfile
Last active July 4, 2024 17:24
lightweight Ruby on Rails
source 'https://rubygems.org'
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack"
gem "railties"
gem "tzinfo"
# Let's use thin
@umhan35
umhan35 / gall
Created March 30, 2013 04:13
grep '{first arg}' . -R
#!/usr/bin/ruby
if ARGV.length != 1
print "[Exit] need 1 argument (now #{ARGV.length})\n"
exit
end
pattern = ARGV[0]
cmd = "grep '#{pattern}' . -R"
@umhan35
umhan35 / whichp
Created January 5, 2014 03:19
which package is this file
#!/bin/sh
if [ $# -ne 1 ]; then
echo "usage: $(basename $0) command"
exit 1
fi
set -e
@umhan35
umhan35 / gist:8279173
Last active January 2, 2016 08:49
capistrano 3: run rails rake task on server
desc "DESC"
task TASK: ['deploy:set_rails_env'] do
on roles :app do
within release_path do
# within current_path do
with rails_env: fetch(:rails_env) do
execute "rake", "another:task"
end
end
end
@umhan35
umhan35 / gist:8628318
Created January 26, 2014 04:11
treat bitbucket like github in `Gemfile`

Copy & paste the following to your Gemfile

def bitbucket repo; {git: 'ssh://[email protected]/'+repo} ;end

Usage

gem 'xxx', github('user/repo')

@umhan35
umhan35 / content.md
Created March 13, 2014 04:57
Speed up Rails deployment when using bundler

Run bundle cache

# bundler specific
set :bundle_flags, '--deployment' # from --deployment --quiet
Loading Rails is too slow, services are here to rescue.
#include <Servo.h>
#define SHIFT 7
#define R 0 // Red LED
#define G 1 // Green LED
#define B 2 // Blue LED
#define TIME 15 // Column of Time
#define MAXSN 12 // Max Number of Servos
#define MAXMN 10 // Max Number of Motions
#define MAXFN 8 // Max Number of Frames
@umhan35
umhan35 / openssl
Created April 25, 2014 19:46
openssl
sudo apt-get update && sudo apt-get upgrade openssl
openssl version -b
1:27