This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ========================= | |
# For Bundler | |
# Cap will run "bundle --deploy" on the production server | |
# every time when you deploy | |
# ========================== | |
require 'bundler/capistrano' | |
set :application, "wechat_bot" | |
# ========================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 6 | |
app_root = File.expand_path("../..", __FILE__) | |
working_directory app_root | |
# Listen on fs socket for better performance | |
listen "/tmp/unicorn.sock", :backlog => 64 | |
listen 4096, :tcp_nopush => false | |
# Nuke workers after 30 seconds instead of 60 seconds (the default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://maps.google.com/maps/api/geocode/json?latlng=39.910093,116.403945&language=zh-CN&sensor=false | |
{ | |
"results" : [ | |
{ | |
"address_components" : [ | |
{ | |
"long_name" : "128号", | |
"short_name" : "128号", | |
"types" : [ "street_number" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger | |
def self.add_logging | |
def log(msg) | |
STDERR.puts Time.now.strftime("%H:%M:%S: ") + "#{self} (#{msg})" | |
end | |
end | |
end | |
class Example < Logger | |
add_logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"env":{ | |
"PATH":"${HOME}/.rvm/bin:${PATH}" | |
}, | |
"cmd": ["rvm-auto-ruby", "$file"], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.ruby" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AttrLogger | |
def log(msg) | |
puts msg | |
end | |
module ClassMethods | |
def attr_logger(name) | |
attr_reader name | |
define_method("#{name}=") do |val| | |
puts "Assigning #{val.inspect} to #{name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Authentication | |
# Add helper method as soon as module included | |
def self.included(controller) | |
controller.send :helper_method, :current_user, :logged_in?, :redirect_to_target_or_default | |
end | |
def current_user | |
@current_user ||= User.find(session[:user_id]) if session[:user_id] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | |
NSInteger result = 0; | |
if ([tableView isEqual:self.myTableView]) { | |
result = 3; | |
} | |
return result; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { | |
UIView *result = nil; | |
if ([tableView isEqual:self.myTableView] && section == 0) { | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; | |
label.text = @"Section 1 Header"; | |
label.backgroundColor = [UIColor clearColor]; | |
[label sizeToFit]; | |
OlderNewer