Skip to content

Instantly share code, notes, and snippets.

View saroar's full-sized avatar
🏠
Working from home

Saroar Khandoker saroar

🏠
Working from home
View GitHub Profile
@saroar
saroar / bitcoin-pay.rb
Created May 10, 2017 06:47 — 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
@saroar
saroar / form_steps.rb
Created April 11, 2017 14:18 — forked from emk/form_steps.rb
Fill in multiline forms with Cucumber and Webrat
# Fill in multiple form fields using a table. Use it as follows:
#
# When I fill in the fields
# | Field 1 | Value 1 |
# | Field 2 | Value 2 |
When /^I fill in the fields$/ do |table|
table.rows_hash.each {|field, value| fill_in field, :with => value }
end
@saroar
saroar / active-record-migration-expert.md
Created October 12, 2016 17:33 — forked from pyk/active-record-migration-expert.md
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb
@saroar
saroar / deploying_phoenix_on_dokku.md
Created September 18, 2016 07:22 — forked from henrik/deploying_phoenix_on_dokku.md
Deploying Elixir's Phoenix Framework on Dokku.

Deploying Phoenix on Dokku

Worked 2015-09-08 for Phoenix 1.0.1 on Dokku 0.3.25.

These instructions assume you've set up Dokku. If not, go find a tutorial for that part. My notes for setting it up on Digital Ocean.

On your local machine, in the app's repo

Create a Dokku app:

class CreateProjects < ActiveRecord::Migration[5.0]
def change
create_table :projects do |t|
t.string :name
t.timestamps
end
end
end
ActiveAdmin.register NutritionData do
menu false
form do |f|
f.inputs "Details" do
f.input :item_id, :as => :hidden
f.input :header, :input_html => {:rows => 5}
f.input :serving, :input_html => {:rows => 5}
f.input :calories
f.input :calories_from_fat