Skip to content

Instantly share code, notes, and snippets.

@thefloweringash
thefloweringash / gist:1442127
Created Dec 7, 2011
Noppoo HID descriptors, original and modified with MacOS support.
View gist:1442127
#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),
View gist:1921139
#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
HID report dumper for MacOS
View hid_report_dumper.c
#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 Jun 25, 2012
C++11 Variadic Template Pattern Matching
View gist:2987134
#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 Jun 25, 2012
Winning at templates?
View gist:2988405
#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 Aug 14, 2012
Not sure if winning: variadic templates as lists
View lists.cpp
// 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 Nov 4, 2012
ctags: Fix invalid use of 'const' resulting in garbage filenames
View ctags.patch
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 Dec 10, 2015
Testing indent-to with indent-tabs-mode
View indent-to-test.el
(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 Dec 11, 2015
Info.plist with entries for testing with vid 0x1007 and pid 0x8400. https://github.com/thefloweringash/iousbhiddriver-descriptor-override
View Info.plist
<?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>
View bzImage-to-gzip.sh
#!/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