Skip to content

Instantly share code, notes, and snippets.

View roymax's full-sized avatar

Roy roymax

View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@roymax
roymax / data.yaml
Created August 18, 2013 12:09
持有基金查询,需要到http://juhe.cn 申请一个API KEY
funds:
-
code: "375010"
capital: 10000
units: 3353
-
code: "270002"
capital: 5000
units: 2544.47
# and more
class Player
@health = nil
def play_turn(warrior)
# cool code goes here
@health = warrior.health unless @health
if warrior.feel.empty?
if @health < 12
warrior.rest!
else
warrior.walk!
@roymax
roymax / ThriftClient
Created July 21, 2013 13:34
grizzly-thrift
public void testGrizzly(String ip, int port) throws IOException, InterruptedException, ExecutionException, TimeoutException, TException {
// init client
final FilterChainBuilder clientFilterChainBuilder = FilterChainBuilder.stateless();
clientFilterChainBuilder.add(new TransportFilter());
// clientFilterChainBuilder.add(new ThriftFrameFilter());
clientFilterChainBuilder.add(new ThriftClientFilter());
final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
final ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
@roymax
roymax / gist:5244410
Last active December 15, 2015 10:19
redmine svn together
PerlLoadModule Apache::Redmine
<Location /svn>
DAV svn
# SVNPath /srv/svn/repo
SVNParentPath /srv/svn
AuthName "Subversion repository"
@roymax
roymax / ip-up
Created April 9, 2012 09:32
vpn-router-ip-up
#!/bin/sh
# VPN_GATEWAY is the remote address of the vpn tunnel
# when ppp executes this script it will pass several values to it
# $5 will hold the remote gateway
VPN_GATEWAY=192.168.20.239
if [ "${5:-}" = "${VPN_GATEWAY}" ]
then
/sbin/route add 192.168.30.0/24 $5
fi
@roymax
roymax / gist:1297677
Created October 19, 2011 07:33
git+dropbox
~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git
~/Dropbox/git $ mkdir project.git
~/Dropbox/git $ cd project.git
~/Dropbox/git $ git init --bare
~/Dropbox/git $ cd ~/project
@roymax
roymax / notifications_all.rb
Created September 27, 2011 05:35 — forked from loss-zz/notifications_all.rb
notifications_all.rb
#-----数据库schema
#attachable 为虚拟属性,为兼容以后的私信notif之类的
create_table :notifications do |t|
t.belongs_to :user
t.references :attachable, :polymorphic => true
t.text :content
t.timestamps
end
add_index :notifications, :user_id
add_index :notifications, [:attachable_id, :attachable_type]
@roymax
roymax / gitbox.sh
Created September 12, 2011 14:55
private repos, git+dropbox
~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git
~/Dropbox/git $ mkdir project.git
~/Dropbox/git $ cd project.git
~/Dropbox/git $ git init --bare
~/Dropbox/git $ cd ~/project