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
# coding: utf-8 | |
require 'rubygems' | |
require 'date' | |
require 'pdf/reader' | |
require 'graticule' | |
require 'builder' | |
class String | |
def is_numeric? |
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
# blog post: http://blog.slashpoundbang.com/post/1455548868/memcachemodel-make-any-ruby-object-that-persists-in | |
# No transactions or exceptions (yet). | |
module MemcacheModel | |
def self.included(base) | |
base.class_eval do | |
extend ActiveModel::Naming | |
extend ActiveModel::Translation | |
extend ActiveModel::Callbacks | |
extend MemcacheModel::ClassMethods |
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
# blog post: http://blog.slashpoundbang.com/post/1521530410/accessing-the-os-x-keychain-from-ruby | |
class KeyChain | |
def self.method_missing(meth, *args) | |
run args.unshift(meth) | |
end | |
def self.find_internet_password(*args) | |
# -g: Display the password for the item found | |
output = quiet args.unshift('find-internet-password', '-g') |
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
// blog post: http://blog.slashpoundbang.com/post/1573439856/google-maps-bookmarklet-for-cinema-clock | |
/*! | |
* jQuery JavaScript Library v1.4.4 | |
* http://jquery.com/ | |
* | |
* Copyright 2010, John Resig | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://jquery.org/license | |
* |
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
# blog post: http://blog.slashpoundbang.com/post/2346603512/checking-if-a-domain-exists-in-all-top-level-domains | |
name = "domain" # CHANGE THIS | |
require 'whois' | |
# deleted, unimplemented, or not in use: bv cs dd eh er gb sj ss yu | |
tlds = %w(aero asia biz cat com coop info int jobs mobi museum name net org post pro tel travel xxx) + # generic | |
%w(edu gov mil) + # USA | |
%w(arpa) + # infrastructure |
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
<?php | |
// Original by: Philippe Dagenais-Pérusse | |
// Get the files to parse | |
if ($argc) { // Command-line interface | |
$files = array_slice($argv, 1); | |
} | |
else { | |
$files = array(); | |
if ($handle = opendir($path)) { |
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
// blog post: http://blog.slashpoundbang.com/post/2428557007/unpack-and-beautify-javascript | |
// Assumes js_beautify is available: see https://github.com/einars/js-beautify/raw/master/beautify.js | |
function unpack_and_beautify(value) { | |
var position = 0, | |
open_string = "eval(function(", | |
open_index = -1, | |
close_string = "'.split('|'),0,{}))", | |
close_index = -1, | |
close_length = close_string.length, |
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
# coding: utf-8 | |
# blog post: http://blog.slashpoundbang.com/post/2488598258/running-javascript-from-the-command-line-with-v8 | |
abort "usage: #{$0} filename.h\n #{$0} filename.js prefix" unless ARGV[0] | |
abort "ERROR: Couldn't open '#{ARGV[0]}' for reading" unless File.exist?(ARGV[0]) | |
abort "ERROR: Prefix is required if input is JavaScript" if ARGV[0][/js$/] && !ARGV[1] | |
if ARGV[0][/js$/] | |
puts "const char #{ARGV[1]}_code[] = {\n #{File.read(ARGV[0]).unpack('U*').map{|i| i == 8212 ? [226, 128, 148] : i }.flatten.each_slice(16).map{ |a| a.map{ |i| "0x%02x" % i }.join(',') }.join(",\n ") },0x00\n};" | |
else |
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
// blog post: http://blog.slashpoundbang.com/post/2488598258/running-javascript-from-the-command-line-with-v8 | |
#include <v8.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include "beautify.h" | |
#include "unpack_and_beautify.h" | |
#define BUF_SIZE 1024 |
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
// blog post: http://blog.slashpoundbang.com/post/2488598258/running-javascript-from-the-command-line-with-v8 | |
const char unpack_code[] = { | |
0x2f,0x2f,0x20,0x62,0x6c,0x6f,0x67,0x20,0x70,0x6f,0x73,0x74,0x3a,0x20,0x68,0x74, | |
0x74,0x70,0x3a,0x2f,0x2f,0x62,0x6c,0x6f,0x67,0x2e,0x73,0x6c,0x61,0x73,0x68,0x70, | |
0x6f,0x75,0x6e,0x64,0x62,0x61,0x6e,0x67,0x2e,0x63,0x6f,0x6d,0x2f,0x70,0x6f,0x73, | |
0x74,0x2f,0x32,0x34,0x32,0x38,0x35,0x35,0x37,0x30,0x30,0x37,0x2f,0x75,0x6e,0x70, | |
0x61,0x63,0x6b,0x2d,0x61,0x6e,0x64,0x2d,0x62,0x65,0x61,0x75,0x74,0x69,0x66,0x79, | |
0x2d,0x6a,0x61,0x76,0x61,0x73,0x63,0x72,0x69,0x70,0x74,0x0a,0x0a,0x2f,0x2f,0x20, | |
0x41,0x73,0x73,0x75,0x6d,0x65,0x73,0x20,0x6a,0x73,0x5f,0x62,0x65,0x61,0x75,0x74, |
OlderNewer