Skip to content

Instantly share code, notes, and snippets.

View josteink's full-sized avatar

Jostein Kjønigsen josteink

View GitHub Profile
@josteink
josteink / forever-session
Created April 28, 2017 09:41
Screen glue
#!/usr/bin/env bash
~/bin/screen-create-or-attach ever-session weechat
@josteink
josteink / demo.sh
Last active February 1, 2017 08:37
Getting your own process without using procfs on Linux
#!/bin/sh
gcc test.c
./a.out
# /home/josteink/demo/a.out
cp a.out b.out
./b.out
# /home/josteink/demo/b.out
ln -s a.out c.out
./c.out
@josteink
josteink / on_stateful_code.txt
Last active October 21, 2020 05:37
On why stateful code is bad
On why stateful code is bad
===========================
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
@josteink
josteink / compile_commands.json
Created February 13, 2016 11:43
coreclr build output with additional cmake-flags
This file has been truncated, but you can view the full file.
[
{
"directory": "/home/jostein/build/coreclr/bin/obj/Linux.x64.Debug",
"command": "/usr/bin/clang++ -DBIT64=1 -DBUILDENV_CHECKED=1 -DDEBUG -DDISABLE_CONTRACTS -DLINUX64 -DPIC=1 -DPLATFORM_UNIX=1 -DSystem_Globalization_Native_EXPORTS -DURTBLDENV_FRIENDLY=Checked -D_DBG -D_DEBUG -D__LINUX__=1 -Isrc/corefx/System.Globalization.Native -I../../../src/corefx/System.Globalization.Native -Wall -Wno-null-conversion -std=c++11 -g -O0 -fPIC -fno-omit-frame-pointer -fms-extensions -fstack-protector-strong -ferror-limit=4096 -Werror -Wno-unused-private-field -Wno-unused-variable -Wno-microsoft -Wno-tautological-compare -Wno-constant-logical-operand -Wno-unknown-warning-option -Wno-invalid-offsetof -Wno-incompatible-ms-struct -fPIC -o src/corefx/System.Globalization.Native/CMakeFiles/System.Globalization.Native.dir/calendarData.cpp.o -c /home/jostein/build/coreclr/src/corefx/System.Globalization.Native/calendarData.cpp",
"file": "/home/jostein/build/coreclr/src/corefx/System.Globalization.Native/calendarData.c
@josteink
josteink / Intel ACPI dump
Created September 18, 2015 21:17
Dump of Intel ACPI DSDT data on Lenovo Carbon X1
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20141107-64 [Dec 17 2014]
* Copyright (c) 2000 - 2014 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
* Disassembly of dsdt.dat, Fri Sep 18 23:07:21 2015
*
* Original Table Header:
@josteink
josteink / Spotify-To-Google-Playlist-Converter.el
Created September 18, 2015 11:03
A emacs-lisp function to convert a spotify-playlist exported from spotlistr to work with gmusic-playlist to import into Google Music.
(defun hour-minute-seconds-to-milliseconds (input)
"Convert a string of format 01:02:03 to milliseconds."
(with-temp-buffer
(insert input)
(goto-char (point-min))
(search-forward-regexp "\\([[:digit:]]+\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\)")
(let* ((hour (string-to-number (match-string 1)))
(minutes (* 60 hour))
(minute (string-to-number (match-string 2)))
(seconds (* 60 (+ minute minutes)))