Skip to content

Instantly share code, notes, and snippets.

View jbaiter's full-sized avatar

Johannes Baiter jbaiter

View GitHub Profile
@rsslldnphy
rsslldnphy / re_frame.cljs
Created July 3, 2015 14:37
custom register-sub
(if-not goog.DEBUG
(def register-sub rf/register-sub)
(do
(defonce subcounts (atom {}))
(aset js/document "subcounts" #(.table js/console (clj->js
(for [[k vs]
(reverse (sort-by :total-time @subcounts))]
(assoc vs :subscription (str k))))))
@fulmicoton
fulmicoton / benchmark.py
Last active May 13, 2016 19:04
benchmark
class Index(object):
def __init__(self,):
self.idx_to_val = []
self.val_to_idx = {}
def get_id(self, val):
return self.val_to_idx[val]
def get_val(self, idx):
return self.idx_to_val[idx]
@maxpert
maxpert / nosqlite.py
Last active May 18, 2018 22:21
A really simple Document store built on top of SQLite3 using Python
'''
Copyright (c) 2013 Zohaib Sibte Hassan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@CMCDragonkai
CMCDragonkai / developing_with_nix.md
Last active March 29, 2019 11:03
Developing with Nix (Nodejs, Haskell, Python, PHP, Emscripten) #nix #nixpkgs #nixos #python
@tomcrane
tomcrane / WDL-IxIF.md
Last active July 31, 2020 05:11
Wellcome Library IxIF "Interim" implementation

We want to move the Wellcome Library away from the Wellcome Player and onto the IIIF 2.0 Universal Viewer (UV).

This allows us to move all the Wellcome Library's image API endpoints to the protoype DLCS (Digital Library Cloud Services) that we have started building.

We have a problem. We have video, audio and born-digital content, besides image sequence content. We don't want to maintain the Player and the UV together. This non-image content is a tiny fraction of the total, but an important one.

Other institutions share this problem, and everyone agrees that IIIF will need to extend to handle non-image-sequence resources - "IxIF". We want to inherit all that we can from IIIF - the JSON-LD, the Open Annotation model, the manifest wrapper and general approach to metadata ("presentation not semantics"). Shared Canvas may be appropriate for some media but not others.

  • Images are canvas-based media - they occupy a region of a plane. Annotations are on regions of the plane.
  • Audio is a time-based medium - i
@ptaoussanis
ptaoussanis / transducers.clj
Last active December 17, 2021 13:54
Quick recap/commentary: Clojure transducers
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
@boppreh
boppreh / balloontip.py
Created November 2, 2012 11:35 — forked from wontoncc/balloontip.py
Balloon tip module, Python, using win32gui. Display a notification in the tray bar and quits after 10 seconds.
# -- coding: utf-8 --
from win32api import *
from win32gui import *
import win32con
import sys, os
import struct
import time
class WindowsBalloonTip:
@artizirk
artizirk / pyroute_netlink_wireguard.py
Last active July 5, 2022 14:09
Test program to print out WireGuard interface config using Python pyroute2 netlink library
@Ashung
Ashung / config.json
Last active March 6, 2023 23:08
Subset font use opentype.js
{
"fonts": ["./src/NotoSerifSC-Bold.otf"],
"texts": " 0123456789:年月日时分秒公元农历腊零初一二三四五六七八九十廿甲乙丙丁戊己庚辛壬癸子丑寅卯辰巳午未申酉戌亥立春雨水惊蛰春分清明谷雨立夏小满芒种夏至小暑大暑立秋处暑白露秋分寒露霜降立冬小雪大雪冬至小寒大寒"
}
@kevinoid
kevinoid / error-reporting.js
Last active April 11, 2023 03:50
More Robust Client-Side JavaScript Error Reporting
// JavaScript error reporting functions, including automatic window.onerror
// and unhandledrejection reporting.
//
// Based on:
// https://kevinlocke.name/bits/2019/07/30/more-robust-javascript-error-reporting/
//
// API:
// reportError(message, error):
// Report an exception with optional message and exception value.
// reportRejection(message, cause):