Skip to content

Instantly share code, notes, and snippets.

View blech75's full-sized avatar
🤖

justin blecher blech75

🤖
  • BDL
  • 09:31 (UTC -04:00)
View GitHub Profile
@blech75
blech75 / external_script_domains.js
Created September 3, 2010 20:12
a little Prototype.js magic for returning the domains of external JS files
$A(document.getElementsByTagName('SCRIPT')).reject(function(s){
return !s.getAttribute('src');
}).map(function(s){
return s.getAttribute('src');
}).reject(function(u){
return u.charAt(0) == "/";
}).map(function(u){
return /^https?:\/\/([^/]+)/i.exec(u)[1];
}).uniq();
@blech75
blech75 / gsmls-image-downloader.rb
Created September 10, 2010 13:50
a script to download images associated with a GSMLS ID
#!/usr/bin/env ruby
# gsmls-image-downloader.rb
# -------------------------
# When passed a GSMLS ID, this script will download all of the listing's
# associated images.
require 'open-uri'
def download_image(mls_id)
@blech75
blech75 / screenshot.js
Created May 19, 2011 14:38
batch screenshot script for Firefox and IE on Windows using WSH
// FIXME: use %PROGRAMFILES% to get at "c:\\Program\ Files"
// FIXME: put SAVE_DIR on the current user's desktop?
// FIXME: make it configurable via command-line options?
var BROWSERS = {
'ff' : {
'PATH' : "c:\\Program\ Files\\Mozilla\ Firefox\\",
'SAVE_DIR' : ".\\firefox\\"
},
'ie' : {
'PATH' : "",
@blech75
blech75 / svn-zip
Created June 21, 2011 18:56
export SVN URL, zip it up, drop it on your desktop
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage: "`basename "$0"` "SVN_URL ZIP_NAME" >&2
exit 1
fi
SVN_URL=$1
DIR_NAME=$2
@blech75
blech75 / subdomain_session.rb
Created October 21, 2011 18:28
ugly hack to set subdomain cookies in Rails 1.2 apps
module SubdomainSessions
def self.included(base)
base.class_eval do
alias_method_chain :session_options_with_string_keys, :subdomain_sessions
end
end
def session_options_with_string_keys_with_subdomain_sessions
@session_options[:session_domain] = "." + host;
@session_options_with_string_keys ||= ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.merge(@session_options).stringify_keys
@blech75
blech75 / gist:1503089
Created December 20, 2011 20:18
markdown and lists

i want to be able to do this:


# grocery list

* apples
* bananas
* strawberries
@blech75
blech75 / gist:1606529
Created January 13, 2012 14:37
Search iTMS for Current Song In Stream
(*
"Search iTMS for Current Song In Stream" for iTunes
written by Doug Adams
dougadams@mac.com
Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://www.malcolmadams.com/itunes/
Modified on 2012-01-12 by Justin Blecher <justin at worksperfectly dot net>
@blech75
blech75 / gist:1676673
Created January 25, 2012 15:05
why sending regexps via email is a bad idea
// client attempts to send a regexp in the body of an email message. it
// didn't work. the "file:///" was the telltale sign something was wrong.
//
// the irony here, of course, is that it's a regexp for validating email
// addresses. (and what a regexp it is!)
// pasted into email body in outlook (FAIL!)
REGEX_EMAIL = new RegExp("^([^()<>@,;:\\\\\".\\s\\x00-\\x1F\\x7F\\[\\]]+|\"([^\\\\\"\\x0D]|\\\\.)*\<file:///\\x0D]|\.)*\>")(\\.([^()<>@,;:\\\\\".\\s\\x00-\\x1F\\x7F\\[\\]]+|\"([^\\\\\"\\x0D]|\\\\.)*\"))*@([abcdefghijklmnopqrstuvwxyz0123456789]([-abcdefghijklmnopqrstuvwxyz0123456789]*[abcdefghijklmnopqrstuvwxyz0123456789])?)((\\.([abcdefghijklmnopqrstuvwxyz0123456789]([-abcdefghijklmnopqrstuvwxyz0123456789]*[abcdefghijklmnopqrstuvwxyz0123456789])?))*)(\\.([abcdefghijklmnopqrstuvwxyz0123456789]{2}|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|cat|jobs|mobi|tel|travel|xxx))$<file:///\\.([%5e()%3c%3e@,;:\%22.\s\x00-\x1F\x7F\%5b\%5d%5d+|\%22(%5b%5e\%22\x0D%5d|\.)*\%22))*@(%5babcdefghijkl
@blech75
blech75 / gist:2319809
Created April 6, 2012 13:32
firebug lite tar file does not have execute bits set on directories
[09:30 AM]-[1942]-[justin@justin]-[~]
$ wget http://getfirebug.com/releases/lite/latest/firebug-lite.tar.tgz
--2012-04-06 09:30:37-- http://getfirebug.com/releases/lite/latest/firebug-lite.tar.tgz
Resolving getfirebug.com (getfirebug.com)... 63.245.217.58
Connecting to getfirebug.com (getfirebug.com)|63.245.217.58|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2883190 (2.7M) [application/x-gzip]
Saving to: `firebug-lite.tar.tgz'
100%[==========================================================================================>] 2,883,190 685K/s in 4.3s
@blech75
blech75 / gist:3855684
Created October 8, 2012 23:52
cloudsites default mime types
# MIME type Extension
application/EDI-Consent
application/EDI-X12
application/EDIFACT
application/activemessage
application/andrew-inset ez
application/applefile
application/atomicmail
application/batch-SMTP
application/beep+xml