Skip to content

Instantly share code, notes, and snippets.

View rkellermeyer's full-sized avatar

Richard Kellermeyer rkellermeyer

View GitHub Profile
@rkellermeyer
rkellermeyer / irc.md
Created September 21, 2016 01:09 — forked from xero/irc.md
irc cheat sheet

#IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

##The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
    • Leaves the specified channel.
@rkellermeyer
rkellermeyer / cap_error
Last active August 29, 2015 14:23
Cap Auth Error
$ bundle exec cap dev_sandbox deploy
INFO [c3608890] Running /usr/bin/env mkdir -p /tmp/capstan/ on capstan-dev-sandbox.stonecroptech.com
DEBUG [c3608890] Command: ( RAILS_ENV=dev_sandbox /usr/bin/env mkdir -p /tmp/capstan/ )
INFO [7aecad29] Running /usr/bin/env mkdir -p /tmp/capstan/ on capstan-dev-sandbox-dj.stonecroptech.com
DEBUG [7aecad29] Command: ( RAILS_ENV=dev_sandbox /usr/bin/env mkdir -p /tmp/capstan/ )
cap aborted!
Authentication failed for user capstan@capstan-dev-sandbox.stonecroptech.com
/Users/rkellermeyer/.rvm/gems/ruby-1.9.3-p551@badger/gems/net-ssh-2.8.0/lib/net/ssh.rb:217:in `start'
/Users/rkellermeyer/.rvm/gems/ruby-1.9.3-p551@badger/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/Users/rkellermeyer/.rvm/gems/ruby-1.9.3-p551@badger/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
@rkellermeyer
rkellermeyer / rbenv_plugin_list
Created November 14, 2014 02:06
Essential rbenv plugins
For environment specific vars: https://github.com/sstephenson/rbenv-vars
For handling gemsets: https://github.com/jf/rbenv-gemset
Easily build rubies: https://github.com/sstephenson/ruby-build
RbEnv driven Bundler: https://github.com/carsomyr/rbenv-bundler
Find info on gems: https://github.com/rkh/rbenv-whatis.git
Alias `use` & mimic rvm: https://github.com/rkh/rbenv-use.git
Automatically rehash RbEnv: https://github.com/sstephenson/rbenv-gem-rehash.git
@rkellermeyer
rkellermeyer / richards_crud.erl
Created November 12, 2014 19:32
Erlang Crud
-module(richards_crud).
-compile(export_all).
new() ->
maps:new().
build(Key, Value, Map) ->
maps:put(Key, Value, Map).

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@rkellermeyer
rkellermeyer / user.rb
Last active December 20, 2015 16:59
Can you build a scope by model method value? (Edited showing non-working scope vs. working scope)
class User < ActiveRecord::Base
# ...
# Old scope: scope :adult_purchases_enabled, -> { where(self.age >= 21) }
# Working scope:
scope :adult_purchases_enabled, -> { where('birth_date <= ?', Time.current.advance(years: -21)) }
# ...
# Public Methods
def age
(Time.now.utc().to_s(:number).to_i - self.birth_date.to_time.utc().to_s(:number).to_i)/10e9.to_i
@rkellermeyer
rkellermeyer / spec_results.txt
Created August 6, 2013 13:36
Scope that only returns users who are 21 or older
Failures:
1) User scopes .adult_purchases_enabled does not return users who are not at least 21 years old
Failure/Error: User.adult_purchases_enabled.should_not include(subject)
expected [#<User id: 338, first_name: "Romaine", last_name: "Mohr", address1: "87010 Derick Heights", address2: nil, city: "Welchton", state: "Arkansas", zip_code: "11561", avatar: nil, birth_date: "1993-08-06", email: "foo-16@bar.com", about: nil, created_at: "2013-08-06 13:31:54", updated_at: "2013-08-06 13:31:55", latitude: 40.5895, longitude: -73.6389, active: false>] not to include #<User id: 338, first_name: "Romaine", last_name: "Mohr", address1: "87010 Derick Heights", address2: nil, city: "Welchton", state: "Arkansas", zip_code: "11561", avatar: nil, birth_date: "1993-08-06 00:00:00", email: "foo-16@bar.com", about: nil, created_at: "2013-08-06 13:31:54", updated_at: "2013-08-06 13:31:55", latitude: 40.5895272, longitude: -73.6389038, active: false>
Diff:
@@ -1,2 +1,2 @@
-[#<User id: 338, f
@rkellermeyer
rkellermeyer / pdfr.rb
Created January 10, 2013 21:06
PDF'r
require 'prawn'
Prawn::Document.generate("testing.pdf") do
Dir.foreach(".") do |f|
text "#{f}"
content = File.foreach(f).map(&:line) unless f == "." || f == ".."
text "#{content}"
end
end
@rkellermeyer
rkellermeyer / auth_net_samples.php
Created November 16, 2012 20:44
Auth.net PHP samples
<?php
require_once '../anet_php_sdk/AuthorizeNet.php'; // The SDK
$url = "http://YOURSITE.tld/post_result.php";
$api_login_id = '######';
$transaction_key = '#############';
$md5_setting = '######'; // Your MD5 Setting
$amount = "5.99";
AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);
define("AUTHORIZENET_API_LOGIN_ID", $api_login_id);
@rkellermeyer
rkellermeyer / application.html.haml
Created October 6, 2012 16:41
"can't dup NilClass" type error in search
# ...
= semantic_form_for users_path, :method => 'get', :id => "users_search" do |f|
= f.input :search, params[:search]
= f.submit_tag
#...