Skip to content

Instantly share code, notes, and snippets.

@ysv
ysv / bash-cheatsheet.sh
Created January 9, 2018 22:08 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
h = {
'a' => '1',
'e' => '2',
'i' => '3',
'o' => '4',
'u' => '5'
}
"hello world".gsub(/[aeiou]/, h)
# => "h2ll4 w4rld"
@ysv
ysv / loop.sh
Last active February 21, 2019 10:30
#!/bin/bash
set -xe
function fetchblk () {
blk=$(echo "obase=16; $1" | bc)
data=$(printf '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x%s", true],"id":1}' $blk)
curl -X POST -H "Content-Type: application/json" --data "$data" http://127.0.0.1:8545/ | jq '.'
}
const deployedAddress = "0x9Bc14c55139501643B62d49c9E8dEF17029Ad418";
const amountToClaim = 100000000; // 1 TRST
const abi =
[{"constant":false,"inputs":[],"name":"reclaimTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxAllowanceInclusive","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_maxAllowanceInclusive","type":"uint256"}],"name":"setMaxAllowance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"erc20Contract","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"claimedTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"isPaused","type":"bool"
new_precision = 8
markets=[]
Market.find_each do |m|
markets << m.as_json.slice("bid_unit", "ask_unit", "bid_fee", "ask_fee", "enabled", "position")
m.delete
end
markets.each do |m|
Market.create!(m.merge(ask_precision: new_precision, bid_precision: new_precision))
verify_options = {
verify_expiration: true,
verify_not_before: true,
iss: ENV["JWT_ISSUER"],
verify_iss: !ENV["JWT_ISSUER"].nil?,
verify_iat: true,
verify_jti: true,
aud: ENV["JWT_AUDIENCE"].to_s.split(",").reject(&:empty?),
verify_aud: !ENV["JWT_AUDIENCE"].nil?,
sub: "session",
# From barong container to get JWT_PUBLIC_KEY.
OpenSSL::PKey.read(Base64.urlsafe_decode64(Rails.application.secrets.jwt_shared_secret_key)).public_key.to_pem.yield_self {|pub| Base64.urlsafe_encode64(pub)}
def get_balances_for(member)
Currency.find_each.map do |c|
operations_main_balance = member.balance_for(currency: c, kind: :main)
operations_locked_balance = member.balance_for(currency: c, kind: :locked)
legacy_main_balance = member.legacy_balance_for(currency: c, kind: :main)
legacy_locked_balance = member.legacy_balance_for(currency: c, kind: :locked)
valid = operations_main_balance == legacy_main_balance && operations_locked_balance == legacy_locked_balance
deposits = [
{ member_id: 1, currency_id: :usd, amount: 1000 },
{ member_id: 1, currency_id: :eur, amount: 2000 },
{ member_id: 2, currency_id: :usd, amount: 100 },
{ member_id: 2, currency_id: :eur, amount: 200 }
]
deposits.map do |d|
Deposits::Fiat.create!(d).tap(&:accept!)
end
@ysv
ysv / k-line.md
Last active January 15, 2019 15:46

BITFINEX

wscat -c wss://api.bitfinex.com/ws/2

{ "event": "subscribe", "channel": "candles", "key": "trade:1m:tBTCUSD" }

BINANCE

wscat -c 'wss://stream.binance.com:9443/stream?streams=adabtc@kline_1m'