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
#import <Cocoa/Cocoa.h>
#import <AppKit/NSAccessibility.h>
static CFStringRef kSpotlightBundleIdentifier = CFSTR("com.apple.spotlight");
static void SpotlightCallback(AXObserverRef observer,
AXUIElementRef element,
CFStringRef notification,
@liesen
liesen / äkta-människor.md
Last active February 28, 2021 19:09
ÄKTA MÄNNISKOR, DAVID EISCHERS KOD
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()
@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;*/
@liesen
liesen / patch1.patch
Created November 8, 2010 17:22
CGAL bugs: Sweep line algorithm does not respect the report_endpoints argument
--- CGAL/Sweep_line_2/Sweep_line_2_visitors.h 2010-11-08 18:45:53.000000000 +0100
+++ /Users/liesen/crap/Sweep_line_2_visitors.h 2010-11-08 18:45:45.000000000 +0100
@@ -99,9 +99,7 @@
Status_line_iterator /* iter */,
bool /* flag */)
{
- if ((m_includeEndPoints ||
- event->is_intersection() ||
- event->is_weak_intersection()) && event->is_closed())
+ if ((event->is_intersection() || (event->is_weak_intersection() && m_includeEndPoints)) && event->is_closed())