An introduction to curl using GitHub's API
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| # make this script run, update your gist with the running script, and it's | |
| # output in a separate gist. the entire quzi should take 1-3 minutes, but you | |
| # get 5. | |
| # | |
| # the meat - take < 5 minutes to do this | |
| # | |
| assert :hash do | |
| x = x.to_h |
| I = -> x { x } | |
| C = -> x { -> y { -> z { x[z][y] } } } | |
| T = -> C[I] | |
| K = -> x { -> y { x } } | |
| U = -> f { f[f] } | |
| # I know, this technically isn't the Y combinator, | |
| # and it isn't exactly the Z combinator either (like Y, but for applicative order languages). | |
| Y = -> g { U[-> f { -> x { g[U[f]][x] } } ] } | |
– ltrace -c ruby foo.rb # summary mode
| #!/bin/bash | |
| source mysql_access | |
| TODAY=$(date +"%Y-%m-%d_%H%M%S") | |
| CHECK_RETAINER=$( | |
| mysql api_test \ | |
| -u$MYSQL_USER \ | |
| -p$MYSQL_PASS \ | |
| -h$SOURCE_HOST \ | |
| --socket=$MYSQL_SOCK \ |
From https://github.com/GhostGroup/infrastructure/pull/180
Use socat to eavesdrop on the Nginx -> Unicorn socket-based comms.
ubuntu@ip-10-0-191-247:/etc/nginx/sites-enabled$ SOCK=/var/www/shared/.unicorn.sock [49/144]
Why do we need indifferent_hash while saving?
"/home/shim/Documents/foreman/dynflow/lib/dynflow/utils.rb:60:in `indifferent_hash'",
"/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:268:in `extract_metadata'",
"/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:226:in `prepare_record'",
"/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:236:in `save'",
"/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:125:in `save_action'",
This is Japanese-English translation of my diary articles
These articles demonstration how to find out memory issues and tuning.
| require 'fiber' | |
| require 'concurrent' # gem install concurrent-ruby | |
| Thread.abort_on_exception = true | |
| class Async | |
| def self.perform(&block) | |
| instance = new | |
| instance.instance_eval(&block) | |
| until instance.dispatched.value.zero? do | |
| unless instance.yields.empty? |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.