Skip to content

Instantly share code, notes, and snippets.

View martintrojer's full-sized avatar
🕺
My hovercraft is full of eels

Martin Trojer martintrojer

🕺
My hovercraft is full of eels
View GitHub Profile
#!/usr/bin/env python3
import argparse
docs = """
orig_data_size uncompressed size of data stored in this disk.
This excludes same-element-filled pages (same_pages) since
no memory is allocated for them.
Unit: bytes
compr_data_size compressed size of data stored in this disk
mem_used_total the amount of memory allocated for this disk. This
@martintrojer
martintrojer / setup.sh
Last active November 6, 2023 14:18
wifi -> eth bridge
#!/usr/bin/env bash
set -e
[ $EUID -ne 0 ] && echo "run as root" >&2 && exit 1
##########################################################
# You should not need to update anything below this line #
##########################################################
import itertools
print("Klara is the best")
numbers = map(float,range(1,10))
ops = ['+','-','*','/']
all_ops = list(itertools.product(ops,repeat=8))
print('There are {} different ways to order {} between {}'
.format(len(all_ops), ops, numbers))
@martintrojer
martintrojer / json.hs
Last active May 5, 2016 10:24
beyond clojure: haskell
[persistLowerCase|
Player
name String
level Int
deriving Show
deriving Generic
|]
instance ToJSON Player
instance FromJSON Player
@martintrojer
martintrojer / keybase.md
Created February 9, 2016 16:12
keybase

Keybase proof

I hereby claim:

  • I am martintrojer on github.
  • I am martintrojer (https://keybase.io/martintrojer) on keybase.
  • I have a public key ASDrzkwAX4TaHmqAz6qQohnjJEPgZTuxge1n0DvaI2LKAgo

To claim this, I am signing this object:

@martintrojer
martintrojer / app.clj
Last active August 16, 2021 22:49
ring jetty gzip
(ns http-server
(:require [ring.adapter.jetty :as jetty])
(:import [org.eclipse.jetty.server.handler.gzip GzipHandler]))
(defn- add-gzip-handler [server]
(.setHandler server
(doto (GzipHandler.)
(.setIncludedMimeTypes (into-array ["text/css"
"text/plain"
"text/javascript"
(function() {
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
@martintrojer
martintrojer / gist:2c981adeac9b7fd4af51
Created April 27, 2015 10:56
Clojure compiler bug
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
10:51:33.171 [main] INFO am.resize-images.main - Starting...
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f8ef94542a1, pid=8307, tid=140252449363712
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
@martintrojer
martintrojer / bt
Last active August 29, 2015 14:17
debugging emacs blog
(gdb) bt
#0 cmgoto (tty=0x126bbc0, row=45, col=0) at cm.c:320
#1 0x000000000040a642 in update_frame_line (f=f@entry=0xb06300, vpos=45) at dispnew.c:5031
#2 0x000000000040bcfb in update_frame_1 (f=f@entry=0xb06300, force_p=force_p@entry=true, inhibit_id_p=inhibit_id_p@entry=true, set_cursor_p=set_cursor_p@entry=true) at dispnew.c:4512
#3 0x000000000040d770 in update_frame (f=f@entry=0xb06300, force_p=<optimized out>, force_p@entry=true, inhibit_hairy_id_p=inhibit_hairy_id_p@entry=true) at dispnew.c:3113
#4 0x0000000000432c12 in echo_area_display (update_frame_p=update_frame_p@entry=1) at xdisp.c:11310
#5 0x0000000000432d5e in message3_nolog (m=m@entry=19444193) at xdisp.c:10271
#6 0x0000000000432f1a in message3 (m=m@entry=19444193) at xdisp.c:10213
#7 0x00000000004f4ddb in Fmessage (nargs=<optimized out>, args=<optimized out>) at editfns.c:3452
#8 0x00000000004fc891 in Ffuncall (nargs=<optimized out>, args=<optimized out>) at eval.c:2793
@martintrojer
martintrojer / saveme.sh
Created March 17, 2015 07:35
git reflog
for ref in `git fsck --unreachable | grep commit | cut -d' ' -f3`; do git show --summary $ref; done | less