Skip to content

Instantly share code, notes, and snippets.

View vogler's full-sized avatar

Ralf Vogler vogler

  • Munich, Germany
  • 18:34 (UTC +02:00)
View GitHub Profile
@vogler
vogler / subtype.ml
Last active August 29, 2015 14:18
subtyping of polymorphic variants when using GADTs
type 'r t = A : [`A | `T] t | B : [`B | `T] t;; (* the information 'r : [> `T] seems to be missing *)
(* type _ t = A : [ `A | `T ] t | B : [ `B | `T ] t *)
(* the following works as expected: *)
let rec f : type r. r t -> r = function A -> `T | B -> `T;;
(* val f : 'r t -> 'r = <fun> *)
f A;;
(* - : [ `A | `T ] = `T *)
(* now f should be called on different modules for the same q, and the results should be combined *)
@vogler
vogler / README.md
Last active April 21, 2016 15:09
Goblint C library functions

Compilation and linking with undefined functions

GCC compilation process GCC compilation process

Linking fails if an undefined function is used:

❯ gcc test.c
Undefined symbols for architecture x86_64:

"_f", referenced from:

goblint jobs

All topics can also be done as hiwi jobs. Recommendations for theses:

  • ba = bachelor's thesis
  • ma = master's thesis

ba, ma specification system for library functions

See description

@vogler
vogler / lattice.ml
Created November 17, 2016 16:15
some lattice examples
(* REPL: #use "lattice.ml";; *)
#require "batteries";;
#require "ppx_deriving.std";;
open BatteriesExceptionless
let nopath x = let open String in let i = (rindex x '.' |? -1) + 1 in sub x i (length x - i);;
module type PartialOrder = sig
type d [@@deriving show, enum]
val leq : d -> d -> bool

This extension helps dealing with warning 57:

File "when.ml", line 28, characters 4-19:
Warning 57: Ambiguous or-pattern variables under guard;
variable x may match different arguments. (See manual section 8.5)

Problem

let f = function
 | A x, _ (* A 0, A 1 would match here and fail the guard *)
@vogler
vogler / dash.py
Created April 5, 2017 19:01
detects dash button presses
from scapy.all import *
from datetime import datetime
# blocked these macs in router to avoid notifications. however, this makes them try longer.
# fake server: https://github.com/ide/dash-button/issues/59
# maybe set google as primary dns and rpi as secondary: https://medium.com/@tombatossals/cheating-the-amazon-dash-iot-button-the-almost-easy-way-e5bc62f93f8c
macs = {
"ac:63:be:ea:5b:1b": "kleenex",
"ac:63:be:ba:2f:85": "oral-b"
}
@vogler
vogler / ppx_reflect.ml
Last active October 27, 2017 09:43
ppx_reflect
(** identifiers *)
(* name of identifier as string *)
let%id foo = declare Int
let foo = declare Int "foo"
(* name of module as string *)
module%id Foo = struct end
module Foo = struct let name = "Foo" end
module%id Foo (Bar : S) = struct end
@vogler
vogler / gist:fc7d77c1fc424aa2902e
Last active February 12, 2018 21:22
cVim Options
set autoupdategist
set nosmoothscroll
set cncpcompletion
let blacklists = ["*://mail.google.com/*", "*://netflix.com/*"]
set noautofocus
let mapleader = ","
map <Leader>d :tabdetach<CR>
map <Leader>a :tabattach<Space>
map a previousTab
map s nextTab
@vogler
vogler / sVimrc
Last active May 22, 2018 13:30
sVim Options
set nosmoothscroll
map "s" nextTab
map "a" previousTab
type a = { id: number, name: string, foo: string }
type b = { id: string, name: string, bar: string }
type c = a | b
type d = a & b
type id = d['id'] // number & string = never (bot)
const va: a = {id: 1, name: 'ha', foo: 'foo'}
const vb: b = {id: '1', name: 'ha', bar: 'bar'}
const vc1: c = va
const vc2: c = vb