Skip to content

Instantly share code, notes, and snippets.

@Hubro
Hubro / apline
Created January 23, 2015 14:58
Command for appending/prepending text to lines
#!/bin/bash
# Append/prepend text to line
function usage
{
echo -e "Usage: $(basename "$0") [a|p] TEXT"
echo
echo -n "apline reads from standard input and appends/prepends TEXT to "
echo "each line."
@Hubro
Hubro / pyenv.sh
Created June 13, 2012 13:28
Python virtual environment selector
function pyenv() {
VIRTUALENVS_PATH=~/pyenvs
# Procure env name. If it was supplied in an argument, use that
if [[ "$1" != "" ]]
then
VIRTUALENV_NAME=$1
else
# Otherwise prompt the user for it
VIRTUALENV_NAME=""
@Hubro
Hubro / report_to_json.php
Created March 27, 2012 14:32
Function for converting an xml report from Yahoo Web Analytics into a json format
<?php
# Function for converting an xml report into a json format
function report_to_json($path)
{
# Check if the file exists
if(!file_exists($path)) return false;
# Set content type to json and charset to utf-8
# header('Content-type: application/json; charset=utf-8');
@Hubro
Hubro / gist:1876138
Created February 21, 2012 12:05
Shortcut function for top-down css gradients, written in stylus
// Shortcut for top-down gradient background color
td_gradient(color1, color2)
background-color (color1 + (color2 - color1) / 2)
background -webkit-gradient(linear, 0% 0%, 0% 100%, from(color1), to(color2))
background -webkit-linear-gradient(top, color1, color2)
background -moz-linear-gradient(top, color1, color2)
background -ms-linear-gradient(top, color1, color2)
background -o-linear-gradient(top, color1, color2)
@css
{