Skip to content

Instantly share code, notes, and snippets.

View sander's full-sized avatar

Sander Dijkhuis sander

View GitHub Profile
// Catch errors early
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace EithersAndOptionals
{
struct Either<T1, T2> where T1 : class where T2 : class
@sander
sander / errors.txt
Created February 25, 2016 17:20
Emacs errors
Warning (emacs): Unable to activate package `with-editor'.
Required package `dash-2.11.0' is unavailable
Warning (emacs): Unable to activate package `solarized-theme'.
Required package `dash-2.6.0' is unavailable
Warning (emacs): Unable to activate package `magit-popup'.
Required package `dash-2.11.0' is unavailable
Warning (emacs): Unable to activate package `magit'.
Required package `dash-2.11.0' is unavailable
Warning (emacs): Unable to activate package `git-commit'.
Required package `dash-2.11.0' is unavailable
(println "loading deps")
(require
'[cljs.build.api :as build])
(defn release []
(build/build
"src"
{:main 'fmp.core
:output-to "release/release.js"
@sander
sander / dl.js
Created December 8, 2015 09:15
Download pins from a Pinboard board
var size = '474x'; // alts: 60x60, 236x, 736x, orig
var n = 0;
var result = $('.BoardPage .Pin').map(function (_, it) {
var url = $(it).find('.pinHolder > a').attr('href');
return {
desc: $(it).find('.pinDescription').text().trim(),
url: url,
id: +url.split('/')[2],
n: n++
};
@sander
sander / async-error.txt
Created December 1, 2015 12:14
async error
/Users/sander/Code/fmp/out/cljs/core.cljs:261
(js/Error.
^
Error: No protocol method ReadPort.take! defined for type null:
at cljs$core$missing_protocol (/Users/sander/Code/fmp/out/cljs/core.cljs:261:4)
at cljs$core$async$impl$protocols$take_BANG_ (/Users/sander/Code/fmp/out/cljs/core/async/impl/protocols.js:27:34)
at cljs$core$async$impl$ioc_helpers$take_BANG_ (/Users/sander/Code/fmp/out/cljs/core/async/impl/ioc_helpers.js:103:68)
at /Users/sander/Code/fmp/out/cljs/core/async.js:783:52
at /Users/sander/Code/fmp/out/cljs/core/async.js:888:51
at cljs.core.async.pipe.cljs$core$IFn$_invoke$arity$3.cljs.core.async.impl.dispatch.run.call.cljs$core$async$state_machine__18606__auto____1 (/Users/sander/Code/fmp/out/cljs/core/async.js:909:4)
(defn- before [begin]
(fn [{:keys [time]}]
(<= time begin)))
(defn- weighted [weigh now ival]
(fn [{:keys [time] :as entry}]
(assoc entry :weight (weigh (- 1 (/ (- now time) ival))))))
(defn- pop-while [pred queue]
(loop [q queue]
(if (and (not (empty? q))
(pred (peek q)))
(ns om-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(enable-console-print!)
(def init-data
{:current-user {:email "bob.smith@gmail.com"}
:items [{:id 0 :title "Foo"}
@sander
sander / dev.clj
Created November 26, 2015 08:47
figwheel question
(println "loading deps")
(require
'[figwheel-sidecar.system :as sys]
'[com.stuartsierra.component :as component]
'[cljs.build.api :as build])
(def system
(sys/create-figwheel-system (sys/fetch-config)))
@sander
sander / README.md
Last active November 3, 2015 16:48
ANCS in a Node child process

Usage:

var t = require('transit-js')
var r = t.reader('json')

var child = require('child_process').fork('ancs_process.js', {
  env: {ABLE_HCI_DEVICE_ID: 1}})
.on('message', function(m) {
 console.log(r.read(m))})
@sander
sander / ancs.js
Last active February 5, 2021 16:02
BLE to stdin/stdout
var bleancs = require('ble-ancs')
var t = require('transit-js')
var writer = t.writer('json')
var reader = t.reader('json')
function status(v) {
return t.map([t.keyword('type'), t.keyword('status'),
t.keyword('value'), t.keyword(v)])}
function notif(v) {
return t.map([t.keyword('type'), t.keyword('notification'),