Skip to content

Instantly share code, notes, and snippets.

View theterminalguy's full-sized avatar
🎯
Focusing

theterminalguy

🎯
Focusing
View GitHub Profile
@theterminalguy
theterminalguy / web-fonts-asset-pipeline.md
Created August 12, 2018 08:41 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@theterminalguy
theterminalguy / example_activejob.rb
Last active June 8, 2018 04:05 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
module ObjectTracker
module ClassMethods
def track_method(method_name)
alias_method :"#{method_name}_without_tracking", method_name
define_method :"#{method_name}_with_tracking" do |*splat|
params = self.class.instance_method(:"#{method_name}_without_tracking").parameters.collect(&:last)
self.send(:"#{method_name}_without_tracking", *splat) # do method first
self.track_event!(method_name, Hash[*(params.zip(splat).flatten)]) # then track
end
alias_method method_name, :"#{method_name}_with_tracking"
@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 }
@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 / 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
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 / 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.
@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 / 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", ...]