Skip to content

Instantly share code, notes, and snippets.

View cypreess's full-sized avatar

Kris Dorosz cypreess

View GitHub Profile
@cypreess
cypreess / periodic_thread.py
Last active February 28, 2024 02:59
Python periodic thread using timer. You can cancel this thread any time. Thread will live at maximum to the end of one single processing run, otherwise it will end in the same time (especially during a wait time for next run). This code avoids the problem of waiting very long for thread exiting, because it does not uses time.sleep(). Please be a…
import logging
import threading
class PeriodicThread(object):
"""
Python periodic Thread using Timer with instant cancellation
"""
def __init__(self, callback=None, period=1, name=None, *args, **kwargs):
cypreess@wierzba:~$ . /usr/local/bin/virtualenvwrapper.sh
cypreess@wierzba:~$ mkvirtualenv test1
New python executable in test1/bin/python2.7
Also creating executable in test1/bin/python
Installing setuptools............done.
Installing pip...............done.
(test1)cypreess@wierzba:~$ pip install -e git+https://github.com/agh-glk/plp.git#egg=plp-dev
Obtaining plp from git+https://github.com/agh-glk/plp.git#egg=plp-dev
Cloning https://github.com/agh-glk/plp.git to ./.virtualenvs/test1/src/plp
Unpacking objects: 100% (19/19), done.
cypreess@iMac ~ cat f.cc
#include <stdio.h>
int main(){
unsigned char a = 255;
unsigned long int b = (a << 24);
unsigned long int c = ((unsigned long int) a << 24);
printf("b=%lu\n", b);
printf("c=%lu\n", c);
@cypreess
cypreess / robot.js
Created December 4, 2012 18:13
asxs
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);