Skip to content

Instantly share code, notes, and snippets.

View wezm's full-sized avatar

Wesley Moore wezm

View GitHub Profile
module Spec
module Mocks
# module ArgumentMatchers # rspec > 1.1.12
module ArgumentConstraints
# Based on:
# http://trottercashion.com/2009/2/12/custom-argumentmatchers-in-rspec
class NumericNearMatcher
def initialize(expected, tolerance)
require 'rubygems'
require 'hpricot'
require 'time'
if ARGV.size < 1
puts "Usage: fix_times.rb file.gpx"
exit 2
end
File.open(ARGV[0]) do |f|
#!/bin/bash
############################################################################
# Script to open a directory in TextMate excluding certain directories that
# tend to slow down the Find in Project... function.
#
# Place in an executable loctation with a name of your choosing.
# I use `ate' and have it in ~/Local/bin (which has been added to $PATH)
############################################################################
@wezm
wezm / gist:114808
Created May 20, 2009 13:16
HTML5 Template for xhtmldoctype.com
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
<body>
</body>
@wezm
wezm / virtualbox_feed.rb
Created June 28, 2009 01:18
Script to generate an Atom feed from the VirtualBox News page
#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'uuidtools'
require 'date'
require 'activesupport' # For DateTime.to_time
require 'uri'
require 'rubygems'
require 'nokogiri'
require 'mechanize'
require 'logger'
module BankBalance
class NabFetcher
def fetch(client_number, password)
require 'active_support/core_ext/string'
module CleanURIs#:nodoc:
# Having these methods as module methods instead of in just a simple mixin
# enables stubbing them more easily (which is important when File system
# access is stubbed in tests (as it should) because the unicode-support uses
# filesystem access to generate some lookup tables and will fail. So it needs
# to be stubbed out aswell
module UTF8Helper#:nodoc:
require 'rubygems'
require 'rack/cache'
infinity = Proc.new do |env|
# env['HTTP_CACHE_CONTROL'] = 'max-age=60'
[200, {"Content-Type" => "text/plain", 'Cache-Control' => 'max-age=60'}, env.inspect]
end
use Rack::CommonLogger
@implementation MyClass : CPObject
{
}
- (CPString)helloWorld
{
return @"Hello World"
}
@end
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <blkid/blkid.h> /* Linux, requires libblkid-dev on Debian/Ubuntu */
/* Small program to print the device name that a file resides on.
Uses stat to get the device id then devname or blkid_devno_to_devname
to convert the dev id to a device name */
int main(int argc, char **argv)