Skip to content

Instantly share code, notes, and snippets.

@nontone
nontone / 0_howto_install_phantomjs.md
Created May 13, 2018 18:01 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@nontone
nontone / blockchain.rb
Last active November 6, 2017 07:42 — forked from chrisallick/blockchain.rb
tiny blockchain in ruby
# https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b
# http://ruby-for-beginners.rubymonstas.org/writing_classes/self.html
# https://stackoverflow.com/questions/33768598/ruby-sha-256-hexidigest-values-are-different-from-what-python-generates
require 'rubygems'
require 'digest'
class Block
def initialize(index, timestamp, data, previous_hash)
@index = index
@nontone
nontone / simplifying_has_many_through.rb
Last active May 15, 2016 22:13 — forked from thomasklemm/simplifying_has_many_through.rb
Simplifying a has_many :through (ActiveRecord / Rails). Also a useful boilerplate sharing complex ActiveRecord scenarios.
# Run this script with `$ ruby has_much_fun.rb`
require 'sqlite3'
require 'active_record'
# Use `binding.pry` anywhere in this script for easy debugging
require 'pry'
# Connect to an in-memory sqlite3 database
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].inject([]){ |s, (count, name)|
if secs > 0
secs, n = secs.divmod(count)
s.unshift "#{n.to_i} #{name}"
end
s
}.join(' ')
end