Skip to content

Instantly share code, notes, and snippets.

View altamic's full-sized avatar

Michelangelo Altamore altamic

View GitHub Profile
@altamic
altamic / bitcoin.md
Created September 29, 2014 20:17
p2p crypto currencies versus traditional financial institutions

P2P payments for the masses

In 2009 Satoshi Nakamoto conceived Bitcoin, an electronic payment system based on cryptographic proof instead of trust. Bitcoin allow to make payments over a communications channel without a trusted party. In this post I will try to explain why its design choices are sound and fair.

Fixed money stock

Unless you are living on mars, you cannot avoid the amount of bad economic news on mainstream media, i.e. governments promoting either banks bailouts or bankrupt corporations too big to fail, hence running on larger and larger deficits, incresing taxes while cutting to the bone their services to population.

We are turned into thinking that the only way to escape our doomsday scenario is creating money i.e. a money expansion.

@altamic
altamic / gist:452b3ed9b6cc19db22b7
Created June 26, 2015 11:58
ruby http static server
# run an ad hoc http static server in your current directory (nobu)
ruby -run -ehttpd . -p8000
# ~/.irbrc file
# From http://giantrobots.thoughtbot.com/2008/12/23/script-console-tips
require 'rubygems'
require 'wirble'
Wirble.init
Wirble.colorize
# Easily print methods local to an object's class
class Object
initializer "time_formats.rb",
%q{def quarter(month)
(((month - 1) / 3) + 1) if (1..12).member? month
end
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS[:quarter] = lambda { |time| time.strftime("Q#{quarter(time.month)}-%y") }
}
What is this life if, full of care,
We have no time to stand and stare.
-- from "Leisure," by W.H. Davies
# deploy.rb
require 'yaml'
APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/app_config.yml"))
default_run_options[:pty] = true
set :user, APP_CONFIG['user']
set :domain, APP_CONFIG['domain']
set :application, APP_CONFIG['application']
module DelegateAttributes
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def delegate_or_override(*methods)
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}`
end
end
#! /bin/bash
# erb2haml
# by Michelangelo Altamore
# Obtains a file list having an html.erb extension
# under the current dir and convert each file
# to haml format with html.haml extension.
# It requires haml gem.
for erb_file in `find . -name *.html.erb`; do
# purge.rb
def delete_if_existent(file_name)
run "\[ -e #{file_name} \] && rm #{file_name}"
end
# Delete unnecessary files
%w(README public/index.html public/favicon.ico public/robots.txt public/images/rails.png).each do |file_name|
delete_if_existent(file_name)