Skip to content

Instantly share code, notes, and snippets.

3081dc8bd48393dfcb9af31a7d078a4f
@olavmrk
olavmrk / gist:15421f48ff22b3db53d1
Created February 2, 2015 12:05
2560x1440 via DVI
xrandr --newmode "2560x1440" 241.50 2560 2600 2632 2720 1440 1443 1448 1481 -hsync +vsync
xrandr --addmode HDMI1 2560x1440
xrandr --output HDMI1 --mode 2560x1440
@olavmrk
olavmrk / wireshark-remote.sh
Created January 7, 2015 15:59
Run wireshark with remote dump over ssh
wireshark -k -i <(ssh root@dumphost.example.org tcpdump -U -w - host somehost.example.org and port 80)
@olavmrk
olavmrk / clockdbg.py
Last active August 29, 2015 14:10
Clock debugging script.
#!/usr/bin/env python
import ctypes
import ntplib # wget https://ntplib.googlecode.com/hg/ntplib.py
import sys
import time
# struct timespec {
# time_t tv_sec; /* seconds */
# long tv_nsec; /* nanoseconds */
@olavmrk
olavmrk / securerandom.php
Created July 16, 2014 09:44
Generate secure random integers in a uniform distribution
<?php
function getRandomBits($bits) {
assert('is_int($bits)');
/* First load some random bytes. */
$numBytes = ($bits - 1) / 8 + 1;
$bytes = openssl_random_pseudo_bytes($numBytes);
/* Convert it to an integer. */
@olavmrk
olavmrk / term-colors.sh
Created July 8, 2014 08:11
Show terminal colors
#!/bin/bash
for ((C=0;C<=7;C++)) do echo -e "\e[0;$((30+C))mcolor$C\e[0m \e[1;$((30+C))mcolor$((C+8))\e[0m"; done
#!/usr/bin/env python
import platform
import socket
import struct
import sys
_ULOG_NL_EVENT = 111
class _NetlinkHeader:
SIZE = 16
@olavmrk
olavmrk / sizeof-ulog_packet_msg_t.c
Created June 29, 2014 18:46
Check padding of ulog_packet_msg_t
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#define IFNAMSIZ 16
#define ULOG_PREFIX_LEN 32
#define ULOG_MAC_LEN 80
typedef struct ulog_packet_msg {
@olavmrk
olavmrk / statictest.py
Created June 29, 2014 18:04
Testing storing references to @staticmethod in class
#!/usr/bin/env python
class Hello(object):
@staticmethod
def _hello_impl_1():
print 'Hello world!'
_hello_impl = None
@staticmethod
def hello():
if Hello._hello_impl == None:
Hello._hello_impl = Hello._hello_impl_1
#include <asm/types.h>
#include <linux/netlink.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
int main() {
int res;