Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
class BaseMenuItem {
public:
virtual void show() = 0;
virtual BaseMenuItem *next(int input) = 0;
virtual int input() {
int inp;
std::cin >> inp;
#! /bin/bash
# readonlyroot.sh -- Setup dirs on the tmpfs to keep the root partition read-only
# See-Also: http://roland.entierement.nu/pages/debian-on-soekris-howto.html
# Available-At: https://gist.github.com/1216392
#
# Place this file in /etc/init.d and run:
# sudo update-rc.d readonlyroot.sh start 04 S
#
# To maintain persistent data, place a file at /etc/cron.d/readonlyroot as:
# 0 * * * * root /etc/init.d/readonlyroot.sh save >/dev/null
/* emacs settings: -*- c-basic-offset: 8 tab-width: 8 -*-
*
* pgrep/pkill -- utilities to filter the process table
*
* Copyright 2000 Kjetil Torgrim Homme <kjetilho@ifi.uio.no>
*
* May be distributed under the conditions of the
* GNU General Public License; a copy is in COPYING
*
* Changes by Albert Cahalan, 2002,2006.
@atorkhov
atorkhov / gist:5671059
Created May 29, 2013 15:12
Config parsing with argument handling
#!/usr/bin/env python
import argparse
import ConfigParser
class FakeSecHead(object):
def __init__(self, fp):
self.fp = fp
self.name = fp.name
self.sechead = '[DEFAULT]\n'
@atorkhov
atorkhov / gist:5534981
Last active December 17, 2015 02:19
Deform File Upload Temp Store
# http://pastebin.com/prQgYHzQ
import os
from deform.interfaces import FileUploadTempStore
from datetime import datetime, timedelta
import pickle
from cStringIO import StringIO
class BeakerTempStore(FileUploadTempStore):
@atorkhov
atorkhov / gist:5403562
Created April 17, 2013 11:31
PIL word wrap
# http://tanner-tech.googlecode.com/svn-history/r197/trunk/NewWorldMap/cardgen/eniCards.py
import Image, ImageDraw, ImageFont
# load an existing image
photo = Image.open("lyn.jpg")
photoSize = photo.size
# create a new, empty image
card = Image.new('RGB', (600, 600), color=(255,255,255))
@atorkhov
atorkhov / gist:3664384
Created September 7, 2012 08:36
Enumerate v4l devices and show their info
// From zarvox.org/shortlog/static/recorder.py
def choose_camera_device():
"""Lets the user pick an external video device to use from /dev/video*"""
videodevs = ["/dev/" + x for x in os.listdir("/dev/") if x.startswith("video") ]
#print videodevs
if len(videodevs) == 1:
print "Found exactly one video device; using", videodevs[0]
return videodevs[0]
if len(videodevs) == 0:
@atorkhov
atorkhov / 20-custom-ehci-hcd
Created January 7, 2012 10:10
custom-ehci-hcd rpm
#!/bin/sh
#inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug
# tidied by tqzzaa :)
VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"