Skip to content

Instantly share code, notes, and snippets.

@enkore
enkore / cl_enum.c
Last active November 5, 2016 15:59
Simple OpenCL enumerator
// I place this in the public domain
// Compile with
// <gcc/clang> <thisfile>.c -lOpenCL-Wall -Wextra -Wpedantic -std=c99
// Created a long time ago
// Updated, some memory leaks fixed and so on 2014-05-28
// Changed to real C instead of some quirky C++ casts inbetween (2014-05-28)
#include <CL/cl.h>
@enkore
enkore / gist:2978342
Created June 23, 2012 13:43
Simple footer with reportlab
# I place this in the public domain
def make_pdf_from_elements(elements, title, author):
# elements is a list containing flowables, while title and author are simply strings added to PDF metadata
def drawPage(canvas, doc):
canvas.setTitle(title)
canvas.setSubject(title)
canvas.setAuthor(author)
canvas.setCreator(author)
@enkore
enkore / gist:2978752
Created June 23, 2012 15:50
HTML to reportlab flowables converter
# I place this in the public domain
# This only handles non-nested lists, emphasis, headings and horizontal rules (which are converted to page breaks)
# Sufficient for converting Markdown generated HTML to reportlab flowables...
import xml.sax as sax
def html_to_rl(html, styleSheet):
elements = list()
@enkore
enkore / gist:3131917
Created July 17, 2012 20:42
Microsoft SideWinder Strategic Commander USB-HID protocol
Displaying the HID stream without any decoding (not so helpful):
# od -t x1 -v --width=7 /dev/hidraw0
Example packet:
01 Start
00 Position data
00 Position data
00 Position data
00 Position data
00 Keys on top
@enkore
enkore / upper2.py
Created August 6, 2012 23:02
Uploading files and creating nodes to a Drupal site using Services, Python and XMLRPC
#!/usr/bin/env python2
# coding=utf-8
# Copyright (C) 2012 Marian Beermann
#
# This program is free software: you can rediunicodeibute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@enkore
enkore / 4chandl.py
Created August 27, 2012 21:48
Downloader for entire 4chan threads
#!/usr/bin/env python3
# 4chan downloader
# Copyright (C) 2012 Marian Beermann
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@enkore
enkore / posting.dot
Created October 10, 2012 22:09
posting
digraph posting {
subgraph cluster_post {
label="Wie Beiträge verfasst werden";
"Beitrag lesen"
-> "Beitrag verstehen"
-> "Unklare Wörter nachschlagen"
-> "[zitieren] drücken"
@enkore
enkore / gist:3873096
Created October 11, 2012 15:09
Erstes AVR-Programm für eigene Hardware (RUNNERS RECORD)
#include <avr/io.h>
int main(void)
{
DDRB = 0x02;
PORTB = 0x00;
while(1) {
}
void gps_init()
{
FIL nmea;
uint16_t last_size = eeprom_read_word(&ee_init_size);
if(f_open(&nmea, "/initseq.txt", FA_READ) == FR_OK) {
uint16_t size = f_size(&nmea);
if(size > 1024) {
// Use EEPROM block, sequence in file is too large
@enkore
enkore / riceboy.py
Created November 13, 2012 12:38
riceboy downloader
#!/usr/bin/env python3
import os
from urllib.request import urlretrieve
stories = {
"see": (".gif", 84),
"order": (".gif", 744),
"vattu": (".png", 354),
}
other_ext = [".gif", ".png"]