Skip to content

Instantly share code, notes, and snippets.

@EricLondon
EricLondon / scala-get-methods.scala
Created August 25, 2017 11:30
scala-get-methods.scala
""
.getClass.getMethods.map(_.getName) // methods
.sorted // sort
.filter(_ matches "(?i).*index.*") // grep /index/i
/////////
implicit def toMethods(obj: AnyRef) = new {
def methods = obj.getClass.getMethods.map(_.getName)
}
@EricLondon
EricLondon / sidekiq.rake
Created November 10, 2016 14:45
Sidekiq status rake task
require 'sidekiq/api'
namespace :sidekiq do
desc 'Output Sidekiq Status'
task status: :environment do
divider = '=================================================='
puts "#{divider}\nSTATS"
stats = Sidekiq::Stats.new
puts "\tProcesses:\t#{stats.processes_size}"
@EricLondon
EricLondon / nodejs_promise_example.js
Last active November 9, 2016 14:29
NodeJS Promise Example
var error = undefined;
var result = "wee!";
var chainableMethod = function () {
return new Promise(function(resolve, reject) {
if (error) {
console.log('got error');
return reject(error);
}
console.log('no error');
@EricLondon
EricLondon / emoji.rb
Created October 30, 2015 15:03 — forked from everm1nd/emoji.rb
Print Emoji in Ruby
# all emoji
# 1000.times { |i| emoji(127740 + i) + ' ' }
# moon phases
# 8.times { |i| emoji(127761 + i) }
DELAY = 0.3;
# clean screen
def clean
@EricLondon
EricLondon / gist:a3f1297cf8bc63673c79
Created July 14, 2015 20:06
RSpec Capybara Poltergeist config
require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {
debug: true,
timeout: 120,
js_errors: true,
inspector: true,
phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'],
@EricLondon
EricLondon / gist:f5e4722c15d1e9d6a7d1
Created July 9, 2015 12:51
nodejs spawn shell process (ps aux) and filter
var run_cmd = function(cmd, args, callBack) {
var spawn = require('child_process').spawn;
var child = spawn(cmd, args);
var resp = "";
child.stdout.on('data', function (buffer) { resp += buffer.toString() });
child.stdout.on('end', function() { callBack (resp) });
}
var check_ps_aux = function(service) {
@EricLondon
EricLondon / gist:df145895d5a3bacd2f7e
Last active August 29, 2015 14:23
IMS nginx & passenger
# I had nginx and passenger already installed via brew:
# note: this caused problems with RVM & gemsets
brew uninstall nginx passenger
brew cleanup
##########
# from the IMS rails project:
# note/todo: add to Gemfile?
gem install passenger -v 5.0.10
@EricLondon
EricLondon / gist:72952b77499badad4e29
Last active August 29, 2015 14:06
Rails Model Concern: track which classes have included the Concern
require 'active_support/concern'
module ChildTrackable
extend ActiveSupport::Concern
# keep track of what classes have included this concern:
module Children
extend self
@included_in ||= []
framework 'AppKit'
class Download
attr_reader :response, :responseBody
def start(request)
puts "START!"
NSURLConnection.connectionWithRequest(request, delegate:self)
end
@EricLondon
EricLondon / index.md
Created September 26, 2012 17:11 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one