Skip to content

Instantly share code, notes, and snippets.

@janx
janx / test_contract_meta.json
Created February 24, 2016 02:56
test contract meta register
{"source":"contract test { function multiply(uint a) returns(uint d) { return a * 7; } }","language":"Solidity","languageVersion":"0.2.1","compilerVersion":"0.2.1","compilerOptions":"--bin --abi --userdoc --devdoc --add-std --optimize -o /tmp/solc206349014","abiDefinition":[{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"type":"function"}],"userDoc":{"methods":{}},"developerDoc":{"methods":{}}}
@janx
janx / web3_filter.js
Created January 9, 2016 11:48
Web3.js event watch problem
// if 2nd arg is 'latest', everything is fine
var event = book.NewRecord(null, 'latest');
//event.get(function(err, results) {
// console.log(results);
//});
event.watch(function(err, result) {
if(err) {
console.log("error:", err);
} else {
console.log(result);
#!/bin/sh
path=`find /your_gollum_project -name '*.md' | sed 's/\/your_gollum_project\///' | sed 's/.md\$//' | dmenu -i -fn Tamzen-12 -p "Edit gollum wiki:" -l 25`
url="http://localhost:4567/edit/$path"
[ -z $path ] || /usr/bin/chromium --app="$url"
@janx
janx / react_spotlight.js
Created July 2, 2015 04:15
A script to show which parts rendered by React
setInterval(function() { Array.prototype.slice.call(document.querySelectorAll('[data-reactid]')).forEach(function(element) { element.style.background = 'rgba(255,0,0,0.1)'; }) }, 500)
#!/usr/bin/env ruby
if ARGV.size < 1
puts "usage: ruby_tags [version]"
exit 1
end
version = ARGV[0]
d = Dir["/home/jan/.rbenv/versions/#{version}/lib/ruby/gems/*/gems"]
raise "gems dir not found" if d.size < 1
@janx
janx / dmenu_goto_window.rb
Last active August 29, 2015 14:19
Jump to specified window (archlinux + bspwm + dmenu)
#!/usr/bin/env ruby
# get a list of all windows
window_list = `wmctrl -l`.split("\n").map {|l| l.strip.split(' ', 4)}
# write window names to a tmp file
File.open('/tmp/dmenu_goto_windows', 'w') do |f|
window_list.each {|w| f.puts w[3] }
end
Verifying myself: My Bitcoin username is +janx. https://onename.io/janx
@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
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."
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,