Skip to content

Instantly share code, notes, and snippets.


Stefan Crain stefancrain

View GitHub Profile
View jQuery HTML5 placeholder fix.js
// Released under MIT license:
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
}).blur(function() {
var input = $(this);
rsvp /
Last active May 13, 2020 : check download speed rate via command line | Linux bash script
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2013-07-11
# _______________| netspeed : check download speed via command line.
# Usage: netspeed [tokyo, london, usw, use, east, west, URL]
# ^default U.S. west coast.
# [ -speed_KB/sec ]
# ^negation activates the Mbps converter.
kwharrigan /
Created Apr 12, 2012
MKS fast-import script for git
#Copyright (c) 2012 Kyle Harrigan
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
obscurerichard /
Created Sep 17, 2012
Simulates a low bandwidth, high-latency network connection


This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default
slow modem-56k -d eth0    # Simulate a 56k modem on the eth1 device. eth0 is unchanged.
juanje / gist:3797297
Created Sep 28, 2012
Mount apt cache of a Vagrant box in the host to spin up the packages installation
View gist:3797297

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir ='cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
ecampidoglio /
Created Feb 21, 2013
A Bash script that prints the current state of the CPU on a Raspberry Pi. It displays variables like temperature, voltage and speed.
# cpustatus
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"
matthewbednarski / postal-codes.json
Last active Dec 14, 2020
Global postal codes regex formats
View postal-codes.json
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$"}, { "Note":
cirrusUK / config
Last active Sep 24, 2020
newsboat config
View config
# ░░░░░░ ░░░░░░ ░░ ░░ ░░░░░░ ░░░░░░ ░░ ░░░░░░░░ ░░░░░░ ░░ ░░ ░░░░░ ░░░░░░
# ███╗ ██╗███████╗██╗ ██╗███████╗██████╗ ███████╗██╗ ██╗████████╗███████╗██████╗
# ████╗ ██║██╔════╝██║ ██║██╔════╝██╔══██╗██╔════╝██║ ██║╚══██╔══╝██╔════╝██╔══██╗
# ██╔██╗ ██║█████╗ ██║ █╗ ██║███████╗██████╔╝█████╗ ██║ ██║ ██║ █████╗ ██████╔╝
# ██║╚██╗██║██╔══╝ ██║███╗██║╚════██║██╔══██╗██╔══╝ ██║ ██║ ██║ ██╔══╝ ██╔══██╗
# ██║ ╚████║███████╗╚███╔███╔╝███████║██████╔╝███████╗╚██████╔╝ ██║ ███████╗██║ ██║
# ╚═╝ ╚═══╝╚══════╝ ╚══╝╚══╝ ╚══════╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
# ░░░░░░ ░░░░░░ ░░ ░░ ░░░░░░ ░░░░░░ ░░ ░░░░░░░░ ░░░░░░ ░░ ░░ ░░░░░ ░░░░░░
# ▓▓▓▓▓▓▓▓▓▓
# ░▓ author ▓ cirrus <>
Dhertz /
Last active Aug 8, 2020
Quick overview of how to get Apple's new TV screensavers working on most linux systems.

Using Apple’s Aerial Screensavers on Ubuntu After coming across the [Aerial] ( screensavers for Mac, and installing them, I decided that I had had enough of the graphics-demos of my Ubuntu Precise system. I hope to provide a simple guide on how to add them to your setup as well.

First, you need to install xscreensaver (for example with aptitude, but your distro should have it):

sudo aptitude install xscreensaver
Matthewspear / selfcontrol-aliases
Last active Jul 29, 2016
SelfControl Terminal Shortcuts
View selfcontrol-aliases
# Add these lines to ~/.bash_profile or ~/.zshrc:
# SelfControl
alias sc-read="defaults read org.eyebeam.SelfControl"
alias sc-run="sudo /Applications/ $(id -u $(whoami)) --install"
alias sc-check="sudo /Library/PrivilegedHelperTools/org.eyebeam.SelfControl $(id -u $(whoami)) --checkup"
if [ "$1" = "" ]; then