Skip to content

Instantly share code, notes, and snippets.

// TiddlyWiki 5 code from Jeremy Ruston
// Gives you a jQuery object that you can set width and height on, just as if it was an IMG tag.
var svgDoc = new DOMParser().parseFromString(svgText,
"application/xml").documentElement;
fixSVG(svgDoc.childNodes,generateIdPrefix());
img = $(document.importNode(svgDoc, true));
function yoink(complete) {
var all={
scripts: [],
stylesheets: []
}
function downloadResources(urls, onComplete) {
var resources = [];
#!/usr/bin/env python
# Quick edit of FND's http://github.com/FND/tiddlywebadmin/blob/master/spa.py
# mahemoff - added support for remote resources and uglied up RegExps to make them a # bit more general
"""
single-page app compiler
uses references to local JavaScript and CSS files and bakes their code into an
HTML5 document
<!-- This is a Node+WebSocket powered demo to sync videos
across different browsers. This file is the client,
the other one is the Node server. Powered by Node and
http://github.com/miksago/node-websocket-server -->
<style>
.inactive { display: none; }
.active { display: block; }
</style>
<script>
*** JS ***
var $twitbox = $("<div class='twitbox'/>")
.html("<div>Loading</div>")
.appendTo("#main-table .nav");
var url = "http://twitter.com/status/user_timeline/techmeme.json?count=10&callback=?";
$.getJSON(url, function(tweets) {
$twitbox.empty();
$("<h3/>").html("@techmeme says").appendTo($twitbox);
$.each(tweets, function(i, tweet) {
@mahemoff
mahemoff / Web Store Featured Apps
Created February 1, 2011 17:01
Quick GM script to extract CSV of featured apps on Chrome Web Store (GM because Chrome extensions are disabled on Web Store for security reasons). Need to visit each Featured page, hit Extract to append all apps, and show will log them to console.
var pen = new Graphics(); // I find "graphics" vague, so I call it pen!
stage = new Stage(canvas); // the display
pen.setStrokeStyle(1).drawCircle(0,0,RADIUS); // not really drawn yet
circle = new Shape(g); /* AHA now we have an object for the thing we haven't yet really drawn
stage.addChild(circle); // Now it's drawn
// later on, we see the benefits of this cunning display
circle.x += 8; //
stage.update();
var pen = new Graphics(); // I find "graphics" vague, so I call it pen!
stage = new Stage(canvas); // the display
pen.setStrokeStyle(1).drawCircle(0,0,RADIUS); // not really drawn yet
circle = new Shape(g); /* AHA now we have an object for the thing we haven't yet really drawn */
stage.addChild(circle); // Now it's drawn
// later on, we see the benefits of this cunning display
circle.x += 8; //
stage.update();
@mahemoff
mahemoff / suck.rb
Created June 2, 2011 15:09
replace image urls with images
#!/usr/bin/env ruby
# suck.rb index.html will build a local.index.html with all images offline
require 'httpclient'
### UTILITIES
Dir.mkdir('images') unless File.directory?('images')
def imagepath(url)
'images/' + url.sub('http://','').gsub('/','__')
end
@mahemoff
mahemoff / gist:1103969
Created July 25, 2011 11:53
Canvas-to-Canvas copy (jQuery+Kaffeine)
$.fn.copyTo = (target) -> {
src = $(this)[0]
$(target).each( () -> {
@.getContext("2d").drawImage(src,
0, 0, src.width, src.height,
0, 0, @.width, @.height
)
})
}