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")'
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"
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)
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 ""
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.
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
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
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
View background-page.html
<!DOCTYPE html>
<html>
<head>
<script src="xhrproxy.js"></script>
<script>
setupXHRProxy();
</script>
</head>
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"