Skip to content

Instantly share code, notes, and snippets.

View theterminalguy's full-sized avatar
🎯
Focusing

theterminalguy

🎯
Focusing
View GitHub Profile
@theterminalguy
theterminalguy / railscasts.rb
Created June 20, 2016 15:27 — forked from samqiu/railscasts.rb
Download free Railscast video
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@theterminalguy
theterminalguy / file.rb
Created July 25, 2016 14:20
RuralTown Json
This file has been truncated, but you can view the full file.
RuralTown.create!([
{:rural_district_id=>1, :id=>"Abuma", :name=>"Abuma"},
{:rural_district_id=>1, :id=>"Amaebem", :name=>"Amaebem"},
{:rural_district_id=>1, :id=>"Amaeke", :name=>"Amaeke"},
{:rural_district_id=>1, :id=>"Amakpofia", :name=>"Amakpofia"},
{:rural_district_id=>1, :id=>"Amankwu", :name=>"Amankwu"},
{:rural_district_id=>1, :id=>"Amasa", :name=>"Amasa"},
{:rural_district_id=>1, :id=>"Amatiti", :name=>"Amatiti"},
{:rural_district_id=>1, :id=>"Amodu", :name=>"Amodu"},
{:rural_district_id=>1, :id=>"Eziama", :name=>"Eziama"},
@theterminalguy
theterminalguy / Remove From Git By Extension
Created August 3, 2016 10:28 — forked from benzittlau/Remove From Git By Extension
Remove all *.swp files from a git repository
git ls-files | grep '\.swp$' | xargs git rm
Area
Postcode
State
Street
Town
Zone
namespace :urban do
[
# returns all the state in Nigeria
@theterminalguy
theterminalguy / file1.txt
Created August 22, 2016 12:19
Created via API
Demo
ActiveRecord::Schema.define(version: xxxxx) do
create_table "areas", force: :cascade do |t|
t.integer "town_id"
t.string "name"
end
add_index "areas", ["town_id"], name: "index_areas_on_town_id"
create_table "post_codes", force: :cascade do |t|
@theterminalguy
theterminalguy / reset_primary_key.md
Created January 18, 2017 13:38 — forked from paulsturgess/reset_primary_key.md
Reset postgres primary key index using Rails
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')

If you need the table names:

$ ActiveRecord::Base.connection.tables

=> ["accounts", "assets", ...]

@theterminalguy
theterminalguy / measure.rb
Created February 5, 2017 03:56 — forked from camertron/measure.rb
Measure the memory taken by a Ruby object (by Robert Klemme)
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
@theterminalguy
theterminalguy / gist:8d741f6d8368e51c2662ba893985928d
Created March 4, 2017 17:31 — forked from ckenst/gist:351f3ceb1dd1505c0918
Gregg Pollack's Founders Talk All Lessons

Gregg Pollack's Founder's Talk 1

25 Lessons:

  1. As a founder, you must be willing to wear all hats
  2. Do one on ones
  3. If you have an audience, you can make money
  • Sponsorships
  • Charging people
  • If you can bring an audience, you can probably figure out a way to monetize.