Skip to content

Instantly share code, notes, and snippets.

View xiaods's full-sized avatar
🌏
Coding for Fun

Deshi Xiao xiaods

🌏
Coding for Fun
View GitHub Profile
@Pallinder
Pallinder / .bash_profile
Created September 3, 2013 17:29
Getting golang + mac os x + gdb to play nicely
alias gdbnew='/usr/local/Cellar/gdb/7.6/bin/gdb'
@Rich-Harris
Rich-Harris / gh-pages.md
Created August 11, 2013 23:02
Automating gh-pages branch updating with changes to the master branch
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.github.com/jreyes/5993810/raw/496a4991a528af1d56e9e984d5034cc8199f37fd/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@tkdchen
tkdchen / RPM spec template for packaging Python package
Created May 19, 2013 09:32
Make changes according to your requirements. I use $var to indicate what you have to replace with real value. The template follows the RPM package naming convention in Fedora community. That is all Python package's name should have prefix ``python-`` .
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%global pkg_name $name
Name: python-%{pkg_name}
Version: $version
Release: 1%{?dist}
Summary: $summary
Group: Development/Languages
License: $license
@chendo
chendo / gist:5361523
Created April 11, 2013 07:49
Slap this in ~/.ssh/config to route github.com access over SSH via another server to get around routing issues.
Host github.com
ProxyCommand ssh -qxT <ssh server you have access to> nc %h %p
@fxn
fxn / gist:5344725
Last active December 15, 2015 23:59
ActiveRecord::ConnectionAdapters::PostgreSQLColumn.class_eval do
prepend Module.new {
def mpq?
type == :mpq
end
def simplified_type(field_type)
field_type == 'mpq' ? :mpq : super
end
@subelsky
subelsky / asset.rake
Created March 3, 2013 21:48
Quick rake task to check if assets need to pre-compiled before deployment (since I don't like precompiling during deployment)
namespace :assets do
task :check do
root_dir = File.join(File.dirname(__FILE__),"..","..")
assets_last_modified_at = Dir["#{root_dir}/app/assets/**/**"].map { |p| File.mtime(p) }.sort.last
assets_last_compiled_at = Dir["#{root_dir}/public/assets/**/**"].map { |p| File.mtime(p) }.sort.last
if assets_last_modified_at > assets_last_compiled_at
fail "Assets need to precompiled; last asset modified at #{assets_last_modified_at}"
end
end
@headius
headius / gist:4343186
Created December 20, 2012 05:42
Running a startup flag-timing tool for JRuby users, to find the best flags on their system.
system ~/projects/jruby/blah $ jruby ../../startup_bench/lib/tune.rb 1 'touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local'
Beginning tuning for `touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local`
Trying 90 combinations of flags
--------------------------------------------------------------------------------
Last: -J-server
Average time: 8.529s
Overall average: 8.529s
Estimated completion time: 2012-12-19 23:46:27 -0600
--------------------------------------------------------------------------------
Last: -J-client
@doitian
doitian / edit.html.erb
Created December 16, 2012 13:11 — forked from masqita/type_caster.rb
Add a active model wrapper to edit settings in form. `type_caster.rb` can be put in lib directory, which convert the field to specific type. The wrapper idea also can be used to wrap any other object, such as [Railscasts #396](https://github.com/railscasts/396-importing-csv-and-excel/blob/master/store-with-validations/app/models/product_import.rb)
<h1>Settings</h1>
<%= simple_form_for @settings, :as => 'settings', :url => admin_settings_path, :html => { :class => 'form form-horizontal' } do |f| %>
<fieldset>
<legend>Points Earning</legend>
<%= f.input :site_name %>
<%= f.input :per_page %>
</fieldset>
<div class="control-group">
#!/usr/bin/ruby
LOGGING = true
LOGFILE = File.join(File.dirname(__FILE__), 'authorized_script_log')
# if we're logging, set up log file in advance
if LOGGING
begin
LOG = File.open(LOGFILE, 'a')
at_exit { LOG.close }