Skip to content

Instantly share code, notes, and snippets.

@ispedals
ispedals / video-thumbnail-display.html
Created May 20, 2013 16:19
Experiment creating thumbnails of MP4 videos using the HTML5 Filereader API. Currently, the loading of videos in rapid succession fails with a decoding error, and if too many videos are processed concurrently, the display driver crashes.
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery.js"></script>
<script src="https://rawgithub.com/caolan/async/master/lib/async.js"></script>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script>
window.URL = window.URL || window.webkitURL;
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>JSONP Test</title>
<script>
function foo(data) {
document.getElementsByTagName('body')[0].innerHTML=JSON.stringify(data);
}
@ispedals
ispedals / subtitle-marker.pl
Created May 20, 2013 18:06
Marks a subtitle file using pseduo-bookmarks generated from timestamped screenshots for further review
#!perl
use v5.12;
use warnings;
use Subtitles::ASS::File;
use Subtitles::SRT::File;
use Subtitles::Time;
use List::Util 'first';
use utf8::all;
use autodie;
@ispedals
ispedals / gist:5614951
Created May 20, 2013 19:50
How to export just the files in a git repository
git checkout-index -a -f --prefix=/Users/Owner/Desktop/app/
@ispedals
ispedals / gist:5614958
Created May 20, 2013 19:51
youtube-dl.py command for downloading videos with output templating
python youtube-dl.py -v -f 18 -o "/Users/Owner/desktop/d/%(uploader)s/%(id)s_%(upload_date)s"
@ispedals
ispedals / filepicker.js
Created May 20, 2013 20:46
Example addon showing how to call the filepicker on Firefox for Android
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
function log(str) { Services.console.logStringMessage(str); }
function showToast(aWindow, message) { aWindow.NativeWindow.toast.show(message, "short"); }
var g;
@ispedals
ispedals / server.py
Created May 20, 2013 20:48
Example using BaseHTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from urllib import unquote
b=[]
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
if not self.path in b:
f.write('<li><a href=%s>%s</a></li>\r\n'%(unquote(self.path)[1:],unquote(self.path)[1:]))
b.append(self.path)
print self.path
@ispedals
ispedals / test-xml.pl
Created May 20, 2013 20:53
Compare performance of Mojo::DOM and XML::Smart
#!perl
use v5.16;
use utf8;
use XML::Smart;
use Mojo::DOM;
use Benchmark qw( timethese cmpthese );
my $xml = <<'EOF';
<?xml version='1.0' encoding='UTF-8'?><feed gd:etag="W/&quot;A0ACRHgyfyp7I2A9WhNQGUo.&quot;" xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:gd="http://schemas.google.com/g/2005" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:yt="http://gdata.youtube.com/schemas/2007"><id>tag:youtube.com,2008:user:chemicalsreact14:uploads</id><updated>2012-11-27T01:29:25.697Z</updated><category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /><title>Uploads by chemicalsreact14</title><logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo><link href="http://gdata.youtube.com/feeds/api/users/chemicalsreact14?v=2" rel="related" type="application/atom+xml" /><link href="http://www.youtube.com/channel/UC6PnMX0ZSS4hnqGRmByH4gA/videos" rel="alternate" type="text/ht
@ispedals
ispedals / youtube-video-explorer.pl
Created May 20, 2013 21:05
Mojolicious::Lite app that explores a youtube video by both displaying both the author's video and related videos recursively
#perl
use v5.16;
use warnings;
use XML::Smart;
use Mojolicious::Lite;
my %videos; #videos to be saved; structured <id:[title, author_url, id, duration, [thumbnails]]>
my %seen; #videos that have been seen and either saved or rejected; keys are video ids
my %authors; #authors whose uploads have been seen; keys are author urls
@ispedals
ispedals / mecab.reading.py
Created May 20, 2013 21:11
Example using reading.mecab from Anki
# -*- coding: utf-8 -*-
from reading import mecab
from codecs import open
print mecab.reading(u'もう 冗談言わないでよ').encode('utf8')