Skip to content

Instantly share code, notes, and snippets.

View rshk's full-sized avatar
😎
Being awesome

Samuele Santi rshk

😎
Being awesome
  • Tampa, Florida
View GitHub Profile
import io
import re
import pytest
test_cases = [
(r'eggs:spam:bacon', ['eggs', 'spam', 'bacon']),
(r'eggs\:spam:bacon', ['eggs:spam', 'bacon']),
(r'eggs\\:spam:bacon', ['eggs\\', 'spam', 'bacon']),
(r'eggs\\\:spam:bacon', ['eggs\\:spam', 'bacon']),
(r'eggs::spam:bacon', ['eggs', '', 'spam', 'bacon']),
@rshk
rshk / green_stream_dispatching.py
Created March 9, 2014 16:30
Dispatch items from a generator to two consumer, using greenlets to parallelize operations.
import time
from greenlet import greenlet
##------------------------------------------------------------
##
## We have a producer (a simple generator) and two
## consumers (functions accepting a generator).
##
@rshk
rshk / gist:8242161
Created January 3, 2014 17:24
Jquery Windows
<!DOCTYPE html>
<html><head>
<title>Blah</title>
<style>
body {
background: #ddd;
}
#my-window {
position:absolute;
@rshk
rshk / Example Usage
Last active January 1, 2016 08:19
CliTools with Flask
% pse_admin --help
usage: cli-app [-h] {run,db_init} ...
positional arguments:
{run,db_init} sub-commands
run
db_init
optional arguments:
-h, --help show this help message and exit
@rshk
rshk / .xinitrc
Created November 26, 2013 14:42
#!/bin/bash
## Set a decent keyboard layout..
setxkbmap -layout us -variant altgr-intl &
## This is needed for compositing
(
xrandr --output DP-2 --preferred --primary --pos 0x0 --output LVDS-1 --preferred --pos 1920x300 \
|| xrandr --output DP-2 --preferred --primary --output LVDS-1 --preferred --right-of DP-2 \
|| xrandr --output LVDS-1 --preferred --primary
# Rewrite a bunch of commits to clean 'em up
# We have a bunch of commits we want to reorganize (anything
# after 2a23a731 needs to be reorganized..)
% git log --pretty=oneline
89bee8d13ae1b0047901d07b139d5980072cddbc fourth
984809f2bc6e9598439096dbf4333bbf1aee37d0 third
e714be8487bdbb64eb1efc2caa071695825d633f second
2a23a731833bb701fae3767452865d4120fadcf4 first
@rshk
rshk / timing_context.py
Created May 9, 2013 14:14
Timing context
from collections import OrderedDict
class TimerContext(object):
def __init__(self, name, callback):
self._name = name
self._callback = callback
self._start = None
def __enter__(self):
self._start = time.time()
@rshk
rshk / run_tests.sh
Created April 27, 2013 16:19
Utility script to run Python unittests located in a ``tests`` package in the same directory
#!/bin/bash
ROOTDIR="$( dirname "$0" )"
cd "$ROOTDIR"
if [ $# == 0 ]; then
python -m unittest discover -v
else
"""
Fade IN/OUT some text..
"""
import sys
import time
import pygame
## Show some text fade in/out
"""
Fade IN/OUT some text..
"""
import sys
import time
import pygame
## Show some text fade in/out