Skip to content

Instantly share code, notes, and snippets.

@thefloweringash
thefloweringash / gist:1442127
Created December 7, 2011 09:20
Noppoo HID descriptors, original and modified with MacOS support.
#include <stdio.h>
#include <stdint.h>
#include "HIDReportData.h"
const uint8_t standard_descriptor_primary[] = {
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x06),
HID_RI_COLLECTION(8, 0x01),
HID_RI_USAGE_PAGE(8, 0x08),
#include <string.h>
template <typename T> struct lift {
typedef T t;
};
template <typename T> struct ptr {
typedef typename lift<T>::t* t;
};
template <typename T> struct lift<ptr<T> > {
@thefloweringash
thefloweringash / hid_report_dumper.c
Created May 12, 2012 10:45
HID report dumper for MacOS
#include <curses.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/hid/IOHIDManager.h>
#include <IOKit/hid/IOHIDKeys.h>
struct keyboard_handler {
uint8_t hid_report_buffer[1024];
int index;
@thefloweringash
thefloweringash / gist:2987134
Created June 25, 2012 07:13
C++11 Variadic Template Pattern Matching
#include <iostream>
using namespace std;
template <typename... T>
struct pp {};
template <typename T, typename TI,
typename U, typename UI>
struct matcher;
@thefloweringash
thefloweringash / gist:2988405
Created June 25, 2012 12:51
Winning at templates?
#include <iostream>
using namespace std;
template <typename... T>
struct pp {};
template <typename T, typename TI,
typename U, typename UI,
typename F>
@thefloweringash
thefloweringash / lists.cpp
Created August 14, 2012 00:54
Not sure if winning: variadic templates as lists
// Template Wrangling
// ==================
// convert a template into something that can be ::apply-ed
template <template <typename...> class T>
struct make_apply {
template <typename... Args>
using apply = T<Args...>;
};
@thefloweringash
thefloweringash / ctags.patch
Created November 4, 2012 03:32
ctags: Fix invalid use of 'const' resulting in garbage filenames
diff -ur a/ctags-5.8/read.c b/ctags-5.8/read.c
--- a/ctags-5.8/read.c 2009-07-04 17:29:02.000000000 +1200
+++ b/ctags-5.8/read.c 2012-11-04 16:19:27.000000000 +1300
@@ -18,7 +18,6 @@
#include <string.h>
#include <ctype.h>
-#define FILE_WRITE
#include "read.h"
#include "debug.h"
@thefloweringash
thefloweringash / indent-to-test.el
Last active December 10, 2015 20:58
Testing indent-to with indent-tabs-mode
(require 'cl)
(whitespace-mode t)
(setq indent-tabs-mode t
tab-width 4)
(defun indent-to-test--run (start end)
(interactive "r")
(undo-boundary)
(flet ((undo-boundary () nil))
@thefloweringash
thefloweringash / Info.plist
Last active December 11, 2015 02:09
Info.plist with entries for testing with vid 0x1007 and pid 0x8400. https://github.com/thefloweringash/iousbhiddriver-descriptor-override
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>12C60</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>IOUSBHIDDriverDescriptorOverride</string>
#!/bin/bash
# pull apart a bzImage compressed with xz (or gzip),
# and put it back together in a format that pv-grub understands
# useful when your kernel is compressed but your pv-grub doesn't
# recognise it, for example rescue64 from system rescue cd.
# the result is *not* a bootable kernel outside of pv-grub
# worksforme on OS X, YMMV