Skip to content

Instantly share code, notes, and snippets.

View xiangzhuyuan's full-sized avatar
🤗

Mathew P. Jones xiangzhuyuan

🤗
View GitHub Profile

#git subtree 的用法

假如有一个iOS的项目,我用到了很多外部的库,如AFNetworking,我怎么把它集成进来呢?

##通过submodule的方法

把这个项目追加到自己是项目中:

git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking

git-subtree(1)

NAME

git-subtree - Merge subtrees together and split repository into subtrees

SYNOPSIS

@xiangzhuyuan
xiangzhuyuan / rails_engine_abc.markdown
Created September 22, 2014 15:53
学习记载之 rails engine

#rails engine

此文讲述关于 engine, 他们如何被用来提供额外的功能给他们的宿主程序,如果一个比较干净和容易使用的接口. 读完此文会收获到:

  1. 什么构成了 engine
  2. 怎么生成一个 engine
  3. 给 engine 添加功能
  4. 把 engine 嵌入到一个程序里
  5. 在宿主程序里重写 engine 的功能
@xiangzhuyuan
xiangzhuyuan / rails_i18n.markdown
Last active August 29, 2015 14:06
rails i18n

#Rails 国际化

从 rails 2.2开始就支持了 ruby 国际化的 gem. 提供了一个任意使用扩展的框架,用来翻译你的程序一个完整的自定义语言.不仅仅是英语. 给你的程序提供多语言支持.

通常国际化的过程就是把所有的字符串抽象出来.然后放在特定的地方,而本地化的过程就是提供对应的翻译和本地的格式. 所以,在 rails 程序里国际化的过程就是:

  1. 确保支持 i18n
  2. rails 哪里找到对应的本地字典
  3. 告诉 rails 怎么设置和保护和切换地域.
#[codility]MinAvgTwoSlice
def solution(A):
# write your code in Python 2.6
# if one slice is the MA, then the average of its subslices
# can not be smaller and also it can not be bigger, or the average of the
# whole slice will change
# every slice can be divide into two kinds of subslices, e.g., two-element and three element
@xiangzhuyuan
xiangzhuyuan / python-interview.md
Last active November 19, 2018 10:02
a list questions from here: http://careerride.com/

What is Python? State some programming language features of Python.

Python is a modern powerful interpreted language with objects, modules, threads, exceptions, and automatic memory managements. Python was introduced to the world in the year 1991 by Guido van Rossum Salient features of Python are

  • Simple & Easy: Python is simple language & easy to learn.
  • Free/open source: it means everybody can use python without purchasing license.
  • High level language: when coding in Python one need not worry about low-level details.
  • Portable: Python codes are Machine & platform independent.
  • Extensible: Python program supports usage of C/ C++ codes.
@xiangzhuyuan
xiangzhuyuan / download-lofter-image.rb
Created December 19, 2014 09:45
网易 lofter 图片下载
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'fileutils'
print 'start....'
base_url = 'http://sakalee.lofter.com/?page='
@xiangzhuyuan
xiangzhuyuan / download-neteasy-lofter-image.rb
Created December 19, 2014 09:56
下载网易lofter 图片
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'fileutils'
print 'start....'
base_url = 'http://sakalee.lofter.com/?page='
@xiangzhuyuan
xiangzhuyuan / download_lofter_image.rb
Created December 19, 2014 14:12
一键下载网易 lofter 图片
#!/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
@xiangzhuyuan
xiangzhuyuan / init-redis.rb
Created January 12, 2015 14:30
redis demo1
require 'redis'
$redis = Redis.new({:host => "localhost", :port => "6379"})
#p $redis.ping
$redis.flushall
i = 0
10.downto 1 do
p i
i +=1