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
ssokolow / snippet.sh
Created Jun 24, 2009 — forked from ches/snippet.sh
ches's github alias modified for Linux
View snippet.sh
# 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(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
@ssokolow
ssokolow / saver_disabler.sh
Created Jun 25, 2009
xkill-style screensaver-disabling which won't leave it disabled by accident
View saver_disabler.sh
#!/bin/sh
# 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
ssokolow / radiobuttons_with_none_selected.py
Created Jun 25, 2009
How to fake a gtk.RadioToolButton group where you can set all buttons inactive
View radiobuttons_with_none_selected.py
# 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
ssokolow / get_selection_html.coffee
Created Jun 25, 2009
How to get the current selection in HTML rather than plaintext
View get_selection_html.coffee
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
else
return ""
@ssokolow
ssokolow / completer_entry.py
Created Jun 25, 2009
Modification of PyGTK's EntryCompletion example with shell-like tab completion.
View completer_entry.py
#!/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
ssokolow / boilerplate.py
Last active Mar 31, 2019
Python boilerplate from which I start all my projects
View boilerplate.py
#!/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
ssokolow / LCDd.conf
Created Nov 3, 2009
LCDd.conf for PCIDEA 20x4 USB LCD
View LCDd.conf
[server]
Driver=CFontzPacket
## CrystalFontz packet driver (for CF631, CF633 & CF635) ##
[CFontzPacket]
# Select the LCD model [default: 633; legal: 631, 633, 635]
Model=631
# Select the output device to use [default: /dev/lcd]
Device=/dev/ttyUSB0
@ssokolow
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: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@ssokolow
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>
<html>
<head>
<script src="xhrproxy.js"></script>
<script>
setupXHRProxy();
</script>
</head>
@ssokolow
ssokolow / distutils_command_template.py
Created Jul 28, 2010
Template for custom Distutils commands with dependencies
View distutils_command_template.py
"""Template for custom Distutils commands with dependencies"""
from distutils.core import Command
commands = {}
try:
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.