Skip to content

Instantly share code, notes, and snippets.

@jklmnn
jklmnn / gist:95a9605c060a917f5859
Last active August 29, 2015 14:16
Löve version check.
LOVE_VERSION = "0.9.1"
if love._version ~= LOVE_VERSION then
--Print error message and quit.
end
@jklmnn
jklmnn / gist:00d4859245bc7b825bdb
Last active December 15, 2015 09:31
ParkAPI Erfurt fixes.
diff --git a/park_api/cities/Erfurt.py b/park_api/cities/Erfurt.py
index 1b78de1..fe9b673 100644
--- a/park_api/cities/Erfurt.py
+++ b/park_api/cities/Erfurt.py
@@ -1,6 +1,8 @@
from bs4 import BeautifulSoup
from park_api.geodata import GeoData
from park_api.util import convert_date
+import re
+import datetime
@jklmnn
jklmnn / load-balance.sh
Created October 4, 2016 07:57 — forked from girst/load-balance.sh
Simple Linux Load Balancing with `iproute2`
#!/bin/bash
# Load balance multiple internet connections. Requires iproute2, awk and grep.
# (C) 2016 Tobias Girstmair, isticktoit.net, GPLv2
# Also useful: speedometer -l -r eth1 -t eth1 -m $(( 1024 * 1024 * 3 / 2 ))
# Not much user error checking is done - only pass working network connections
# script needs root to work and at least two connections to be useful
[ $EUID -eq 0 -a $# -ge 2 ] || {
echo "Usage (as root): $0 iface1 iface2 ..." >&2
@jklmnn
jklmnn / dump.py
Last active March 11, 2019 22:20
Dump ParkAPI database.
#!/usr/bin/env python3
import psycopg2 as psql
from sys import argv
import configparser
import os
from urllib.parse import urlparse
from tqdm import tqdm
import csv
@jklmnn
jklmnn / remove-old-kernels.sh
Last active February 2, 2017 13:30
Removes all kernels installed under Debian/Ubuntu that aren't loaded.
#!/bin/bash
kernels=$(dpkg -l | grep -E "ii linux-(image|headers)-[0-9]\.[0-9]\.[0-9]-.*" | grep -v $(uname -r | cut -d"-" -f1,2) | cut -d" " -f3)
echo "Current kernel: $(uname -r)"
echo "Remove kernels:"
echo "$kernels"
read -p "Execute? (y/n)" choice
if [ "$choice" == "y" ]
then
echo $kernels | xargs sudo apt-get remove -y
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20160831-64
* Copyright (c) 2000 - 2016 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
* Disassembly of DSDT, Fri May 12 09:26:31 2017
*
* Original Table Header:
@jklmnn
jklmnn / preprocessor_fun.h
Created September 2, 2017 20:57 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@jklmnn
jklmnn / get_working_sectors.c
Last active September 12, 2017 17:30
Get the working sectors of a block device. Uses the output of bad sectors created by badblocks. Thanks to @nikp123
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *fp = fopen(argv[1], "rb");
if(!fp) return 1;
int last = 0, bigdiff = 0, num;
while(fscanf(fp, "%d", &num) > 0){
if((num - last) > bigdiff) {
printf("Overthrow: %#x > %#x (%#x-%#x)\n", num-last, bigdiff, last, num);
@jklmnn
jklmnn / efi_fb.cc
Last active February 11, 2021 19:15
use efi framebuffer from linux user space
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
#include "genode.h"
@jklmnn
jklmnn / ls.c
Last active December 26, 2019 15:45
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
void ls(char *path)
{
DIR *dir;
struct dirent *file;
dir = opendir(path);