Skip to content

Instantly share code, notes, and snippets.

View jonlabelle's full-sized avatar

Jon LaBelle jonlabelle

View GitHub Profile
@jonlabelle
jonlabelle / mdpreview.sh
Last active December 23, 2015 19:09
A simple Sublime Text Build System for Markdown source.
#!/usr/bin/env bash
#
# Sublime Text 2|3 Markdown Build System
#
# This Sublime Text 2|3 build system simply takes Markdown source as an
# arg(1) and parses the HTML for previewing in a browser window.
#
# **Requirements**
#
# - Sublime Text 3 <http://www.sublimetext.com>
@jonlabelle
jonlabelle / atomic_time.py
Last active December 25, 2015 03:39
Fetch atomic time for your current locale in Python.
#!/usr/bin/env python
import re
import urllib2
def fetch_data():
return str(urllib2.urlopen('http://time.is').read())
@jonlabelle
jonlabelle / rp.py
Last active December 25, 2015 05:49
Return the canonical path (real path) of the specified filename, eliminating any symbolic links encountered in the path.
#!/usr/bin/env python
import os.path as filepath
import sys
from optparse import OptionParser
def main():
parser = OptionParser(
prog='rp', usage="%prog [path]\n\nReturn the canonical path of the specified filename\n\n [path]\tpath of file to check\n\n when *no args* are passed, the current working directory\n will be set as [path].")
@jonlabelle
jonlabelle / datauri.sh
Last active June 18, 2016 18:17
Bash function that creates a data URI scheme for a file.
#!/usr/bin/env bash
# generate data uri scheme for file
function datauri()
{
local mimeType=$(file -b --mime-type "$1")
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8"
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
@jonlabelle
jonlabelle / update-sublime-packages.sh
Last active December 26, 2015 04:28
A Bash function that updates Sublime Text packages which aren't under package control, and have git repositories.
# update all non-sublime package control packages (osx)
function update_sublimetext_packages()
{
echo ""
echo "==> Updating Sublime Text Packages"
echo ""
local cwd=$(pwd)
local subl_pkgs_dir=~/Library/Application\ Support/Sublime\ Text\ 3/Packages
local repo=
@jonlabelle
jonlabelle / show.sh
Last active July 12, 2022 15:48
Bash functions to output colorized messages in the terminal, according to context.
# show a cyan `OK!`, or arg `1` message
function show_info()
{
local msg="OK!"
if [ ! -z "$1" ]; then
msg="$1"
fi
echo -e "\033[0;36m${msg}\033[0m"
}
@jonlabelle
jonlabelle / television_resolution_standards.md
Last active May 5, 2024 04:02
Digital and analog television standards resolution reference.

Television Standards

Digital and analog television standards resolution reference.

Digital TV Standards

Standard Resolution (dots × lines) DAR (H:V) Pixels
PixelVision 120 × 90 4:3 10,800
@jonlabelle
jonlabelle / aspdotnet-razor-syntax-reference.md
Last active November 11, 2022 15:48
ASP.NET Razor Syntax Reference

ASP.NET Razor Syntax Reference

Code Block

@{
    int x = 123;
    string y = "because.";
}

Expression (Html Encoded)

@jonlabelle
jonlabelle / node-static-file-server.js
Created March 21, 2014 16:25
Simple node.js static file server.
var path = require('path');
var fs = require('fs');
//
// Configuration
//
var config = {
@jonlabelle
jonlabelle / iis7_command_line_tool.md
Created April 17, 2014 21:41
IIS 7 Command Line Tool

IIS 7 Command Line Tool

AppCmd.exe IIS 7 command-line tool used to perform common IIS administrative tasks such as creating new sites, stopping/starting services, and viewing status of the site.

Usage

appcmd (command) (object-type) <identifier> </parameter1:value1 ...>