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
# encoding: utf-8 | |
require 'digest/md5' | |
require "faraday" | |
module Renren | |
class Client | |
def self.sign(params) | |
str = params.map {|k, v| "#{k}=#{v}"}.sort.join | |
str << secret |
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 -i -H "Authorization: Bearer {access_token}" -F source={api_key}-F text={text} https://api.douban.com/shuo/v2/statuses/ |
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
# encoding: utf-8 | |
# include Taobao::Parameters module, then call #params=() instance method to set more parameters ( method_name, etc.) and call | |
# #params_after_sign to get the full url query parameters after signing. | |
require 'digest/md5' | |
module Taobao | |
module Parameters | |
def self.included(base) |
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
convert favicon.png -colors 256 -resize 32x32 -transparent white favicon.ico |
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 ApplicationHelper | |
# render nav list for twitter bootstrap. | |
# define the nav list items. | |
def nav_list | |
[ | |
[:a, 'A', 'http://example.com/a'], | |
[:b, 'B', 'http://example.com/b'], | |
[:c, 'C', 'http://example.com/c'], | |
[:d, 'D', 'http://example.com/d'], |
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
require 'fileutils' | |
task :default => [:generate] | |
# put Slim templates under templates/ directory. run `rake generate` to generate html pages into public/ directory. | |
desc 'Generate html pages from Slim templates' | |
task :generate do | |
base_path = File.dirname(__FILE__) | |
templates_path = File.join(base_path, 'templates') |
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
window.Editor = | |
create : (text_area_id) -> | |
$("#" + text_area_id).hide() | |
editor_id = "editor_" + text_area_id | |
iframe_html = "<iframe id= " + editor_id + " style='width: 100%; height: 500px;'> | |
<!DOCTYPE html> | |
<html> | |
<head><meta charset='utf-8' /><title></title> | |
<body> | |
</body> |
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
# via: http://stackoverflow.com/questions/752717/how-do-i-use-define-method-to-create-class-methods | |
class Environment | |
def self.current | |
ENV['APP_ENV'] ||= 'development' | |
end | |
%w(development product test).each do |environment| | |
(class << self; self; end).instance_eval do | |
define_method "#{environment}?" do |
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 Model | |
module Publishable | |
PUBLISHING_STATUSES = %w(published approved deleted).freeze | |
extend ActiveSupport::Concern | |
included do | |
PUBLISHING_STATUSES.each do |status| | |
define_method "is_#{status}?" do | |
self.publishing_status == status | |
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
# Please add faraday, em-http-request, oj(optional) to Gemfile | |
CONFIG = { | |
qq: { | |
'appid' => 'your appid', | |
'appkey' => 'your appkey', | |
'host' => '119.147.19.43' # debug host. change it to openapi.tencentyun.com before release the app | |
} | |
}.freeze |
OlderNewer