Skip to content

Instantly share code, notes, and snippets.

@osfx
osfx / app.rb
Last active December 26, 2018 05:59
Rails App
comment_lines "Gemfile", /gem 'tzinfo-data'/
generate(:controller, "static index")
route "root to: 'static#index'"
rails_command("db:migrate")
after_bundle do
git :init
git add: "."
git commit: %Q{ -m 'Initial commit' }
end
0x9AF47a39E7Fdb6f9bd870f7665928eb82cEc5C2e
@osfx
osfx / bitcoin-pay.rb
Created November 18, 2017 04:41 — forked from Sjors/bitcoin-pay.rb
This script demonstrates how a bitcoin transaction is created and signed. Just pass in your own address and private key and it will prepare a transaction for you. You can then copy & paste that transaction into a webservice like Blockchain to send it. I wrote this mostly to understand better how it works. I sometimes had to "cheat" and look at t…
#!/usr/bin/env ruby
require 'open-uri'
require 'JSON'
require 'digest/sha2'
require 'pry'
require 'bigdecimal'
require 'bitcoin' # Because I need to cheat every now and then
# Usage:
# gem install pry json ffi ruby-bitcoin
@osfx
osfx / block_chain.rb
Created November 18, 2017 04:40 — forked from altamic/block_chain.rb
Blockchain consisting of proof of work as from lian
#
# Ruby Example of the 'proof of work' explanation
# from https://en.bitcoin.it/wiki/Proof_of_work
#
# note: block data passed to do_work is simplified.
# bitcoin blockchain is more complex too.
#
require 'digest/sha2'
@osfx
osfx / block_chain.rb
Created November 18, 2017 04:39 — forked from altamic/block_chain.rb
Blockchain consisting of proof of work as from lian
#
# Ruby Example of the 'proof of work' explanation
# from https://en.bitcoin.it/wiki/Proof_of_work
#
# note: block data passed to do_work is simplified.
# bitcoin blockchain is more complex too.
#
require 'digest/sha2'
@osfx
osfx / README-Template.md
Created November 18, 2017 04:35 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@osfx
osfx / spec.rb
Created November 2, 2017 13:05
Пример спеки
require "spec_helper"
describe 'Пользователь' do
context '#авторизован' do
it 'доступно меню настроек' do
end
it 'есть ссылка на кошелёк' do
end
end
end
@osfx
osfx / my-ip.sh
Created October 4, 2017 23:42
my-ip
# with sed:
ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
# with sed:
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
@osfx
osfx / Gemfile.rb
Created June 10, 2017 15:50
Gemfile
# before_all do
run "rm -rf Gemfile"
run "touch Gemfile"
add_source "https://rubygems.org"
after_bundle do
gem 'rails', '~> 5.1.1'
gem 'pg', '~> 0.18'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
@osfx
osfx / index.md
Created April 22, 2017 03:00 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one