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
# Reincarnation for classes | |
class Class | |
def reincarnate | |
buried = Object.__send__(:remove_const, self.name) | |
Object.const_set(self.name, Class.new(buried)) | |
end | |
end | |
class Abc |
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
# mongo_template.rb | |
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842) | |
# | |
# To use: | |
# rails project_name -m http://gist.github.com/gists/219223.txt | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" |
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 'forwardable' | |
require 'rubygems' | |
require 'uri' | |
gem 'oauth', '~> 0.3.6' | |
require 'oauth' | |
gem 'hashie', '~> 0.1.3' | |
require 'hashie' |
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
#此DEMO的功能:查询手机类的淘客商品 | |
require 'digest/md5' | |
require 'net/http' | |
require 'open-uri' | |
require 'iconv' | |
#获得当前时间 | |
t = Time.new(); | |
#组装参数 |
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 'rubygems' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
:adapter => "mysql", | |
:host => "localhost", | |
:database => "myapp", | |
:username => "root", | |
:password => "root", | |
:encoding => "utf8") |
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
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame]; | |
campFireView.animationImages = [NSArray arrayWithObjects: | |
[UIImage imageNamed:@"campFire01.gif"], | |
[UIImage imageNamed:@"campFire02.gif"], | |
[UIImage imageNamed:@"campFire03.gif"], | |
[UIImage imageNamed:@"campFire04.gif"], | |
[UIImage imageNamed:@"campFire05.gif"], |
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
# usr/bin/ruby | |
# encoding: UTF-8 | |
require 'rubygems' | |
require 'open-uri' | |
require 'json' | |
#cmd = 'curl --basic --user username:password http://twitter.com/statuses/friends_timeline.json' | |
url = 'http://twitk.com/k/statuses/friends_timeline.json' | |
buffer = open(url, :http_basic_authentication => ["username", "password"]).read |
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
mysql> use wordpress; | |
Database changed | |
mysql> show tables; | |
+-----------------------+ | |
| Tables_in_wordpress | | |
+-----------------------+ | |
| wp_commentmeta | | |
| wp_comments | | |
| wp_links | | |
| wp_options | |
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 "net/http" | |
require "json" | |
USER = '[email protected]' | |
PASS = '123456' | |
API_URL = "http://api.renren.com/restserver.do" | |
def base_params | |
{ | |
"api_key" => "f2570a570d56439784bfb69dbda699d1", |
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
#import "PostViewController.h" | |
#import "WoyiAppDelegate.h" | |
#import "ImagePickerController.h" | |
@implementation PostViewController | |
#pragma mark - | |
#pragma mark Initialization |
OlderNewer