Convenience function for performing a groupBy on a list then a sortBy on the resulting groups using Underscore methods.
sortedGroupBy(list, groupByIterator, sortByIterator)
| it "every redis commands should be realized in redis-namespace" do | |
| # Use methods.map{|m|m.to_sym} for backward compatible till ruby1.8 | |
| r_methods = (Redis.public_instance_methods(false) - MonitorMixin.public_instance_methods).map{|m|m.to_sym} - | |
| [:client, :synchronize, :with_reconnect, :without_reconnect, :connected?, :id, :method_missing, :inspect, :_bpop, :_eval, :_scan ] | |
| rns_methods = (Redis::Namespace::COMMANDS.keys + Redis::Namespace.public_instance_methods(false)).map{|m|m.to_sym} | |
| do_not_needs = [:slowlog, :sync, :time, :migrate, :subscribed?, :unwatch, :script] | |
| (r_methods - rns_methods - do_not_needs).should eq([]) | |
| end |
| #coding=gbk | |
| # | |
| #62进制,特别合于月、日、时、分、秒的压缩进储 | |
| # | |
| digit62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | |
| #整数转化为62进制字符串 | |
| #入口: | |
| # x : 整数 | |
| #返回: 字符串 | |
| def int_to_str62( x ): |
| #coding=gbk | |
| digit64 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/' | |
| def int_to_str64( x ): | |
| try: | |
| x=int(x) | |
| except: | |
| x=0 | |
| if x<0: | |
| x=-x | |
| if x==0: |
| $ chmod +x ./proxy_list_fetcher.rb | |
| $ ./proxy_list_fetcher.rb | head | |
| 180.94.88.58 8080 Afghanistan fast HTTPS High +KA | |
| 187.87.155.2 8080 Brazil fast HTTPS High +KA | |
| 120.132.132.119 8080 China medium HTTPS High +KA | |
| 210.211.109.244 8081 Viet Nam fast HTTP Low | |
| 216.244.71.143 3128 United States medium HTTPS High +KA | |
| 190.237.224.22 8080 Peru slow HTTPS High +KA |
Convenience function for performing a groupBy on a list then a sortBy on the resulting groups using Underscore methods.
sortedGroupBy(list, groupByIterator, sortByIterator)
| prog_stats memcached |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
contrived is a microgem that depends on another microgem array_range, however gemspecs don't support DVCS dependencies. So how do we solve this without prematurely denting the universe?
Just use bundler.
Add all microgems to your project's Gemfile:
| # | |
| # Initialize the stuff | |
| # | |
| # We build the status bar item menu | |
| def setupMenu | |
| menu = NSMenu.new | |
| menu.initWithTitle 'FooApp' | |
| mi = NSMenuItem.new | |
| mi.title = 'Hellow from MacRuby!' | |
| mi.action = 'sayHello:' |
| module Middleware | |
| class Logger | |
| def initialize(app, logger) | |
| @app = app | |
| @logger = logger | |
| end | |
| def call(env) | |
| headers = env.select {|k,v| k.start_with? 'HTTP_'} |