Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
| # Support for http digest auth | |
| # Discovered here: http://johan.bingodisk.com/public/code/net_digest_auth.rb | |
| require 'digest/md5' | |
| require 'net/http' | |
| module Net | |
| module HTTPHeader | |
| @@nonce_count = -1 | |
| CNONCE = Digest::MD5.new("%x" % (Time.now.to_i + rand(65535))).hexdigest |
| #!/bin/bash | |
| alias ..="cd .." | |
| alias ls="ls -p" | |
| alias la="ls -lA" | |
| alias l="ls -l" | |
| alias ll="ls -l" | |
| alias psf="ps -cU `whoami`" | |
| alias grep="grep --color=auto" | |
| alias cack="ack --cpp" |
| > This is a Shortwave configuration file | |
| > http://shortwaveapp.com/ | |
| > | |
| > Some triggers copied from benpickles (http://gist.github.com/43371) | |
| > | |
| > Urls may contain the following replacement tokens: | |
| > | |
| > %s → search terms | |
| > %r → URL of current page | |
| > %d → domain part of the current URL |
| #!/usr/bin/ruby | |
| # | |
| # Example usage: | |
| # tell iTunes to pause | |
| # tell iTunes to play | |
| # tell Linkinus to quit | |
| # | |
| # http://twitter.com/mxcl | |
| # we add it back later |
Some exercises from the Falsy Values workshops.
The good parts:
| Scenario: Edit Company Name # features/user_edit.feature:6 | |
| Given I am signed up and signed in with "test@example.com" # features/step_definitions/session_steps.rb:12 | |
| And I am on the home page # features/step_definitions/web_steps.rb:44 | |
| When I follow "My Info" # features/step_definitions/web_steps.rb:56 | |
| And I fill in "user[company_name]" with "Royal Snoker Casino" # features/step_definitions/web_steps.rb:60 | |
| And I fill in "user[current_password]" with "secret" # features/step_definitions/web_steps.rb:60 | |
| And I press "Update" # features/step_definitions/web_steps.rb:52 | |
| undefined method `node_name' for nil:NilClass (NoMethodError) | |
| ./features/step_definitions/web_steps.rb:53:in `/^(?:|I )press "([^"]*)"$/' | |
| features/user_edit.feature:12:in `And I press "Update"' |
| function jsonrpc(user, method, params, http_method, cont) { | |
| if(_.isFunction(http_method)) { | |
| cont = http_method; | |
| http_method = 'GET'; | |
| } | |
| var request; | |
| var opts = { |
| <?php | |
| /** | |
| * @Given /^I logged in as "([^"]*)" with "([^"]*)" password$/ | |
| */ | |
| public function iLoggedInAsWithPassword($username, $password) | |
| { | |
| return array( | |
| new Step\Given("I am on \"/login\""), | |
| new Step\When("I fill in \"Username\" with \"$username\""), |
| #!/usr/bin/env ruby | |
| require 'csv' | |
| require 'json' | |
| if ARGV.size != 2 | |
| puts 'Usage: csv_to_json input_file.csv output_file.json' | |
| puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects' | |
| exit(1) | |
| end |
| require 'win32ole' | |
| app = WIN32OLE.new('iTunes.Application') | |
| # p app.ole_obj_help | |
| # p app.ole_methods | |
| tracks = app.LibraryPlaylist.Tracks | |
| puts "Num of tracks: #{tracks.Count}" | |
| tracks.each do |track| | |
| %w(Artist Name Album).each do |name| |