Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'base64'
require 'openssl'
require 'pp'
if ARGV.size != 1
puts "Usage: #{$0} <pem file>"
exit 1
end
@janx
janx / gist:9756153
Created March 25, 2014 06:23
Bitcoin client bootstrap before 0.6.x

https://en.bitcoin.it/wiki/Network

#IRC#

As-of version 0.6.x of the Bitcoin client, IRC bootstrapping is no longer enabled by default. The information below is accurate for most versions prior.

Bitcoin joins a random channel between #bitcoin00 and #bitcoin99 on irc.lfnet.org. Your nick is set to an encoded form of your IP address. By decoding all the nicks of all users on the channel, you get a list of all IP addresses currently connected to Bitcoin.

For hosts that cannot make outbound connections on port 6667, the lfnet servers are also listening on port 7777.

@janx
janx / centos-bitcoind-guide.markdown
Last active May 8, 2019 05:27
Install bitcoind on CentOS 6.5

##RPM Packages##

sudo yum install qt-devel protobuff-devel qrencode-devel

##Switch to user bitcoind##

sudo useradd bitcoind
sudo su - bitcoind
mkdir bitcoind

mkdir bitcoind/deps

@janx
janx / how-to-benchmark.markdown
Last active August 29, 2015 14:00
Integration benchmark

All below stuff run in PRODUCTION rails environment, make sure production settings in your database.yml points to a test database!!!

###Reset database

RAILS_ENV=production rake db:reset

###Start matching engine

# modify config/amqp.yml first if rabbitmq server is running on node other than 127.0.0.1
RAILS_ENV=production rake daemon:matching:start
#!/usr/bin/env ruby
require 'json'
require 'openssl'
require 'eventmachine'
require 'websocket-eventmachine-client'
access_key = 'your access key'
secret_key = 'your secret key'
@janx
janx / slanger_nginx_lb.conf
Created May 5, 2014 05:09
Use nginx as load balancer for Slanger
upstream slanger_ws {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
server 127.0.0.1:8004;
server 127.0.0.1:8005;
server 127.0.0.1:8006;
server 127.0.0.1:8007;
server 127.0.0.1:8008;
}
m = Member.find_by_email 'foo@peatio.dev'
market = Market.find :btccny
ask = OrderAsk.new(
source: 'debug',
state: Order::WAIT,
member_id: m.id,
ask: market.target_unit,
bid: market.price_unit,
currency: market.id,
m = Member.find_by_email 'foo@peatio.dev'
market = Market.find :btccny
puts "Ready ..."
a = m.get_account(:cny)
puts "balance: #{a.balance.to_s('F')}"
puts "locked: #{a.locked.to_s('F')}"
gets
puts "Started."
@janx
janx / gist:d8dc98870373d06c9e8d
Last active August 29, 2015 14:04
Description of ActiveRecord pattern from <Patterns of Enterprise Application Architecture>
In simple applications the Domain Model (116) is an uncomplicated structure that actually corresponds pretty
closely to the database structure, with one domain class per database table. Such domain objects often have
only moderately complex business logic. In this case it makes sense to have each domain object be
responsible for loading and saving from the database, which is Active Record (160) (see Figure 3.3). Another
way to think of the Active Record (160) is that you start with a Row Data Gateway (152) and then add domain
logic to the class, particularly when you see repetitive code in multiple Transaction Scripts (110).
...
As the domain logic gets more complicated and you begin moving toward a rich Domain Model (116), the simple
Verifying myself: My Bitcoin username is +janx. https://onename.io/janx