Skip to content

Instantly share code, notes, and snippets.

@yaph
yaph / dynamicjsongmap.js
Created January 21, 2012 16:19
Load JSON data and then dynamically load Google Maps API V3 to display a map using the data
$.getJSON('http://example.com/getjson, function(dataJSON) {
$.getScript('http://www.google.com/jsapi?key=API_KEY', function(data, textStatus){
function mapLoaded() {
var myOptions = {
center: new google.maps.LatLng(dataJSON.lat, dataJSON.long),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
}
@yaph
yaph / gist:1561397
Created January 4, 2012 18:40
prevent addition of PHPSESSID to links in .htaccess when user agents don't support cookies
php_value session.use_only_cookies 1
php_value session.use_trans_sid 0
@yaph
yaph / deliciousexport2list.js
Created November 26, 2011 22:55
Create an unordered list with only href anchor attributes from a Delicious bookmark export
var list = '';
$('dl dt').each(function(idx,elt){
var a = $(elt).find('a');
list += '<li><a href="' + a.attr('href') + '">' + a.text() + '</a></li>\n';
});
console.log('<ul>'+list+'</ul>');
@yaph
yaph / xdebug_profiler_htaccess
Created November 21, 2011 10:13
Enable the Xdebug profiler in .htaccess
php_value xdebug.profiler_enable 1
php_value xdebug.profiler_output_dir /tmp
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/rgomez/bin/eclipse
Name=Eclipse
Icon=/home/rgomez/app/eclipse/icon.xpm
@yaph
yaph / git_copy_changed.sh
Created July 7, 2011 20:31
copy changed files in git repo to target directory, paths are not retained
git diff --name-only | xargs -I {} cp {} /target_dir
@yaph
yaph / bundle install call
Created May 23, 2011 15:53
install ruby packages using bundler
sudo /var/lib/gems/1.8/bin/bundle install
@yaph
yaph / phpmyadmin file name template
Created March 8, 2011 15:40
File name template for phpMyAdmin with today's date and database name
%Y_%m_%d___DB__
@yaph
yaph / gist:825091
Created February 13, 2011 20:34
Generic .htaccess redirect from non-www to www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
@yaph
yaph / alexa keyword url
Created December 18, 2010 16:36
get a list of full URLs from Alexa Top 1M pages that match given keyword
grep -r keyword alexa_top-1m.csv | perl -pe 's/^d+,/http:\/\//'