Skip to content

Instantly share code, notes, and snippets.

View theterminalguy's full-sized avatar
🎯
Focusing

theterminalguy

🎯
Focusing
View GitHub Profile
@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 }
http://es6-features.org/#BlockScopedVariables
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
@theterminalguy
theterminalguy / docker.help
Created December 2, 2017 21:03
Docker cheat sheet
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
docker container rm <hash> # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
docker image ls -a # List all images on this machine
@theterminalguy
theterminalguy / fibonacci.rb
Created October 21, 2017 19:07
Fibonacci sequence in ruby
def fib(n = 5)
first_two = [0, 1]
result = first_two + []
n.times do |i|
ans = first_two.inject(:+)
result.push(ans)
first_two = [first_two.last, ans]
end
result.slice(0, n)
end
@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 / design.rb
Last active September 12, 2017 17:24
Domain Driven Design in Ruby On Rails
#https://www.braintreepayments.com/blog/untangle-domain-and-persistence-logic-with-curator/
#https://github.com/braintree/curator
#https://nulogy.com/who-we-are/company-blog/articles/building-rich-domain-models-in-rails-separating-persistence/
#http://abhchand.me/blog/?p=117
#https://www.rubytapas.com/2017/04/11/skinny-controller-domain-model-events/
#https://gist.github.com/vsavkin/3577292
#https://stackoverflow.com/questions/1100819/how-do-you-design-object-oriented-projects
@theterminalguy
theterminalguy / linkedin.js
Last active October 14, 2017 13:53
Allows you to view linkedin private profiles
(
() => {
$('#advocate-modal').remove()
$('#pagekey-public_profile_v3_desktop').style.overflowY = 'scroll'
}
)()
@theterminalguy
theterminalguy / try_chain.rb
Last active September 8, 2017 21:19
Avoid several `.try` in your rails code
# https://www.mobomo.com/2010/11/calling-methods-on-potential-nil-objects-in-rails/
# http://tony.pitluga.com/2011/08/08/destructuring-with-ruby.html
module ActiveSupport
refine Object do
def try_chain(*args)
args.size > 1 ? eval("self.try(args[0]).try_chain(#{args[1..-1].inspect[1..-2]})") : self.try(args[0])
end
end
end
@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/"