Skip to content

Instantly share code, notes, and snippets.

@boxdot
boxdot / tmdb_scrape.py
Last active September 17, 2017 14:43
A movie information scraper in python for XBMC
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Usage: ./tmdb_scrape.py <movie title>
#
# A scraper à la MediaElch for XBMC.
#
# Searches for the given movie, retrieves the movie information from TMDb (only
# user ratings are retrieved from IMDb) and saves it to the .nfo file.
# Additionally a movie poster (best rated), a backdrop (also best rated) and
@boxdot
boxdot / zoom.html
Last active August 29, 2015 14:06
A working example of a graph, which can be zoomed/panned and also resized. Resizing does not change the scale of the graph but changes the viewport. Therefore domain and range of the axes should also be changed, which does not fully works with zoom behaviour of d3. The latter changes the corresponding scale, but changing the scales does not auto…
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Programmatic Change of Domain/Range and Zoom/Pan</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/black-tie/jquery-ui.css">
<style>
html, body {
margin: 1em;
}
@boxdot
boxdot / arte_tracks_video_fetcher
Last active August 29, 2015 14:06
A simple bash/python script to fetch video urls for Arte Tracks
#!/bin/bash
#
# settings
#
LANGUAGE=DE
#
# script
@boxdot
boxdot / flatten_map_reduce
Created September 10, 2014 13:00
MapReduce of MongoDB puts the result in `values` field. Sometimes one wants the result to be a document and not a pair `(_id, values)`. The function below flattens the result of map_reduce.
function(table) {
db[table].find().forEach(function(x) {
var update = { $set: {}, $unset: { value: '' } }
for (var k in x.value)
update.$set[k] = x.value[k]
db[table].update({_id: x._id}, update)
})
}
@boxdot
boxdot / index.html
Last active August 29, 2015 14:06
Bresenham's line algorithm
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
shape-rendering: crispEdges;
}
.grid line {
stroke: #DEDEDE;
@boxdot
boxdot / 4pl.py
Created September 29, 2014 08:31
Generates a m3u playlist from the 4players video newsfeed. Already processed videos are cached. New videos are labeled with "NEW" prefix.
#!/usr/bin/env python
import feedparser, re, urllib2, os, sys
CACHEDIR = os.path.join(os.path.split(os.path.realpath(__file__))[0], 'cache')
VIDEOFEEDURL = 'http://feeds.4players.de/Allgemein/videos/-/rss.xml'
def formatted(s):
return re.sub(u'[^\w]+', u'-', s.strip(), 0, re.UNICODE).lower()
print '#EXTM3U'
import Html exposing (..)
import Html.Attributes exposing (..)
import Time
currentTime : Signal Time.Time
currentTime = Time.every Time.second
main = Signal.map2
(\time ls ->
@boxdot
boxdot / Random.elm
Last active August 29, 2015 14:25
Using Elm architecture and setting random seed.
import Time
import Random
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
-- MODEL
import Char
import Html exposing (..)
import Html.Attributes exposing (..)
chars : Char -> Char -> List Char
chars x y =
let
a = Char.toCode x
b = Char.toCode y
nums = [a .. b]
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import StartApp
-- MODEL
type alias Image =
{ title : String