Skip to content

Instantly share code, notes, and snippets.

View liesen's full-sized avatar

liesen

  • I'm just exploring, really
  • Stockholm, Sweden
View GitHub Profile
with open('gymnastics.in', 'r') as fin:
K, N = map(int, fin.readline().split())
P = {k: {int(n): i for i, n in enumerate(fin.readline().split())}
for k in range(K)}
ans = 0
for n1 in range(1, N + 1):
for n2 in range(1, N + 1):
if n1 == n2:
@liesen
liesen / marklovejoydotcom.py
Created August 9, 2019 17:54
Find a particular post from marklovejoydotcom.tumblr.com
import requests
import xmltodict
def find_post_by_photo_url(photo_url, start=0, num=50):
total = start + 1
while start < total:
r = requests.get('https://marklovejoydotcom.tumblr.com/api/read', params={'start': start, 'num': num})
r.raise_for_status()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@liesen
liesen / recursion-schemes.ipynb
Created November 28, 2014 15:06
Recursion schemes, Stockholm Haskell User Group, 2014-11-27
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@liesen
liesen / äkta-människor.md
Last active February 28, 2021 19:09
ÄKTA MÄNNISKOR, DAVID EISCHERS KOD
@liesen
liesen / README.md
Last active December 24, 2015 22:39 — forked from mbostock/.block
@liesen
liesen / gist:1433041
Created December 5, 2011 09:40
Count number of tracks in playlists
_ = sp.require('underscore');
sp.core.library.getTracks().length
// Versus:
// Total number of tracks in "library" = all playlists
_.reduce(sp.core.library.getPlaylists(), function (a, x) { return a + _.reject(_.map(_.range(x.length || 0), function (i) { return x.getTrack(i); }), function (t) { return t.isLocal || t.isAd || t.isPlaceholder || !t.availableForPlayback; }).length; }, 0)
// Number of unique tracks (unique track URIs)
@liesen
liesen / SpotifyViewsDemo.html
Created December 1, 2011 16:38
Spotify Apps API example
<!DOCTYPE html>
<html>
<head>
<title>API</title>
<link rel="stylesheet" href="sp://import/css/adam.css">
<style>
body {
-webkit-box-orient: vertical;
display: -webkit-box;
import qualified Data.Map as M
import Data.List (find)
import Data.Maybe (fromMaybe)
firstNonRep :: String -> Maybe Char
firstNonRep xs = let m = M.fromListWith (+) . map (\c -> (c,1)) $ xs
lookup = flip (M.findWithDefault 0) m
in find ((== 1) . lookup) xs
main = print $ case firstNonRep "faabcbcdee" of
@liesen
liesen / electric-fence.patch
Created January 28, 2011 21:14
Patch to get libefence to build on OS X
diff --git a/page.c b/page.c
index 07ac9d5..69374c4 100644
--- a/page.c
+++ b/page.c
@@ -30,7 +30,7 @@
static caddr_t startAddr = (caddr_t) 0;
#if ( !defined(sgi) && !defined(_AIX) )
-extern int sys_nerr;
+/*extern int sys_nerr;*/