This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# activate middle click + trackpoint scrolling | |
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Evdev Wheel Emulation' 1 | |
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Evdev Wheel Emulation Button' 2 | |
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Evdev Wheel Emulation Timeout' 220 | |
# horizontal scrolling | |
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _POSIX_C_SOURCE 200809L | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
void *xrealloc(void *p, size_t sz) | |
{ | |
p = realloc(p, sz); | |
if (p == NULL) { | |
fprintf(stderr, "OOM!\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Applicative instance where we have NOT (ap = (<*>)) | |
-- is this valid? | |
data ParFallible e a = Fail e | Success a | |
instance Functor (ParFallible e) where | |
fmap _ (Fail e) = Fail e | |
fmap f (Success a) = Succes (f a) | |
instance Monoid e => Applicative (ParFallible e) where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- some custom atomic datatype, defined in Atom.hs | |
newtype Atom = Atom ByteString deriving (Ord) | |
-- another custom datatype | |
newtype DbInt = DbInt Word64 deriving (Ord) | |
-- and so on. | |
-- DbIndex.hs | |
-- an index doesn't know of all the possible datatypes we might want to use. | |
-- So we can't use a sum type (Expression Problem), but need these datatypes wrapped in an existential type. | |
data Cell where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* benchmark for testing function call overhead of function pointer | |
* integer lexem parsing, vs inlined integer lexem parsing | |
*/ | |
#include <assert.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#define BUFSIZE ((size_t)(1024*1024*1024)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <X11/Xlib.h> | |
#include <X11/Xutil.h> | |
Display *dpy; | |
Window rootwin; | |
Atom atom_WM_NAME; | |
Window appwin; | |
Window childwin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# This is useful for editing multi-line C macros | |
import sys | |
lines = [line.rstrip(' \\\n').rstrip() for line in sys.stdin] | |
maxlen = max(len(line) for line in lines) | |
for line in lines: | |
print(line + ' '*(2 + maxlen - len(line)) + '\\') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Stateful closure in Haskell | |
import Data.IORef | |
makeCounter :: IO (Int -> IO Int) | |
makeCounter = do | |
state <- newIORef 0 | |
return $ \i -> do | |
modifyIORef state (+i) | |
readIORef state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
class Element: | |
def __init__(self, name, **attributes): | |
self.name = name | |
self.attributes = attributes | |
self.childs = [] | |
def setAttribute(self, key, val): |
OlderNewer