Skip to content

Instantly share code, notes, and snippets.

# install build dependencies
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
# clone and install rbenv environment
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
require 'omniauth-oauth2'
module OmniAuth
module Strategies
class Weibo < OmniAuth::Strategies::OAuth2
option :name, 'weibo'
option :client_options, {
:site => "https://api.weibo.com",
# encoding: utf-8
require "omniauth-oauth2"
module OmniAuth
module Strategies
class Wechat < OmniAuth::Strategies::OAuth2
option :name, "wechat"
option :client_options, {
require "omniauth-oauth2"
module OmniAuth
module Strategies
class Tqq < OmniAuth::Strategies::OAuth2
option :name, 'tqq'
option :client_options, {
:site => "https://graph.qq.com",
module Imon
module DynamicQuery
# def find_by_expression(all_or_first, exp, options={})
# conditions=expression.params
# conditions.insert(0, exp.expression)
# options.merge :conditions=>conditions
# find(all_or_first, options)
# end
@deppyu
deppyu / count.rb
Created February 24, 2014 07:17
计算一个数字的出现1的次数
def counter(n)
return 0 if n<=0
(n%10) == 1 ? 1+counter(n/10) : counter(n/10)
end