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 / 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
@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.
set imap_user = 'user@gmail.com'
set imap_pass = 'pass'
set spoolfile = imaps://imap.gmail.com:993/INBOX
set folder = imaps://imap.gmail.com:993
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed=”imaps://imap.gmail.com/[Gmail]/Drafts”
set message_cachedir=”~/.mutt/cache/bodies”
set certificate_file=~/.mutt/certificates
set smtp_url = "smtp://user@smtp.gmail.com:587/"
@theterminalguy
theterminalguy / The difference between the junior and senior Rails developer
Created August 24, 2017 20:23 — forked from njonsson/The difference between the junior and senior Rails developer
The difference between the junior and senior Rails developer — an extract of the discussion forum at the Rubyists LinkedIn group
Someone recently asked the following question in the discussion forum of the Rubyists LinkedIn group: What separates a junior Rails developer from a senior one?
My response follows. Join us at http://www.linkedin.com/groups?gid=120725 to weigh in on this and other topics of interest to Rubyists. As of today there are almost 1,200 members, including numerous movers and shakers in the Ruby and Rails communities.
“Distinguishing between junior and senior people in the Rails world is not so different from making the distinction in other web development environments.
“Junior Rails people have not dealt with scaling issues to the degree that senior people have. Getting a public-facing Rails application to perform under significant stress is more challenging than doing the same with other building materials such as PHP. Senior people know how to performance-test Rails applications, where to look for bottlenecks, and how to eliminate them one after another until performance is acceptable in real conditions. The Ra
@theterminalguy
theterminalguy / install_elasticsearch_osx.md
Created October 19, 2017 14:57 — forked from djonsson/install_elasticsearch_osx.md
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@theterminalguy
theterminalguy / follow_observer_spec.rb
Created December 8, 2017 23:09 — forked from ches/follow_observer_spec.rb
Example of testing Rails observers in isolation for cross-cutting concerns
require 'spec_helper'
# Bustle is a pubsub system used for activity streams:
# https://github.com/fredwu/bustle
#
# Here when a person follows another (or a discussion, for instance), the observer wires
# up pubsub between them for future activity notifications. The Follow model knows nothing
# about the implementation choices for the pubsub system.
describe FollowObserver do
subject { FollowObserver.instance }