This file contains 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
(def actions (atom {})) | |
(defn register [action function] | |
(swap! actions assoc action (conj (action @actions) function))) | |
(defn do-action [action arg] | |
(reduce #(%2 %1) arg (action @actions))) |
This file contains 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
(defmacro maze-thread [value & exprs] | |
(let [gen (gensym)] | |
(concat | |
`(let [~gen (atom ~value)]) | |
(map (fn [expr] `(swap! ~gen (fn [~'%] ~expr))) exprs)))) |
This file contains 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
(require 'clojure.contrib.lazy-seqs) | |
(defmacro fib [nr] | |
(let [fibfn (gensym fib)] | |
`(let [~fibfn (fn [nrs#] [(peek nrs#) (+ (first nrs#) (peek nrs#))])] | |
(-> [0 1] ~@(take nr (repeat fibfn)))))) | |
(println (time (last (fib 10)))) | |
(println (time (nth (clojure.contrib.lazy-seqs/fibs) 11))) |
This file contains 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
# implementation | |
from pymouse import PyMouseEventMeta | |
import systembridge | |
from threading import Thread | |
class PyMouseEvent(PyMouseEventMeta): | |
def __init__(self): | |
click_tap = systembridge.get_event_tap(mousepress | mouserelease) | |
move_tap = systembridge.get_event_tap(mousemove) |
This file contains 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
from Quartz import * | |
def MyFunction(*args): | |
print args | |
tap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionListenOnly, kCGEventLeftMouseDown, MyFunction, None) | |
runLoopSource = CFMachPortCreateRunLoopSource(None, tap, 0) | |
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode) | |
CGEventTapEnable(tap, True) |
This file contains 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
from Xlib.display import Display | |
from Xlib import X | |
from Xlib.ext import record | |
from Xlib.protocol import rq | |
# True if you want to stop events from reaching other apps | |
capture = True | |
def record_callback(reply): | |
data = reply.data |
This file contains 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/python | |
# | |
# $Id: record_demo.py,v 1.2 2007/06/10 14:11:59 mggrant Exp $ | |
# | |
# examples/record_demo.py -- demonstrate record extension | |
# | |
# Copyright (C) 2006 Alex Badea <[email protected]> | |
# | |
# 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 |
This file contains 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
from pymouse import PyMouseEvent | |
class event(PyMouseEvent): | |
def move(self, x, y): | |
print "Mouse moved to", x, y | |
def click(self, x, y, button, press): | |
if press: | |
print "Mouse pressed at", x, y, "with button", button | |
else: |
This file contains 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 pythoncom, pyHook | |
from time import sleep | |
from pymouse import PyMouseMeta, PyMouseEventMeta | |
class PyMouseEvent(PyMouseEventMeta): | |
def __init__(self): | |
PyMouseEventMeta.__init__(self) | |
self.listen = True | |
self.start() | |
def run(self): |
This file contains 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 pygame | |
from pymouse import PyMouse | |
from time import sleep | |
# edit this to reflect your joystick axis and buttons | |
action = {'x':0, 'y':1, 'multiplier':3, 'left':0, 'right':1} | |
pygame.init() | |
j = pygame.joystick.Joystick(0) # first joystick | |
j.init() |
OlderNewer