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
@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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#import <Cocoa/Cocoa.h>
#import <AppKit/NSAccessibility.h>
static CFStringRef kSpotlightBundleIdentifier = CFSTR("com.apple.spotlight");
static void SpotlightCallback(AXObserverRef observer,
AXUIElementRef element,
CFStringRef notification,
/* Cocoa accessibility framework for intercepting Spotlight user input. */
#import <Cocoa/Cocoa.h>
#import <AppKit/NSAccessibility.h>
static void searchFieldCallback(AXObserverRef observer,
AXUIElementRef element,
CFStringRef notification,
void *data) {
CFTypeRef subrole, value;
// Bush in Scala
package tests
object Bush {
def main(args : Array[String]) : Unit = {
val states = "Alabama\nAlaska\nArizona\nArkansas\nCalifornia\nColorado\nConnecticut\nDelaware\nFlorida\nGeorgia\nHawaii\nIdaho\nIllinois\nIndiana\nIowa\nKansas\nKentucky\nLouisiana\nMaine\nMaryland\nMassachusetts\nMichigan\nMinnesota\nMississippi\nMissouri\nMontana\nNebraska\nNevada\nNew Hampshire\nNew Jersey\nNew Mexico\nNew York\nNorth Carolina\nNorth Dakota\nOhio\nOklahoma\nOregon\nPennsylvania\nRhode Island\nSouth Carolina\nSouth Dakota\nTennessee\nTexas\nUtah\nVermont\nVirginia\nWashington\nWest Virginia\nWisconsin\nWyoming".lines
val georgewbush = Set.empty ++ "georgewbush"
printf("It's sweet home %s!%n", (states find { state => !(state.toLowerCase exists { georgewbush contains _ }) }).get)
}
// http://stackoverflow.com/questions/1376077/code-golf-the-wave
object Wave {
def main(args: Array[String]) {
val s = if (!args.isEmpty) args(0) else "31415926535897932384626433832795028841971693993751058209749445923078164062862"
val (ls, _) = ((Map() + 0 -> s.substring(0, 1), 0) /: s.toList.zipWithIndex.tail) {
case ((ls, y), (c, i)) =>
val d = y + (c compare s(i - 1))
((ls + d -> (ls.getOrElse(d, "") match { case z => z + (" " * (i - z.length)) + c })), d)
}
#import <Cocoa/Cocoa.h>
#import <AppKit/NSAccessibility.h>
static CFStringRef kSpotlightBundleIdentifier = CFSTR("com.apple.systemuiserver");
static void SpotlightCallback(AXObserverRef observer,
AXUIElementRef element,
CFStringRef notification,
@liesen
liesen / node-spotify-external.js
Created July 13, 2010 18:10
draft of a js api for libspotify
/**
* @namespace
*/
spotify = {};
/**
* @enum {number}
*/
spotify.Error = {
body {
background-color: #000 !important;
}
#statusBar {
background-color: #224 !important;
border-color: #336 !important;
}
#buffers li.server {
@liesen
liesen / test2.cpp
Created November 8, 2010 17:25
CGAL bugs: Sweep line algorithm does not report intersection, x, between two segments if another segment has an end point equal to x
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Gmpq.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Sweep_line_2_algorithms.h>
#include <list>
#include <set>
typedef CGAL::Gmpq NT;
typedef CGAL::Simple_cartesian<NT> Kernel;