Skip to content

Instantly share code, notes, and snippets.

View sporkmonger's full-sized avatar

Bob Aman sporkmonger

View GitHub Profile
gem 'signet', '~> 0.3.0'
require 'signet/oauth_2/client'
gem 'google-api-client', '~> 0.4.3'
require 'google/api_client'
require 'google/api_client/client_secrets'
client_secrets = Google::APIClient::ClientSecrets.load('client_secrets.json')
client = Google::APIClient.new(
:authorization => Signet::OAuth2::Client.new(
:client_id => client_secrets.client_id,
:client_secrets => client_secrets.client_secrets,
@sporkmonger
sporkmonger / rot13.rb
Created April 16, 2012 13:54
ZOMG, don't do this!
class String
def rot13
self.tr "A-Za-z", "N-ZA-Mn-za-m"
end
end
@sporkmonger
sporkmonger / flexbox.html
Created September 18, 2011 19:37
Flexbox Layout
<!DOCTYPE html>
<html>
<head>
<title>Flexbox Layout</title>
<style>
article {
border: 1px solid red;
display: -webkit-box;
display: -moz-box;
display: box;
@sporkmonger
sporkmonger / offline_debug.js
Created April 27, 2011 10:44
Offline Application Cache Debugging
// Adapted from a snippet by Jonathan Stark
var cacheStatusValues = [];
cacheStatusValues[0] = 'uncached';
cacheStatusValues[1] = 'idle';
cacheStatusValues[2] = 'checking';
cacheStatusValues[3] = 'downloading';
cacheStatusValues[4] = 'updateready';
cacheStatusValues[5] = 'obsolete';
Usage: google-api (execute <rpcname> | [command]) [options] [-- <parameters>]
Available options:
--scope <scope> Set the OAuth scope
--client-key <key> Set the 2-legged OAuth key
--client-secret <secret> Set the 2-legged OAuth secret
-s, --service <name> Perform discovery on service
--service-version <id> Select service version
--content-type <format> Content-Type for request
-u, --uri <uri> Sets the URI to perform a request against
>> regexp = Regexp.new("ÀÈÌÒÙ".force_encoding Encoding::ISO8859_1)
=> /ÀÈÌÒÙ/
>> regexp.encoding
=> #<Encoding:ISO-8859-1>
var sys = require('sys'),
http = require('http');
var STATUS_CODES = {
100 : 'Continue',
101 : 'Switching Protocols',
200 : 'OK',
201 : 'Created',
202 : 'Accepted',
203 : 'Non-Authoritative Information',
#!/usr/bin/env ruby
# The program e is a command line utility that extracts lots of
# different archives. It is very simple and can be extended very easily.
#
# It is inspired by how firewall use their rulesets, and works like this:
#
# * For each file that has to be extracted, the rules are matched one after the other.
# * When a rule matches (either by the filetype or filename), the command is executed.
# * If the command does not return an error code the extraction is considered successful, otherwise the next rules are matched.
From 644a88293136c3c4aafecd217b340350cf1f9ca9 Mon Sep 17 00:00:00 2001
From: Bob Aman <[email protected]>
Date: Thu, 25 Jun 2009 09:39:59 -0400
Subject: [PATCH] Fixed Content-Encoding bug with explicit default.
* If the default Content-Encoding of 7bit was given, Mechanize would
error out needlessly.
---
lib/www/mechanize/chain/body_decoding_handler.rb | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
require "datamapper"
class CrawledURI
include DataMapper::Resource
STORAGE_NAME = "crawled_uris"
property :id, Integer, :serial => true
# Data
property :uri, String, :length => 1024