Skip to content

Instantly share code, notes, and snippets.

@yaph
yaph / gist:134894
Created June 23, 2009 22:33
create a query string from a dictionary (pquery) as returned from cgi.parse_qs / urlparse.parse_qs when urllib.urlencode is not appropriate
# create a query string from a dictionary (pquery) as returned from
# cgi.parse_qs / urlparse.parse_qs when urllib.urlencode is not appropriate
query_string = '&'.join(
'='.join([key, pquery[key][0]]) for key in pquery
)
@yaph
yaph / jQueryfy Bookmarklet
Created May 14, 2010 14:10
jQueryfy Bookmarklet
javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://code.jquery.com/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);alert('thank%20you%20for%20using%20jquery!');void(s);
@yaph
yaph / Generic .htaccess redirect from www to non-www
Created August 6, 2010 09:08
Generic .htaccess redirect from www to non-www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$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:\/\//'
@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 / 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 / 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 / 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
[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 / 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