Skip to content

Instantly share code, notes, and snippets.

@ispedals
ispedals / gist:5615916
Created May 20, 2013 21:58
API to play video url
"http://"+xboxIP+"/xbmcCmds/xbmcHttp?command=playfile&parameter="+mediaUrls
@ispedals
ispedals / galleryview.pl
Created May 20, 2013 21:56
Perl script that goes through a directory of images and creates a single page gallery web page. The images can be embedded by base64 encoding them or they can just be linked.
#!perl
use v5.10;
use MIME::Base64;
my $EMBED;
my $fir=q{prunus\\};
$fir =~ s/\\/\\\\/g;
my $dir= $EMBED? '': "'file:///$fir' +";
@ispedals
ispedals / duplicate-addon.py
Created May 20, 2013 21:54
Anki addon for finding duplicates, with special criteria
from aqt import mw
from aqt.utils import showInfo
from aqt.qt import *
import re
def strictDuplicate():
all_words=dict()
for id in mw.col.findNotes("deck:Japanese::Vocabulary"):
note=mw.col.getNote(id)
word=note.fields[0]
@ispedals
ispedals / duplicates-finder.py
Created May 20, 2013 21:53
Script to find duplicate notes in an Anki collection. Some special-casing for certain criteria.
from codecs import open
from collections import defaultdict
import re
"""
To use, export decks so that
Core2k: core2k.txt
Core6k: core6k.txt
Vocabulary (including both user-generated; CorePlus; and Core2-6K): out.txt
Before export, tag non-leech suspended notes with "rololo"
@ispedals
ispedals / dailymotionresolver.py
Created May 20, 2013 21:51
Resolves dailymotion video urls
import urllib2
import re
uid='xv3f6f'
f = urllib2.urlopen('http://www.dailymotion.com/embed/video/%s' % uid).read()
url=re.findall('"stream_h264_url":"(.*?)",', f, re.DOTALL)
resolved_url=url[0].replace('\\','')
print resolved_url
@ispedals
ispedals / copysubs.py
Created May 20, 2013 21:50
Copies the currently playing subtitle in XBMC for Xbox
import xbmc
import shutil
ass_subtitle='special://temp/%s' % xbmc.Player().getSubtitles()
shutil.copy(ass_subtitle, 'Q:\\scripts\\')
@ispedals
ispedals / charname.pl
Created May 20, 2013 21:49
Display the character name of farsi letters in a sentence
#!perl
use v5.12;
use strict;
use warnings;
use utf8;
use Unicode::UCD 'charinfo';
my $SENTENCE = '';
@ispedals
ispedals / ftpproxy.py
Created May 20, 2013 21:46
A HTTP server that proxies GET requests to a FTP server
"""
A HTTP server that proxies GET requests to a FTP server
"""
import ftplib
from mimetypes import guess_type
import BaseHTTPServer
from urllib2 import unquote
from optparse import OptionParser
@ispedals
ispedals / ftppicker.py
Created May 20, 2013 21:45
Recursivly traverses a FTP directory, picking a random user-given number of files and outputting them in the format {image: http://<filename>}
"""
Recursivly traverses a FTP directory, picking a random user-given number of files and outputting them in the format
{image: http://<filename>}
"""
import ftplib
import random
from optparse import OptionParser
def traverse(ftp, depth=0):
"""
@ispedals
ispedals / gist:5615827
Created May 20, 2013 21:44
Converts the currently set .ass subtitle to .srt and sets it as the subtitle for the current video in XBMC for Xbox
"""
ass2srt.py
Converts the currently set .ass subtitle to .srt and sets it as the subtitle for the current video
"""
import re
import xbmc
from os.path import basename, splitext
from datetime import time
import traceback
import codecs