Skip to content

Instantly share code, notes, and snippets.

@ispedals
ispedals / boostrap.js
Last active August 29, 2015 14:11
Example using JNI.jsm to create a card for Ankidroid in Firefox for Android
"use strict";
//JNI.jsm introduced requires Firefox for Android 34
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "JNI", function() {
let scope = {};
@ispedals
ispedals / gist:335c3cae4f4236b10bcd
Created October 12, 2014 17:23
Stream url from livestream
livestreamer -a "- --sout '#http{{mux=ffmpeg{{mux=flv}},dst=:8080/toon}}'" vaughnlive.tv/toonamiest best
@ispedals
ispedals / gist:5846591
Created June 23, 2013 21:25
Addon SDK usage

#Addon SDK usage

##Add widget to addon bar

require('sdk/widget').Widget({
    id: '...',
label: '...', //context label
	content: '...', //text label
	width: 100,

onClick: function() {

@ispedals
ispedals / gist:5846577
Created June 23, 2013 21:17
To remove files from git history after they have been already committed
1. Note that the files will be deleted from the file system as well as from the history, so make a backup of the repository before preceeding and any files that you want then leave untracked in the repository
2. Get a list of tracked files in a tree and save to file (do for each branch)
git ls-tree --full-tree --name-only -r HEAD >> files.txt
3. Review the list of files and remove the files that you want to keep. This is also a good time to edit your .gitignore file so that the files remain untracked if they are added again.
4. Get a list of deleted files in a repository and add the unwanted files to the list of files
git log --diff-filter=D --summary
@ispedals
ispedals / timedtext-to-srt.pl
Created May 20, 2013 22:04
Converts Timed Text subtitles to SRT format
#!perl
use v5.16;
use warnings;
use Subtitles::SRT::File;
use HTML::Entities;
use XML::Simple;
my $srt=Subtitles::SRT::File->new;
my $xml=XMLin shift;
@ispedals
ispedals / SVN delete.bat
Created May 20, 2013 22:03
Deletes .svn files
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"
Perl
+----------------------------------------------------------------+
| Determine memory load |
|----------------------------------------------------------------|
| use Win32::SystemInfo; |
| my %status; |
| Win32::SystemInfo::MemoryStatus(%status); |
| if($status{'MemLoad'} > 90) { |
| … |
| } |
@ispedals
ispedals / Signal-Strength.py
Created May 20, 2013 22:01
XBMC for Xbox script for reading the signal strength of the wireless bridge
import re, urllib, xbmcgui
f = urllib.urlopen("http://admin:password@192.168.0.201/status.htm")
data=f.read()
f.close()
try:
strength=re.search('<td width="10%">(\d+%)<\/td>',data).group(1)
dialog = xbmcgui.Dialog()
ok = dialog.ok('Signal Strength', 'Signal Strength: %s'%strength)
except AttributeError:
@ispedals
ispedals / Vocab-Trainer.html
Created May 20, 2013 22:00
Single page app for learning vocabulary
<!DOCTYPE html>
<html>
<head>
<script>
(function(a,b){function cg(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cd(a){if(!bZ[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bZ[a]=c}return bZ[a]}function cc(a,b){var c={};d.each(cb.concat.apply([],cb.slice(0,b)),function(){c[this]=a});return c}function bY(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function bX(){try{return new a.XMLHttpRequest}catch(b){}}function bW(){d(a).unload(function(){for(var a in bU)bU[a](0,1)})}function bQ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f={},g,h,i=e.length,j,k=e[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h==="string"&&(f[h.toLowerCase()]=a.converters[h]);l=k,k=e[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=f[m]||f["* "+k];if(!n){p=b;for(o in f){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=f[j[1]+" "+k];if(p){o=f[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&d.e
@ispedals
ispedals / rubier.bas
Created May 20, 2013 21:59
Converts Aozora Bunko rubi format to Microsoft Word formatted phonetic guide
Sub rubier()
Dim pattern As String
Dim text As String
Dim parts() As String
Dim kana As String
Dim kanji As String
'pattern = [U+4E00-U+9FFF]{1,}U+12298?*U+12299
'pattern = \p{InCJK_Unified_Ideographs}{1,}\N{left double angle bracket}?*\N{right double angle bracket}
pattern = "[" & ChrW(19968) & "-" & ChrW(40959) & "]{1,}" & ChrW(12298) & "?*" & ChrW(12299)