Skip to content

Instantly share code, notes, and snippets.

! Rules to limit FB tracking of me and doing various "scary" things.
! Read more: http://nikcub.appspot.com/logging-out-of-facebook-is-not-enough
!
! The filters live on the Customize tab of AdBlock Options in Chrome.
@@http://envoy510.blogspot.com/$document
@@||www.blogger.com^$document
@@|http://www.peteralfonso.com/2011/02/download-stock-rooted-gingerbread.html|$document
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function(){
@jhaus
jhaus / uri.js
Created May 7, 2012 20:09 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jhaus
jhaus / gdocs-audio-player-bookmarklet.js
Created January 4, 2012 22:13
Google Docs Audio Player. Prefix with "javascript:" when adding to bookmarks. Bookmarklet broken as of 2010.01.04.
function gup( name ){
var cre_getDocIdelement = document.getElementById( 'gbmpm_0_l' );
name = name.replace( /[\[]/,"\\\[" ).replace( /[\]]/,"\\\]" );
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( cre_getDocIdelement );
if( results == null ) return "";
[["-1","Google","http://www.google.com/search?q=TESTSEARCH",true],
["-1","Gmail+Docs","https://mail.google.com/mail/ca/u/0/#apps/TESTSEARCH",true],
["-1","Google Docs","https://docs.google.com/?tab=mo&authuser=0#search/TESTSEARCH",false],
["-1","Google Reader","http://www.google.com/reader/view/#search/TESTSEARCH/",false],
["-1","YouTube","http://www.youtube.com/results?search_query=TESTSEARCH",true],
["-1","Google Images","http://www.google.com/images?q=TESTSEARCH",true],
["-1","Wikipedia","http://en.wikipedia.org/w/index.php?title=Special:Search&search=TESTSEARCH",true],
["-1","Amazon","http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=TESTSEARCH&tag=carolynmonroe-20",true],
["-1","Google Play Store","https://play.google.com/store/search?q=TESTSEARCH",true],
["-1","Google Music","https://play.google.com/music/listen#TESTSEARCH_sr",true],
@jhaus
jhaus / .htaccess
Created November 22, 2011 09:16
Simple Apache rewrite for index.html to the root url. Source/discussion: http://www.webmasterworld.com/google/3105248.htm
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*\/index\.html?
RewriteRule ^(.*)index\.html?$ http://example.com$1 [R=301,L]
# More resources:
#
# http://old.justinshattuck.com/2007/01/19/apache-mod_rewrite-cheat-sheet/
# http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/
@jhaus
jhaus / .htaccess
Created March 21, 2011 21:55
Apache mod_rewrite parameters for local wordpress HTaccess file on XAMPP - otherwise, may redirect to 404 page
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /path/to/front/of/site/under/root/directory/local_example_com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /path/to/front/of/site/under/root/directory/local_example_com/index.php [L]
</IfModule>
<div id="feedbackGadget" style="left: 359px; top: 20px; visibility: hidden; display: none; " class="gn-gaiabar-gadget">
<div id="feedbackIframe">
<iframe id="feedbackIframeId" name="feedbackIframeId" class="gn-gaiabar-iframe" src="https://spreadsheets.google.com/embeddedform?key=pPo2nzr1TywUz6Kp4cvV6NA&amp;hl=en&amp;gridId=0" frameborder="0" style="height: 320px; width: 480px;">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Feedback</title>
<?php
$url = "http://icanhascheezburger.com";
$html = file_get_contents($url);
$dom = new DomDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$img = $xpath->evaluate("//div[@class='entry']//img")->item(0);
$imgSrc = $img->getAttribute('src');
print("<img src=\"$imgSrc\" />");
@jhaus
jhaus / google-weather-api.php
Created January 4, 2011 23:05
Prints current + 3 day weather forecast - via: googleapihelp.com (slightly modified)
<?php
$weather_loc = 10001;
function getWeather( $weather_loc ) {
// weather data url, location based
$requestAddress = 'http://www.google.com/ig/api?weather=$weather_loc&hl=en';
// Parse XML
$xml_str = file_get_contents($requestAddress,0);