Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaac Sanders isaacsanders

View GitHub Profile
@isaacsanders
isaacsanders / closure.rb
Created Aug 30, 2013
An naïve implementation of a Closure object in Ruby
View closure.rb
class Closure
attr_reader :formals, :bodies, :env
def initialize(formals, bodies, env)
@formals = Array(formals)
@bodies = Array(bodies)
@env = env
end
def call(*args)
raise argument_error(args) if args.length != formals.length
View woes.txt
$ ri Faraday::Middleware
/Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:196:in `load': instance of RDoc::Context::Section needs to have method `marshal_load' (TypeError)
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:196:in `block in load_class'
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:195:in `open'
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:195:in `load_class'
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:609:in `block in classes_and_includes_for'
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:607:in `map'
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:607:in `classes_and_includes_for'
from /Users/isaac/.rvm/gems/ruby-2.0.0-p195@chicago_ideas/gems/rdoc-3.
View foo.rb
define_method :foo do |bar, &block|
block.call(bar)
end
View namespace.rb
namespace "Foo::Bar" do
# Define methods in here.
# `namespace` defines modules all the way down,
# or classes if the constant is already defined.
end
@isaacsanders
isaacsanders / web.hs
Created Feb 27, 2013
Type signatures for web interaction
View web.hs
adminDashboard :: User -> Page
adminDashboard Admin user = dashboardPage
adminDashboard _ = unauthorizedPage
homePage :: User -> Page
homePage Admin user = adminHomePage
homePage Member user = memberHomePage
homePage _ = signInPage
@isaacsanders
isaacsanders / gist:5034024
Created Feb 25, 2013
SERIOUSLY WTF HAPPENED!
View gist:5034024
$ ruby
Could not find i18n-0.6.1 in any of the sources
Run `bundle install` to install missing gems.
@isaacsanders
isaacsanders / mkmf.log
Last active Dec 14, 2015
The output from `rvm install ruby --debug`
View mkmf.log
=== OpenSSL for Ruby configurator ===
=== Checking for system dependent stuff... ===
have_library: checking for t_open() in -lnsl... -------------------- no
"/usr/local/bin/gcc-4.2 -o conftest -I../../.ext/include/x86_64-darwin12.2.0 -I../.././include -I../.././ext/openssl -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/opt/local/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libxml2/include -I/usr/local/opt/libxslt/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/opt/curl-ca-bundle/include -I/usr/local/opt/sqlite/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -pipe conftest.c -L. -L../.. -L/opt/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/op
@isaacsanders
isaacsanders / RubeGoldbergSearch.java
Created Jan 16, 2013
Any thoughts on making this even more awful?
View RubeGoldbergSearch.java
public static int search(Integer[] arriArrayToBeSearched, Integer iItemToBeFoundInArray){
int iIndexOfItemToBeFoundInArrayInArrayToBeSearched = -1;
int iLengthOfArrayToBeSearched = 0;
int iTemporaryVariable = arriArrayToBeSearched.length;
while (iTemporaryVariable > 0) {
iLengthOfArrayToBeSearched += 1;
iTemporaryVariable -= 1;
}
for (int indexInArrayToBeSearched = 0; indexInArrayToBeSearched < iLengthOfArrayToBeSearched; indexInArrayToBeSearched += 1) {
Integer iMemberOfArrayToBeSearchedAtCurrentIndex = arriArrayToBeSearched[indexInArrayToBeSearched];
@isaacsanders
isaacsanders / commands.md
Last active Feb 20, 2019
Basic Vim commands
View commands.md

Vim primer

Modes

  • Normal: the mode that you are generally in at the beginning of a session. One does most of their moving around in this mode.
  • Insert: the mode where you are inserting text.
  • Visual: the mode for selecting text.
  • Command: the mode where you use commands for reading/writing files and managing your session.

I imagine I am missing some, but these are the ones I use the most.