Skip to content
View bitfinex_orderbook.json
{
"bids": [
{
"price": "284.45",
"amount": "15.5929344",
"timestamp": "1438678974.0"
},
{
"price": "284.44",
"amount": "24.0",
View gist:1d3a6aaedfe166f28d99
mysql> select * from pricings where source='btcchina_ob' order by pricing_id desc limit 10;
+------------+-------------+---------------------+---------------------+--------------------+--------------------+--------------------+----------+-------+
| pricing_id | source | remote_ts | local_ts | price_last | price_bid1 | price_ask1 | currency | notes |
+------------+-------------+---------------------+---------------------+--------------------+--------------------+--------------------+----------+-------+
| 1025024 | btcchina_ob | 2015-08-12 09:45:31 | 2015-08-12 09:39:11 | 1700.6033527913733 | 1699.0876049494914 | 1702.1191006332551 | CNY | NULL |
| 1025014 | btcchina_ob | 2015-08-12 09:45:00 | 2015-08-12 09:38:41 | 1700.461464680406 | 1698.8038287275567 | 1702.1191006332551 | CNY | NULL |
| 1025007 | btcchina_ob | 2015-08-12 09:44:28 | 2015-08-12 09:38:11 | 1700.5463038790892 | 1698.8860604081324 | 1702.206547350046 | CNY | NULL |
|
View bitfinex.rb
def headers_for(path, options={})
payload = {}
payload['request'] = path
payload['nonce'] = (Time.now.to_f * 10000).to_i.to_s
payload.merge!(options)
payload_enc = Base64.encode64(payload.to_json).gsub(/\s/, '')
sig = Digest::HMAC.hexdigest(payload_enc, @api_secret, Digest::SHA384)
View deferred_garbage_collection.rb
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f
@@last_gc_run = Time.now
def self.start
GC.disable if DEFERRED_GC_THRESHOLD > 0
end
View eval_benchmark.rb
require 'benchmark'
require 'active_support/inflector'
class Foo
def self.bar
end
end
def with_eval
eval "Foo.bar"
View rspec_with_anonymous_controller.rb
require 'rails_helper'
RSpec.describe V1::BaseController, :type => :controller do
before do
Rails.application.routes.draw do
match "/v1/dummy", to: "v1/base#index", via: :all
end
end
View standup
#!/usr/bin/env ruby
require 'date'
def open_video(file)
file = file.gsub(/\s/, '\\ ')
puts "opening #{file}"
`open #{file} -n /Applications/MPlayerX.app`
end
View zsh-bira-theme.diff
diff --git a/themes/bira.zsh-theme b/themes/bira.zsh-theme
index 2157204..003cb92 100644
--- a/themes/bira.zsh-theme
+++ b/themes/bira.zsh-theme
@@ -4,7 +4,7 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
-if which rvm-prompt &> /dev/null; then
+if [ -e ~/.rvm/bin/rvm-prompt ]; then
View constant_vs_class_variable.rb
require 'benchmark'
LOCALE_ARRAY = (1..1000000).to_a
class MyClass
def self.vars
@@vars
end
def self.vars=(args)
View csrf_token_in_rails_ajax_request.markdown
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end
$(document).ajaxSend(function(e, xhr, options) {
  var token = $("meta[name='csrf-token']").attr("content");
  xhr.setRequestHeader("X-CSRF-Token", token);
Something went wrong with that request. Please try again.