Skip to content

Instantly share code, notes, and snippets.

View zmpeg's full-sized avatar

Matt Zandstra zmpeg

View GitHub Profile
@zmpeg
zmpeg / database.php
Created December 21, 2011 15:31
CakePHP Automatic Database Environment Detection
<?
class DATABASE_CONFIG {
var $default = false;
var $prod = array(
'driver' => 'mysql',
'persistent' => true,
'host' => 'localhost',
'login' => 'prod_user',
@zmpeg
zmpeg / usage.html
Created January 27, 2012 21:01
showfor usage
<!DOCTYPE>
<html>
<head>
<title>showfor</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="showfor.jquery.js"></script>
<script type="text/javascript">
$(function() {
$("#b").showfor("#a", { hideChild:true, disableChild:true });
});
@zmpeg
zmpeg / test.php
Created May 11, 2012 18:08
WorkETC API SetCompany
// Convert to
$setcompany = new stdClass();
$setcompany->company = new stdClass();
$setcompany->company->Branches = new stdClass();
$setcompany->company->Branches->Branch = new stdClass();
$setcompany->company->Branches->Branch->BranchID = 0;
$setcompany->company->Branches->Branch->BranchName = "TEST TEST";
// Make call
$result = $worketc->SetCompany($setcompany);
@zmpeg
zmpeg / wofind.sh
Created December 3, 2012 15:48
Script to recursively grep for files in WebObjects and print their locations nicely.
#!/bin/sh
for A in `grep -r "$1" | awk '{print $1}' | grep html`; do basename $A; done | sort | uniq
@zmpeg
zmpeg / zsh.zprofile
Last active December 11, 2015 03:39
my zsh config
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
@zmpeg
zmpeg / extend.sh
Last active December 15, 2015 19:48
extend desktop with xrandr. Usage: ./extend.sh [dir] where [dir] is 'left' or 'right' or 'clone'
#!/bin/bash
if [ -z "$1" ]; then
xrandr --output HDMI1 --mode 0x0
else
RES=`xrandr | grep -A1 HDMI1 | tail -n1 | awk '{ print $1 }'`
echo "Detected HDMI1 with resolution ${RES}"
if [ "$1" == "right" ] || [ "$1" == "left" ]; then
echo "Extending HDMI1 to the {$1} of eDP1"
@zmpeg
zmpeg / markup_indenter.rb
Last active December 15, 2015 20:29
Indent markup, removing cruft and matching indent lines.
#!/usr/bin/env ruby
IGNORE = ['BR', 'META', '!DOCTYPE', '!--']
def tab_change(tag)
tagname = tag.upcase.split(/[\s|>]/).first[1..-1]
is_open = tag[1] != '/'
return 0 if IGNORE.include? tagname
return 0 if is_open && tag.include?("/#{tagname}")
is_open ? 1 : -1
@zmpeg
zmpeg / README.md
Last active August 12, 2019 20:15
go.sh

go.sh

A simple script to open a dynamic ssh tunnel to your server and connect a fresh chrome browser to it via the socks5 proxy.

Installation

Clone the repo and maybe symlink/shortcut the version you need to somewhere convenient.

git clone https://gist.github.com/8911e3b78a8873612e17.git $HOME/opt/go.sh

@zmpeg
zmpeg / shoot-osx.sh
Last active November 29, 2016 16:54
shoot
#!/bin/bash
#
# Takes a screenshot, puts the URL in your clipboard,
# Then syncronizes the screenshot to your configured host
LOCALDIR="$HOME/Pictures/screenshots/"
REMOTEHOST="mjz.me"
REMOTEDIR="/home/matt/public/mjz.me/public/s/"
TIMESTAMP=`date +%s`
WEBHOST="http://tesera.screenshots.s3-website-us-east-1.amazonaws.com/"
@zmpeg
zmpeg / post-receive.sh
Created March 3, 2015 04:05
Git post-receive deploy hook for simple node apps using screen. Place this in a file in a bare repo under hooks/post-receive.
#!/bin/bash
DEPLOY_DIR="$HOME/apps/my-app/"
SCREEN_NAME="my-app"
echo "Deploying"
GIT_WORK_TREE="${DEPLOY_DIR}" git checkout -f master
echo "Loading nvm, node, npm"
export NVM_DIR="/home/deploy/.nvm"