Skip to content

Instantly share code, notes, and snippets.

describe("NiceTrie", function() {
it("can be initialized", function() {
var t = new Trie();
});
describe("with a trie", function(){
var t;
beforeEach(function() {
t = new Trie();
});
require 'rubygems'
require 'json'
json = JSON.parse(File.open("github_issues.json").read)
issues = json["issues"]
require 'redmine_client'
RedmineClient::Base.configure do
self.site = 'http://bugs.joindiaspora.com'
self.user = 'ilya'
@rsofaer
rsofaer / mongo_mapper_update_on_new.rb
Created November 3, 2010 05:01
MongoMapper: Override by setting ID
require 'mongo_mapper'
MongoMapper.database = 'testing'
class SafeDoc
include MongoMapper::Document
key :name
safe
end
puts "With a 'safe' document class:"
[user]
name = Raphael Sofaer
email = raphael@joindiaspora.com
[github]
user = rsofaer
token = <REDACTED>
[branch]
autosetuprebase = always
autosetupmerge = true
[color]
@rsofaer
rsofaer / Blocks vs modules
Created March 27, 2011 19:06
Got curious after seeing something on reddit/r/ruby
require 'benchmark'
module RoflModule
def rofladd(ping, pong)
ping + pong
end
end
RoflBlock = <<BLOCK
def rofladd(ping, pong)
@rsofaer
rsofaer / gist:7765178
Last active December 30, 2015 02:49
Complexity Classes
O(1) - Constant time
"Get the first value of a list"
"Random sample from a list"
O(logN) - Divide and Pick
Typical of algorithms that divide the input, then look at one of the sections
Searching sorted data
O(N) - For each ....
Sum an array
@rsofaer
rsofaer / postfixhints.rb
Last active December 30, 2015 04:59
Hint file for postfix to infix
class TreeNode
attr_accessor :val, :left, :right
def initialize(v)
@val = v
end
def leaf?
# A node is a leaf if it has no children.
end
end
@rsofaer
rsofaer / installfest_steps.md
Last active December 31, 2015 07:09
Steps for installing starting software for GA WDI 2013

GA_Logo

#WDI Installfest

We are going to install the tools necessarily to program with Ruby and Rails on your computer.

If you are on a Mac which is not running the latest version of OSX, please upgrade through the Mac App Store. Apple has made it easier to set up a computer for software development in OSX Mavericks, and keeping the differences between computers to a minimum will help us get everything installed quickly and correctly.

If you are unsure or run into problems during installation, stop and don't worry; We will finish up any of the loose ends on Installfest. Do not try to troubleshoot on your own, you might break your environment further.

Living in the Command Line

Web programmers have to live on the command line. It gives us fast, reliable, and automatable control over computers. Web servers usually don't have graphical interfaces, so we need to interact with them through command line and programmatic interfaces. Once you become comfortable using the command line, staying on the keyboard will also help you keep an uninterrupted flow of work going without the disruption of shifting to the mouse.

Notes before we start

For any command we discuss here, the command man, short for manual, will give a (hopefully) detailed explanation of that command. Sometimes that explanation will be too detailed for you. When you get lost in a man page and you want to understand it, start again from the beginning of of the man page and keep repeating. Hopefully you will get further into the page each time you read it.

Metaphors

The command line is my home. I literally think of using the command line as walking around a building.

Wh

Debugging and Exceptions

Agenda

  1. Debugging Philosophy and Techniques
  2. Basic Errors and Reading an Exception
  3. Methods and the Stack, Reading a Backtrace
  4. Error Classes, Raising and Rescuing
  5. More Debugging Techniques, a Glimpse of Testing

Debugging in the Abstract