This file contains 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
def anagram_solve(letters, words): | |
solution = [word.lower() for word in words if len(word) == len(letters)] | |
for letter in letters: | |
solution = [word for word in solution if letter in word and letters.count(letter) == word.count(letter)] | |
return solution | |
if __name__ == "__main__": | |
import sys |
This file contains 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
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html | |
Hi everyone, I'm Chris Wanstrath. | |
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But | |
then I took a few moments and thought, Wait, why? Why me? What am I supposed | |
to say that's interesting? Something about Ruby, perhaps. Maybe the | |
future of it. The future of something, at least. That sounds | |
keynote-y. | |
This file contains 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 | |
# | |
# A complete URL-shortening web application, written in Ruby/Sinatra. Run it | |
# from the command line, and then visit http://localhost:4567/ | |
# | |
# Or to run it under apache/passenger, you'll need a config.ru file with the | |
# following contents: | |
# | |
# require 'tinyurl' | |
# run Sinatra::Application |
This file contains 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 'YOUR_APPLICATION' | |
run Sinatra::Application | |
This file contains 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
# :PROCESS: ruby, "ruby %f 2>&1" | |
# :BRACKET_CODE: "[ruby]", "[/ruby]" | |
# :TEXT: | |
# | |
# In the <a | |
# href="http://devver.net/blog/2009/06/a-dozen-or-so-ways-to-start-sub-processes-in-ruby-part-1/">previous | |
# article</a> we looked at some basic methods for starting subprocesses in Ruby. | |
# One thing all those methods had in common was that they didn't permit a lot of | |
# communication between parent process and child. In this article we'll examine | |
# a few built-in Ruby methods which give us the ability to have a two-way |
This file contains 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
# :PUBLISHER: markdown, shell, { command: 'rdiscount' } | |
# :BRACKET_CODE: '[ruby]', '[/ruby]' | |
# :TEXT: | |
# | |
# Have you ever started a long operation and walked away from the computer, and | |
# come back half an hour later only to find that the process is hung up waiting | |
# for some user input? It's a sub-optimal user experience, and in many cases it | |
# can be avoided by having the program choose a default if the user doesn't | |
# respond within a certain amount of time. One example of this UI technique in | |
# the wild is powering off your computer - most modern operating systems will |
This file contains 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
describe SomeController do | |
before(:each) do | |
# exisiting mock setup | |
end | |
# add to mocks, placement after before is key | |
it_should_behave_like "a before filter thingie" | |
it "blah" | |
end |
This file contains 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 | |
# this tool is similar to "git bisect" one, but for specs. | |
# it tries to find what spec from list of specs breaks execution of one specified spec. | |
# | |
# see more at http://zed.0xff.me/2010/01/28/rspec-bisect | |
# | |
# usage example: | |
# ./rspec-bisect.rb spec/**/*_spec.rb spec/controllers/spaces/tickets_controller_spec.rb | |
# [.] rspec runner: ./script/spec |
This file contains 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
--- src/http/ngx_http_variables.c.orig 2010-01-11 03:21:46.000000000 -0800 | |
+++ src/http/ngx_http_variables.c 2010-02-18 10:01:32.000000000 -0800 | |
@@ -93,6 +93,9 @@ | |
static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r, | |
ngx_http_variable_value_t *v, uintptr_t data); | |
+static ngx_int_t ngx_http_variable_start_time(ngx_http_request_t *r, | |
+ ngx_http_variable_value_t *v, uintptr_t data); | |
+ | |
/* |
This file contains 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
# USAGE: Hash.from_xml:(YOUR_XML_STRING) | |
require 'nokogiri' | |
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297 | |
class Hash | |
class << self | |
def from_xml(xml_io) | |
begin | |
result = Nokogiri::XML(xml_io) | |
return { result.root.name.to_sym => xml_node_to_hash(result.root)} |
OlderNewer