Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / escapeHTML.js
Created January 21, 2012 19:37
Fast HTML tag escape JavaScript function
// see benchmark at http://jsperf.com/encode-html-entities
String.prototype.escapeHTML = function(){
var div = document.createElement('div');
div.appendChild(document.createTextNode(this));
return div.innerHTML;
};
@yaph
yaph / eulerproblem1.py
Created January 30, 2012 21:42
Project Euler: problem 1
sum([i for i in range(1000) if (i%3==0 or i%5==0)])
@yaph
yaph / HTML5 Skeleton template.html
Created April 10, 2012 23:27 — forked from rtuin/HTML5 Skeleton template.html
HTML5 skeleton template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
@yaph
yaph / gource_video.sh
Created April 13, 2012 17:46
create a portable pixmap file and then a mp4 file with gource, ppm files may get very very large
gource -1280x720 -o gource.ppm
ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i gource.ppm -vcodec libx264 -vpre ultrafast -crf 1 -threads 0 -bf 0 gource.mp4
@yaph
yaph / gource_video_480p60.sh
Created April 13, 2012 18:36
create a 480p video with 60 frames/s and max time scale with gource
gource --auto-skip-seconds 1 --seconds-per-day 1 --time-scale 4 -640x480 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre ultrafast -crf 1 -threads 0 -bf 0 gource_480p60.mp4
@yaph
yaph / README.md
Created May 11, 2012 21:06
GitHub Language Correlations Circle Pack Visualization

README

View this Gist at bl.ocks.org

A circle packing visualization of the programming language correlations dataset, that is available via Google's BigQuery service as part of the GitHub Archive project.

Included are the 10 most popular programming languages on GitHub at the time of creation (JavaScript, Ruby, Python, Shell, Java, PHP, C, Perl, C++, Objective-C) and their correlated languages with a minimum correlation score of 10. Read more about how correlation scores are calculated.

On the demo page move the mouse pointer over the big containing circles to see the name of the source languages and over the smaller contained circles to see the rounded correlation values.

@yaph
yaph / README.md
Created May 18, 2012 22:23
Map of GitHub Commits

README

A geographic map that displays GitHub commits by countries. To view the map and information on how it was created see this article.

You can also view this gist at bl.ocks.org. If you fork it and apply changes you can see them live at bl.ocks.org/YOUR_GIST_ID.