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 'open-uri' | |
require 'nokogiri' | |
doc = Nokogiri::XML(open('http://search.twitter.com/search.atom?q=&ands=test&lang=en&rpp=10')) | |
doc.xpath('//feed/entry').first.children.each do |t| puts t.attributes 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
--- a/vendor/plugins/paperclip/lib/paperclip.rb | |
+++ b/vendor/plugins/paperclip/lib/paperclip.rb | |
@@ -222,8 +222,8 @@ module Paperclip | |
after_save :save_attached_files | |
before_destroy :destroy_attached_files | |
- define_callbacks :before_post_process, :after_post_process | |
- define_callbacks :"before_#{name}_post_process", :"after_#{name}_post_process" | |
+ define_model_callbacks :post_process | |
+ define_model_callbacks :"#{name}_post_process" |
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 'grackle' | |
client = Grackle::Client.new(:auth=>{:type=>:basic,:username=>'lpgauth',:password=>'password'}) | |
while true do | |
begin | |
if client.users.show?({:screen_name=>'soundcloud'}).followers_count == 24999 | |
client.friendships.create!({:screen_name=>'soundcloud'}) | |
break |
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
cleanup() -> | |
[erase(K) || K <- [?SAVE_QS, | |
?SAVE_PATH, | |
?SAVE_RECV, | |
?SAVE_BODY, | |
?SAVE_BODY_LENGTH, | |
?SAVE_POST, | |
?SAVE_COOKIE, | |
?SAVE_FORCE_CLOSE]], | |
ok. |
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
cleanup() -> | |
[erase(K) || K <- [?SAVE_QS, | |
?SAVE_PATH, | |
?SAVE_RECV, | |
?SAVE_BODY, | |
?SAVE_BODY_LENGTH, | |
?SAVE_POST, | |
?SAVE_COOKIE, | |
?SAVE_FORCE_CLOSE]], | |
ok. |
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
A = 1, | |
B = undefined, | |
C = 3, | |
Struct = {struct, [ | |
{<<"A">>, A}, | |
{<<"B">>, B}, | |
{<<"C">>, c}]}, | |
JSON = mochijson2:encode(Struct). |
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
%%-------------------------------------------------------------------- | |
%%% Internal functions | |
%%-------------------------------------------------------------------- | |
find_best_connection(Tid, Max_pipe) -> | |
case ets:first(Tid) of | |
{Cur_sz, Pid} when Cur_sz < Max_pipe -> | |
ets:delete(Tid, {Cur_sz, Pid}), | |
ets:insert(Tid, {{Cur_sz + 1, Pid}, []}), | |
{ok, Pid}; | |
_ -> |
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
{[{{adx,generate_bid_request,2}, 4, 54.049, 0.069}, | |
{{adx,generate_response,3}, 2, 15.107, 0.037}, | |
{{adx,generate_bid_response_ads,2}, 1, 6.980, 0.028}, | |
{{piqi_tools,encode_rpc_request,2}, 1, 0.000, 0.020}, | |
{{piqi_tools,convert,6}, 1, 0.000, 0.042}, | |
{{ibrowse,send_req,6}, 1, 0.000, 0.017}, | |
{{adx_piqi,parse_bid_request,1}, 1, 0.000, 0.016}, | |
{{piqi_ext,gen_bid_request,2}, 2, 0.000, 0.020}], | |
{ {error_handler,undefined_function,3}, 13, 76.136, 0.249}, % | |
[{{error_handler,ensure_loaded,1}, 13, 35.550, 0.250}, |
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(test). | |
-export([json/0]). | |
json() -> | |
Id = <<"abc123">>, | |
Name = undefined, | |
User = [], | |
User2 = [{<<"id">>, Id} | User], | |
User3 = [{<<"name">>, Name} | User2], |
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
var wait = function(callbacks, done) { | |
var counter = callbacks.length; | |
var next = function() { | |
if(--counter == 0) { | |
done(); | |
} | |
}; | |
for(var i = 0; i < callbacks.length; i++) { | |
callbacks[i](next); | |
} |
OlderNewer