Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Bettison sgbett

View GitHub Profile
@sgbett
sgbett / sm_stats.rb
Last active May 2, 2018
Selfish mine stats
View sm_stats.rb
#!/usr/bin/env ruby
# Dependancies:
# gem install random_variate_generator
require 'random_variate_generator'
class Block
attr_accessor :real_interval, :interval, :timestamp
end
@sgbett
sgbett / selfish_da.rb
Last active May 3, 2018
Selfish mining with DA
View selfish_da.rb
#!/usr/bin/env ruby
# Dependancies:
# gem install random_variate_generator
iterations = 100000
alpha = 0.39 #sm hash_rate
require 'random_variate_generator'
@sgbett
sgbett / sm_sim.rb
Created Apr 6, 2018
Selfish Mining Sim
View sm_sim.rb
#!/usr/bin/env ruby
i = 0
iterations = 1000
sm_hash_pct = 33
public_chain = []
hm_fork = []
sm_fork = []
View Selfish mining sim
#!/usr/bin/env ruby
i = 0
iterations = 1000
reward = 1
sm_hash_pct = 33
hm_reward = 0
sm_reward = 0
View keybase.md

Keybase proof

I hereby claim:

  • I am sgbett on github.
  • I am sgbett (https://keybase.io/sgbett) on keybase.
  • I have a public key whose fingerprint is 9569 BCB5 4DD0 01AE 278B 1A95 D1CE 4815 5C3F 44BC

To claim this, I am signing this object:

@sgbett
sgbett / rails4findby2where.sh
Created May 16, 2016
sed & grep commands for locating uses of 'find_by_X(some_param)' and replacing with where(X: some_param)
View rails4findby2where.sh
#search project for occurances
grep -R find_by_ app/* | awk 'BEGIN {FS=":"}{print $1}' | uniq
#copy original file to .bak and do replacements of find_by with where
for F in $(grep -R find_by_ app/* | awk 'BEGIN {FS=":"}{print $1}' | uniq); do
mv $F $F.bak
sed 's/find_by_id(\(.*\))/where(id: \1).first/g' $F.bak > $F
done
You can’t perform that action at this time.