Skip to content

Instantly share code, notes, and snippets.

☎️
call me on my #!/bin/sh phone

Matthew Loberg mloberg

☎️
call me on my #!/bin/sh phone
Block or report user

Report or block mloberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mloberg
mloberg / Guardfile
Last active Aug 29, 2015
guard-jekyll
View Guardfile
require 'jekyll'
module ::Guard
class Jekyll < Guard
def start
puts "Starting Jekyll on port #{port}"
options = ::Jekyll.configuration({:serving => true, :watch => true, :port => port})
p = ::Process.fork do
::Jekyll::Commands::Build.process(options)
::Jekyll::Commands::Serve.process(options)
View lock.py
import sys
import fcntl
LOCK_EX = fcntl.LOCK_EX
LOCK_SH = fcntl.LOCK_SH
LOCK_NB = fcntl.LOCK_NB
class Flock(object):
@mloberg
mloberg / gist:5469030
Last active Dec 16, 2015
Append a gitignore template to your local .gitignore.
View gist:5469030
#!/usr/bin/env python
import os
import sys
import fcntl
import termios
import struct
import urllib2
import json
GITIGNORE_URL = "https://api.github.com/gitignore/templates"
@mloberg
mloberg / com.gitlab.gitlab.plist
Created Dec 3, 2012
Gitlab LaunchD Startup Script
View com.gitlab.gitlab.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/Cellar/ruby/1.9.3-p125/bin:/usr/local/share/npm/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin:/usr/local/sbin:/usr/X11/bin:/Users/gitlab/.rvm/bin</string>
</dict>
<key>KeepAlive</key>
@mloberg
mloberg / redis.php
Created Oct 18, 2012
PHP Redis Class
View redis.php
<?php
class Redis {
const CRLF = "\r\n";
private $connection;
/**
* Create a new instance of the class.
@mloberg
mloberg / sifter.php
Created Oct 4, 2012
PHP Sifter API Class
View sifter.php
<?php
/**
* A simple PHP class to interact with the Sifter API.
*/
class Sifter
{
/**
* Sifter account hostname (example.sifterapp.com)
@mloberg
mloberg / gist:3750653
Created Sep 19, 2012
Find file in git based on md5 checksum.
View gist:3750653
#!/bin/sh
CHECKSUM=$1
FILE=$2
if [[ -z "$CHECKSUM" ]]; then
echo "Usage: $0 md5 file"
exit 1
elif [[ -z "$FILE" ]]; then
echo "Usage: $0 md5 file"
View .vimrc
"Don't think about using arrow keys in vim
noremap <Up> :q!<Enter>
noremap! <Up> <Esc>:q!<Enter>
noremap <Down> :q!<Enter>
noremap! <Down> <Esc>:q!<Enter>
noremap <Left> :q!<Enter>
noremap! <Left>
@mloberg
mloberg / gist:3099019
Created Jul 12, 2012
Simple Load Test
View gist:3099019
#!/bin/sh
REQUEST="http://example.com"
NUM_REQ=100
CONCURENT=10
# Set up parallel processes (http://mlo.io/blog/2012/06/13/parallel-processes-in-bash.html)
mkfifo pipe
exec 3<>pipe
rm -rf pipe
@mloberg
mloberg / gist:3084643
Created Jul 10, 2012
Find and cd to projects.
View gist:3084643
#!/usr/bin/env bash
# Add or source this from .bash_profile/.bashrc
# usage: project project_name
PROJECT_DIR="~/Code"
project() {
PROJECTS=( $(find $PROJECT_DIR -type d -iname "$1") )
if [[ "${#PROJECTS[@]}" -gt 1 ]]; then
You can’t perform that action at this time.