This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script src="underscore.js"></script> | |
<script type="text/javascript"> | |
function time(s, f) { | |
start = new Date(); | |
f(); | |
end = new Date(); | |
$("#speedtest").append(s + ": " + String(end - start) + " ms<br />"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// underscore-pickrandom.js | |
// (c) 2012 Simon Kågedal Reimer | |
// This file is freely distributable under the MIT license. | |
// _.pickRandom - a mixin for underscore.js. | |
// | |
// Pick random elements from an array. Works similar to | |
// `_.first(_.shuffle(array, n))`, but is more efficient -- operates | |
// in time proportional to `n` rather than the length of the whole | |
// array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to solve a wooden 3D puzzle thing someone got for christmas. | |
# Two-colored tiles should be placed in layers so that no color appears twice | |
# in each layer or in each column. | |
# | |
# Outputs: | |
#We have a solution! | |
# Pink ,Red Orange,Yellow Grey ,Green | |
#Blue ,Yellow Pink ,Green Grey ,Orange | |
# Blue ,Grey Pink ,Orange Green ,Red | |
#Orange,Red Yellow,Grey Pink ,Blue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
"""From https://bugzilla.gnome.org/show_bug.cgi?id=631901#c7 but with | |
some bug fixes. Should print message objects, but on GStreamer 0.10, | |
just prints None.""" | |
from gi.repository import GObject | |
GObject.threads_init() | |
from gi.repository import Gst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* With Vala 0.20.1 from Ubuntu PPA, this gives no errors or warnings on "vala test.vala -C", | |
* but gives C code that doesn't compile: | |
/home/simon/bug.vala.c: In function ‘_vala_main’: | |
/home/simon/bug.vala.c:76:2: error: initializer element is not constant | |
/home/simon/bug.vala.c:76:2: error: (near initialization for ‘foos[0].s’) | |
*/ | |
struct Foo { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# mmongo: An alternative to "meteor mongo" that lets you pass any | |
# arguments to mongo after the -- argument, as in: | |
# mmongo myapp.meteor.com -- myfile.js | |
# | |
# I rewrote this with more features in JavaScript with Node.js: | |
# https://github.com/skagedal/mmongo | |
require 'uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# See http://stackoverflow.com/questions/30759598/how-does-uilabel-vertically-center-its-text/30910504#30910504 | |
# | |
import re | |
import matplotlib.pyplot as pyplot | |
input = open("trace-output.txt").read() | |
entries = input.split("=====") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.request import urlopen | |
counter = 1 | |
while True: | |
url = 'http://libris.kb.se/xsearch?d=swepub&hitlist&q=l%C3%A4ros%C3%A4te%3agu&f=ext&spell=true&hist=true&n=200&start=' + str(counter) | |
print ("Fetching: " + url) | |
data = urlopen(url).read() | |
if not data.find(b"<record>") >= 0: | |
print("No more records!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import re | |
from os import listdir | |
def fix_escapes(string): | |
# Libris over-escapes some backslashes. | |
string = string.replace("\\\\\"","\\\"") | |
# Libris fails to properly escape backslashes in strings, which occurs for example with inline | |
# LaTeX codes like "$\geq" which should be escaped as "$\\geq". They do seem to properly | |
# escape quote chars, however. Now, we can't easily know whethera string liike "\n" should be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.request import urlopen | |
counter = 1 | |
while True: | |
url = 'http://libris.kb.se/xsearch?d=swepub&hitlist&q=l%C3%A4ros%C3%A4te%3agu&f=ext&spell=true&hist=true&n=200&format=json&start=' + str(counter) | |
print ("Fetching: " + url) | |
data = urlopen(url).read() | |
if not data.find(b'"identifier"') >= 0: | |
print("No more records!") |
OlderNewer