Skip to content

Instantly share code, notes, and snippets.

@enkore
enkore / gist:2512070
Created April 27, 2012 19:28
Ctrl+A (Select All) with edit controls without ES_MULTILINE
LRESULT CALLBACK EditWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_KEYDOWN:
switch(wParam) {
case 'A': // Ctrl+A = select all
if(GetKeyState(VK_CONTROL) & 0x8000) {
SendMessage(hWnd, EM_SETSEL, 0, -1);
}
break;
@enkore
enkore / avr_netio.py
Created May 19, 2012 17:50
Controlling the AVR Net-IO board in Python
# DSLRlapse
# AVR Net-IO plugin
# Copyright (C) 2011 Marian Beermann
# 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 / proxy.py
Created May 20, 2012 10:53
DynamicProxy
class DynamicProxy(object):
class Task(object):
fn = None
args = list()
kwargs = dict()
def __init__(self, target, target_proxy=None):
self._target = target
self._methods = inspect.getmembers(target, inspect.ismethod)
print "Methods: %s" % self._methods
@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"]