Skip to content

Instantly share code, notes, and snippets.

View plopp's full-sized avatar

Marcus Kempe plopp

View GitHub Profile
@plopp
plopp / IR-codes
Created September 20, 2017 08:27
# NAD T754 #
PWR_ON = E13EA45B
PWR_OFF = E13E13EC
VOL_UP = E13E11EE
VOL_DOWN = E13E31CE
SET_INPUT_DVD = E13E43BC
SET_INPUT_SAT = E13E03FC
SET_INPUT_VCR = E13E837C
SET_INPUT_VID4 = E13E0CF3
@plopp
plopp / apple_keyboard.sh
Created July 11, 2017 22:37
Correct keys for Non-US Apple Keyboard on Ubuntu
#Reference:
#https://help.ubuntu.com/community/AppleKeyboard#Correcting_swapped_keys_and_wrong_keymaps_for_international_.28non-US.29_keyboards
echo options hid_apple iso_layout=0 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all
sudo reboot
@plopp
plopp / General Makefile
Created May 28, 2017 09:27 — forked from reecer/General Makefile
A general makefile for general-purpose C projects.
CC=gcc
CCFLAGS=-Wall
LDFLAGS=
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
TARGET=des
all: $(TARGET)
$(TARGET): $(OBJECTS)
function factorial(op) {
// Lanczos Approximation of the Gamma Function
// As described in Numerical Recipes in C (2nd ed. Cambridge University Press, 1992)
var z = op + 1;
var p = [1.000000000190015, 76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 1.208650973866179E-3, -5.395239384953E-6];
var d1 = Math.sqrt(2 * Math.PI) / z;
var d2 = p[0];
for (var i = 1; i <= 6; ++i)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import logging
import time
from logging.handlers import TimedRotatingFileHandler
#----------------------------------------------------------------------
def create_timed_rotating_log(path):
""""""
logger = logging.getLogger("Rotating Log")
logger.setLevel(logging.INFO)
#include <Sodaq_RN2483.h>
#include <Sodaq_wdt.h>
#include <StringLiterals.h>
#include <Switchable_Device.h>
#include <Utils.h>
/* Docs
Commands reference RN2483 - http://ww1.microchip.com/downloads/en/DeviceDoc/40001784B.pdf
RN2483 in general - http://www.microchip.com/wwwproducts/en/RN2483
*/
import xlsxwriter
import sys
#### Kvicksundspokalen parser
#Parse file
#Extract fields
#Sort by date?
#Format xml output
#Add to sheet
#Create an new Excel file and add a worksheet.
def twosComplement(val, nbits):
n = (2**nbits)
if(val > (n/2-1)):
return val-n
else:
return val
print twosComplement(64123,16)
@plopp
plopp / ntp2timestamp.py
Created July 8, 2016 16:32
Calls an NTP server and converts the response to a millisecond unix epoch timestamp
import socket
import struct
import time
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
data = '\x1b' + 47 * '\0'
client.sendto(data, ("0.se.pool.ntp.org",123))
data, address = client.recvfrom( 1024 )
if data: