Skip to content

Instantly share code, notes, and snippets.

@n8agrin
n8agrin / net_http_digest_auth.rb
Created March 3, 2009 00:29
HTTP Digest Auth for Ruby's net/http
# 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
@mxcl
mxcl / .profile
Created April 22, 2009 16:13
My Bash .profile file
#!/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"
@holman
holman / waves.txt
Created October 15, 2009 17:05 — forked from mislav/waves.txt
Shortwave conf
> 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
@mxcl
mxcl / tell
Created February 4, 2010 13:40
Convenience script for running certain Applescripts
#!/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
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
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"'
@jlongster
jlongster / gist:1288142
Created October 14, 2011 20:00
Bugzilla jsonrpc
function jsonrpc(user, method, params, http_method, cont) {
if(_.isFunction(http_method)) {
cont = http_method;
http_method = 'GET';
}
var request;
var opts = {
@cystbear
cystbear / FeatureContext.php
Created November 16, 2011 20:24
Behat meta steps -- tiny example
<?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
@macks
macks / iTunes_win32ole.rb
Created December 29, 2011 22:57
Controll iTunes from Ruby script using WIN32OLE
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|