Skip to content

Instantly share code, notes, and snippets.

Stephan Sokolow ssokolow

Block or report user

Report or block ssokolow

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ssokolow /
Created Jun 24, 2009 — forked from ches/
ches's github alias modified for Linux
# Bash alias to open Github page for project in current working directory.
# Will use the current active branch if it exists remotely, or falls back to master.
alias github='br=$(git branch --contains HEAD | sed -rn "s/^\* //p"); if ! git ls-remote . | grep -q -e "refs/remotes/.*/${br}"; then br="master"; fi; xdg-open $(git config -l | sed -rn "s%remote.origin.url=git(@|://)(|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
ssokolow /
Created Jun 25, 2009
xkill-style screensaver-disabling which won't leave it disabled by accident
# A simple little script which prompts you to click a window and then disables
# the screensaver until it goes away.
WID=`xwininfo -int | awk '/Window id/ {print $4}'`
xdg-screensaver suspend "$WID"
ssokolow /
Created Jun 25, 2009
How to fake a gtk.RadioToolButton group where you can set all buttons inactive
# PyGTK doesn't let you set_active(False) on all radio buttons.
# You can work around that by adding a button to the group which will never
# be made visible to the user. (Don't add it to any window)
self.zoom_100 = self.wTree.get_widget("zoom_100")
self.zoom_fit = self.wTree.get_widget("zoom_fit")
self.zoom_manual = gtk.RadioToolButton(self.zoom_100)
ssokolow /
Created Jun 25, 2009
How to get the current selection in HTML rather than plaintext
getSelectionHTML = ->
# Everyone but IE supports DOM selections
if window.getSelection
sel = window.getSelection()
# IE Selections (Must come last to avoid messing with Opera)
else if document.selection
return document.selection.createRange().htmlText
# Fail safely
return ""
ssokolow /
Created Jun 25, 2009
Modification of PyGTK's EntryCompletion example with shell-like tab completion.
#!/usr/bin/env python
"""Modification of PyGTK's EntryCompletion example with shell-like tab completion.
Tab works normally unless there's content, the cursor is at the end of it,
and nothing is selected, preserving intuitive tab-cycling behaviour in all
reasonable cases while still allowing comfortable tab completion.
(To tab-cycle into a field with content in it and then tab-complete, just press
End before you request completion)
If no completions are found, users may press Tab again to go to the next field.
ssokolow /
Last active Mar 31, 2019
Python boilerplate from which I start all my projects
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""[application description here]"""
__appname__ = "[application name here]"
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__version__ = "0.0pre0"
__license__ = "GNU GPL 3.0 or later"
import logging
ssokolow / LCDd.conf
Created Nov 3, 2009
LCDd.conf for PCIDEA 20x4 USB LCD
View LCDd.conf
## CrystalFontz packet driver (for CF631, CF633 & CF635) ##
# Select the LCD model [default: 633; legal: 631, 633, 635]
# Select the output device to use [default: /dev/lcd]
ssokolow / pagination_example.sql
Created Dec 23, 2009
Reasonably efficient pagination without OFFSET (SQLite version)
View pagination_example.sql
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source:
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ssokolow / background-page.html
Created Jun 29, 2010 — forked from romannurik/background-page.html
Simple cross-domain XHR boilerplate for Chrome extensions. Modified to be more useful for POST
View background-page.html
<!DOCTYPE html>
<script src="xhrproxy.js"></script>
ssokolow /
Created Jul 28, 2010
Template for custom Distutils commands with dependencies
"""Template for custom Distutils commands with dependencies"""
from distutils.core import Command
commands = {}
from third_party_package import something
class MyCommand(Command):
description = "Use ThirdPartyPackage™ to frob the project source"
You can’t perform that action at this time.