Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
keithrbennett / server.rb
Last active August 9, 2019 11:39
Getting Sinatra to run alongside other threads in an app.
require 'socket'
require 'sinatra/base'
require 'pry'
puts "Ruby runtime parsing SinatraServer in main thread: #{Thread.current}"
sinatra_thread = Thread.new do
class SinatraServer < Sinatra::Application
puts "Sinatra running in thread: #{Thread.current}"
@jegger
jegger / Kivy_on_Mac_10.9.2
Last active May 22, 2024 00:37
Install kivy into a virtualenv on Mac 10.9 Mavericks
# Inspired by:
# - https://gist.github.com/goldsmith/7262122
# - https://gist.github.com/brousch/6589386
#### Some hints ####
# Currently kivy apps only work on monitor 1 (multiple monitor setup)
# You have to place the terminal which runs kivy on the monitor 1 or make the app fullscreen.
# Make sure you have the "command line tools" for mavericks installed!
# (xcode-select --install)
@jeamland
jeamland / gist:11284662
Created April 25, 2014 10:20
Bluetooth LE on OS X via Python
import select
import socket
import sys
import objc
from PyObjCTools import AppHelper
objc.loadBundle("CoreBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))
@kumichou
kumichou / run.sh
Created June 24, 2014 18:36
Ever wanted to see how to do something simple like catch Ctrl-C in a BASH script? I'll illustrate how to start two different Python "apps" that would normally take over the terminal and stop them both
#!/usr/bin/env bash
CWD=`pwd`
function cleanup {
echo "You pressed Ctrl-C, time to exit the Python Services";
ps aux | grep myservice2 | grep -v grep | awk '{print $2}' | xargs kill -9;
ps aux | grep myservice1 | grep -v grep | awk '{print $2}' | xargs kill -9;
exit 1;
}
@tito
tito / utmotionevent.py
Last active August 29, 2015 14:16
Example of mock-MotionEvent for unittest
# subclass for touch event in unit test
class UTMotionEvent(MotionEvent):
def depack(self, args):
self.is_touch = True
self.sx = args['x']
self.sy = args['y']
self.profile = ['pos']
super(UTMotionEvent, self).depack(args)
@jegger
jegger / main.py
Created March 22, 2015 16:21
WAMP autobahn reconnect
# Copied from https://gist.github.com/DenJohX/e6d0864738da10cb9685 -> DenJohX
# Slightly modified
import sys
from twisted.python import log
from twisted.internet import reactor
from twisted.internet.protocol import ReconnectingClientFactory
from autobahn.websocket.protocol import parseWsUrl
from autobahn.twisted import wamp, websocket
@hlung
hlung / UIRefreshControl+beginRefreshing.h
Last active October 10, 2018 09:31
A UIRefreshControl beginRefreshing method that actually works
//
// UIRefreshControl+beginRefreshing.h
// Kibo
//
// Created by Hlung on 3/6/15.
// MIT License
//
#import <UIKit/UIKit.h>
@LearnCocos2D
LearnCocos2D / gist:77f0ced228292676689f
Last active February 4, 2026 02:02
Overview of Entity Component System (ECS) variations with pseudo-code

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

Entity->Components->Update
  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
@josefnpat
josefnpat / readme.md
Last active March 25, 2026 21:05
Going from Lua 5.2 to PICO-8's Lua

This information applies to the PICO-8 0.1.6 release.

This document is here to help folks with a proficiency in Lua understand the limitations and discrepencies between Lua and PICO-8's Lua.

You can always view the manual or yellowafterlife's extended 0.1.1 manual.

General

  • anything written in uppercase the PICO-8 editor or .p8 is made lowercase by the editor. → editing the .p8 file directly can work
  • print(function() end) outputs the string function instead of the string function: 0x0000000.
@nxhack
nxhack / supervisord
Last active July 15, 2023 15:25
python supervisor startup script for OpenWrt-yun
#!/bin/sh /etc/rc.common
# python supervisor
# (init script for OpenWrt-yun)
# Original : https://github.com/Supervisor/initscripts/blob/master/slackware
START=99
STOP=49
# set HOME for ssh
HOME=/root