Skip to content

Instantly share code, notes, and snippets.

View xinitrc's full-sized avatar

Martin Hilscher xinitrc

View GitHub Profile
@ivawzh
ivawzh / json-parser.ts
Last active February 26, 2024 07:09
Typescript crazy mapped types
// This is only working in 4.1.0-insiders20200903
type ParserError<T extends string> = { error: true } & T
type EatWhitespace<State extends string> =
string extends State
? ParserError<"EatWhitespace got generic string type">
: State extends ` ${infer State}` | `\n${infer State}`
? EatWhitespace<State>
: State
type AddKeyValue<Memo extends Record<string, any>, Key extends string, Value extends any> =
// <script src="angular.min.js"></script>
(function(name, factory) {
// our basic IO module system that stores every module on modules with the "file" namespace
// please use something like browserify rather than rolling your own like this
window.modules = window.modules || {};
window.require = window.require || function require(name) { return window.modules[name] || window[name]; };
var exports = {}; factory(exports, window.require);
window.modules[name] = exports;
}('TodoService', function(exports, require) {
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
import Control.Applicative ((<$>))
import Control.Arrow
import Control.Monad
import Data.Char (toLower)
import Data.Function (on)
import Data.List (groupBy, nub, sortBy)
@tylevad
tylevad / xmonad.hs
Last active November 3, 2023 23:14
XMonad window manager config
{-# LANGUAGE TypeSynonymInstances, DeriveDataTypeable, MultiParamTypeClasses, NoMonomorphismRestriction #-}
-- Ty Levad - tylevad@gmail.com
-- xmonad.hs
-- Core Modules
import System.Exit
import XMonad hiding ((|||))
import qualified XMonad.StackSet as W
-- Action Modules
@tbtlr
tbtlr / get_barcode_from_image.js
Created June 1, 2010 19:33
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',