#git subtree 的用法
假如有一个iOS的项目,我用到了很多外部的库,如AFNetworking
,我怎么把它集成进来呢?
##通过submodule的方法
把这个项目追加到自己是项目中:
git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking
#git subtree 的用法
假如有一个iOS的项目,我用到了很多外部的库,如AFNetworking
,我怎么把它集成进来呢?
##通过submodule的方法
把这个项目追加到自己是项目中:
git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking
#rails engine
此文讲述关于 engine, 他们如何被用来提供额外的功能给他们的宿主程序,如果一个比较干净和容易使用的接口. 读完此文会收获到:
#Rails 国际化
从 rails 2.2开始就支持了 ruby 国际化的 gem. 提供了一个任意使用扩展的框架,用来翻译你的程序一个完整的自定义语言.不仅仅是英语. 给你的程序提供多语言支持.
通常国际化
的过程就是把所有的字符串抽象出来.然后放在特定的地方,而本地化
的过程就是提供对应的翻译和本地的格式.
所以,在 rails 程序里国际化的过程就是:
i18n
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
# quit unless our script gets two command line arguments | |
unless ARGV.length == 1 | |
puts "用法如下:" | |
puts "ruby download_lofter_image.rb '你想下载图片的地址,如:http://sakalee.lofter.com'\n" | |
exit |
require 'redis' | |
$redis = Redis.new({:host => "localhost", :port => "6379"}) | |
#p $redis.ping | |
$redis.flushall | |
i = 0 | |
10.downto 1 do | |
p i | |
i +=1 |
require 'date' | |
require 'redis' | |
$redis = Redis.new({:host => "localhost", :port => "6379"}) | |
#p $redis.ping | |
$redis.flushall | |
%w{my sg es de th tw gb gs id at}.each do |item| | |
i = 0 |
module RedisConnection | |
def connect_to_redis | |
retry_attempts = 0 | |
begin | |
yield | |
rescue => e | |
if retry_attempts < 1 | |
retry_attempts += 1 | |
$redis = Redis.new() | |
retry |
require 'redis' | |
class DirectRedisConnection | |
def initialize(host = 'http://localhost:3000', port = '6379', password = '') | |
super | |
@conn = Redis.new(host: host, port: port) | |
@conn.auth(password) unless password == '' | |
begin | |
self.ping | |
Rails.logger.info "successfully connect to #{@conn.inspect}" |