Skip to content

Instantly share code, notes, and snippets.

View spinningD20's full-sized avatar

spinningD20 spinningD20

View GitHub Profile
from flask.ext.socketio import SocketIO, emit
# flask app configuration, other flask stuff in between. other stuff cut out for brevity
@socketio.on('my broadcast event', namespace='/live')
def live_message():
emit('my response', {'data': statuscontent()}, broadcast=True)
print(request.namespace, 'broadcast socketio')
@socketio.on('connect', namespace='/live')
@spinningD20
spinningD20 / alembic.ini
Last active March 9, 2016 14:18
migrate include_objects problem
[excluded]
tables = ProjectInfo, AddressTypes, AddressTypes_tracking, ClientAddresses_tracking, ClientContacts, ClientContacts_tracking, ClientTypes, ClientAddresses, Clients, Clients_tracking, ContactGroups, ContactGroups_tracking, Contacts, Contacts_tracking
@spinningD20
spinningD20 / main.kv
Created May 7, 2015 14:23
child events fired on parent widget interaction
<PropertyTag>:
size_hint: (None, None)
size: tag_label.size
Label:
size: self.texture_size
on_touch_down: print(self.on_touch_down)
on_touch_up: print(self.on_touch_up)
id: tag_label
color: 0, 0, 0, 1
canvas.before:
@spinningD20
spinningD20 / relevant.kv
Created May 27, 2015 18:27
PinchLabel to StackLayout
StackLayout:
PinchLabel:
text: 'hello'
from functools import wraps
def memoized(f):
"""Decorator that caches a function's return value each time it is
called. If called later with the same arguments, the cached value
is returned, and not re-evaluated.
"""
cache = {}
@wraps(f)
@spinningD20
spinningD20 / spotify_keybindings
Created March 17, 2016 20:10 — forked from jbonney/spotify_keybindings
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
@spinningD20
spinningD20 / main.py
Created May 19, 2016 17:05
custom event binding order issue
#!/usr/bin/python3
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class AfterSuperButton(Button):
def __init__(self, **kwargs):
#!/usr/bin/env python
from pyzmo import *
from evdev.ecodes import *
from evdev import InputDevice
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 8000
import serial
@spinningD20
spinningD20 / iterlete.py
Created November 14, 2016 03:08
needed something quick to go through a media collection, search on youtube if I didn't know what it was, and give the option to skip the file or delete it.
import fnmatch
import os, sys
#import pyperclip # for clipboard usage
import webbrowser
for file in os.listdir('.'):
if fnmatch.fnmatch(file, '*'+sys.argv[1]+'*'):
print "File: " + file
choice = raw_input("Delete? Y/N/L")
if choice.upper() == 'L':
@spinningD20
spinningD20 / main.py
Last active January 20, 2017 03:49
camera_scale throws off convert_from_screen_to_world results
from collections import defaultdict
import tmx
from cymunk.cymunk import Vec2d
from kivent_maps.map_utils import _load_obj_models, _load_tile_map, _load_tile_properties
from kivent_maps.map_utils import _load_tilesets
from kivy.app import App, platform
from kivy.core.window import Window, Keyboard
from kivy.clock import Clock
from kivy.uix.widget import Widget