Skip to content

Instantly share code, notes, and snippets.

View blooalien's full-sized avatar
🎯
Focusing

Bloo Alien blooalien

🎯
Focusing
View GitHub Profile
@christian-oudard
christian-oudard / term_colors.py
Created October 28, 2009 14:54
Terminal output colors in python
from __future__ import print_function
"""
Utilities for 256 color support in terminals.
Adapted from:
http://stackoverflow.com/questions/1403353/256-color-terminal-library-for-ruby
The color palette is indexed as follows:
0-15: System colors
@christian-oudard
christian-oudard / gfm.py
Created June 29, 2010 18:51
Github Flavored Markdown in Python
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0)).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
@wraithmonster
wraithmonster / process-command-line-options.sh
Created February 17, 2012 14:53
Parse command line options (parameters) in bash.
################################################################################
# Command line processing
################################################################################
# Parse the command line arguments.
while [ "$#" -gt "0" ]; do
case "$1" in
# TODO: Create some script options.
# EXAMPLE: Uncomment below to assign a 'destination directory', DST_DIR,
@wraithmonster
wraithmonster / install-couchdb.sh
Created February 17, 2012 17:46
Installs the latest CouchDB version on Ubuntu from source, not from a repository
#!/bin/bash
# Title: install-couchdb.sh
# Description: Installs the latest CouchDB version from source,
# not from a repository.
# Author: wraithmonster
# Reference: https://github.com/iriscouch/build-couchdb
# http://comments.gmane.org/gmane.comp.db.couchdb.user/16292
# Uninstalling from Ubuntu's repository:
# http://serverfault.com/questions/348044
# http://stackoverflow.com/questions/8783621
@wraithmonster
wraithmonster / install-node.sh
Created February 17, 2012 17:53
Installs node.js on Ubuntu
#!/bin/bash
# Title: install-node.sh
# Description: Installs node.js.
# Author: wraithmonster
# Reference: https://github.com/joyent/node/wiki/Installation
# Web framework - http://expressjs.com/
# Node Pkg Manager - https://github.com/isaacs/npm
#
################################################################################
@wraithmonster
wraithmonster / strip-whitespace.sh
Created March 4, 2012 21:31
Strip whitespace & trailing slashes in bash
# References:
# http://bit.ly/bash-exit-status
# http://bit.ly/bash-remove-slash
# http://www.delorie.com/gnu/docs/wget/wget_27.html
# Strip whitespace
WS=`expr "$1" : '[[:space:]]*\(.*\)[[:space:]]*$'`
# Strip whitespace and remove any trailing slashes
WS_AND_SLASHES=`expr "$1" : '[[:space:]]*\(.*\)[[:space:]]*$' | sed -e 's/\\/$//g'`
@wraithmonster
wraithmonster / marmdir.sh
Created March 4, 2012 22:04
Archive the specified directory, then remove it
#!/bin/bash
################################################################################
#
# Title: marmdir.sh
# Description: Archive the specified directory, then remove it
# Author: wraithmonster
# Reference: http://www.apl.jhu.edu/Misc/Unix-info/tar/tar_28.html
# http://bit.ly/bash-string-length
# http://www.linux.com/archive/feature/120291
@nrk
nrk / command.txt
Created April 2, 2012 19:19
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
# -*- coding: utf-8 -*-
import requests
from PySide import QtGui, QtCore
import sys
class AddressEdit(QtGui.QLineEdit):
def __init__(self, parent):
QtGui.QLineEdit.__init__(self, parent)
@raphigaziano
raphigaziano / qtdbg.py
Last active August 16, 2021 15:12
A simple PyQt output widget which can be used as basic debug console
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
qtdbg.py
A simple PyQt output widget.
It's main use case is to serve as an output console, for debugging or
other purposes.
It provides a file-like interface for ease of integration with other
python features such as the logging module, on top of a slightly