⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/racc | |
# -*- encoding: utf-8 -*- Lapis Racc Parser Class | |
# Andy Brown <[email protected]> [April, 12, 2010] | |
/* This is a BNF style parser generator grammar for the | |
* Lapis Language to be used by racc. Racc is a tool | |
* much like Yacc or Bison implemented for Ruby. | |
* | |
* Racc will parse this file and create a lapis.tab.rb | |
* file that contains a Parser class with a do_parse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>untitled</title> | |
<meta name="generator" content="TextMate http://macromates.com/"> | |
<meta name="author" content="Hugh Watkins"> | |
<!-- Date: 2010-06-25 --> | |
<script type="text/javascript" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(stopwatch). | |
-behaviour(gen_server). | |
%% Server API | |
-export([start_link/0, stop/0]). | |
%% Client API | |
-export([start_timer/0, stop_timer/0, read_timer/0]). | |
%% gen_server callbacks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% | |
%% this module models a typical manager/worker pattern, where manager may spawn a large number of workers | |
%% required behaviour: | |
%% | |
%% 1) manager must log unexpected worker exits | |
%% | |
%% - manager must trap exits in init function -> 'process_flag(trap_exit, true)' | |
%% - workers must be spawned with spawn_link | |
%% - worker exit messages are handled by manager handle_info handler [where they can be logged etc] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE_DIRS=%w[deps/rabbitmq-server/src deps/rabbitmq-erlang-client/src] | |
INCLUDE_DIRS=%w[deps/rabbitmq-server/include deps/rabbitmq-erlang-client/include] | |
FILES=%w[rabbit_writer.erl | |
rabbit_reader.erl | |
rabbit_framing_amqp_0_8.erl | |
rabbit_framing_amqp_0_9_1.erl | |
rabbit_framing_channel.erl | |
rabbit_basic.erl | |
rabbit_binary_generator.erl | |
rabbit_binary_parser.erl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "libvirt" | |
def nested | |
puts "nested" | |
h = Libvirt.connect | |
h.domains.each do |d| | |
puts "Domain: #{d.name}" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def phone_number_link(text) | |
sets_of_numbers = text.scan(/[0-9]+/) | |
number = "+1-#{sets_of_numbers.join('-')}" | |
link_to text, "tel:#{number}" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'iconv' | |
require 'nokogiri' | |
# This is a simple script to spider your Netflix paginated "What You've Rated" list. | |
# It requires an OS X based system with Ruby 1.9+, Safari, and AppleScript | |
# | |
# I could not find a way to back up my ratings (for all titles, not just my rental activity) | |
# without registering for a Netflix API key or handing my Netflix credentials over to someone | |
# who had an API key, so I decided to take a brute force approach and just parse the HTML for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you want to use multiple dbs at once there are several different ways... | |
1) If you want to do this on a per-model level, use .store_in (This is for all threads): | |
class Band | |
include Mongoid::Document | |
store_in database: "secondary" # This can be any name you want, no need to put it in the mongoid.yml. | |
end | |
class Artist |