Skip to content

Instantly share code, notes, and snippets.

View ambethia's full-sized avatar
🐼
PANDAS!

Jason L Perry ambethia

🐼
PANDAS!
View GitHub Profile
# Bash prompt
parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/[git: \1$(parse_git_dirty)]/"
}
export PS1="\n\033[1m\[\`if [[ \$? = "0" ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi\`\033[0m \w \$(parse_git_branch)\n∴ "
@ambethia
ambethia / ssh_agent.sh
Created December 1, 2009 20:23
Automagically setup SSH agent crap in your bash profile
SSH_ENV=$HOME/.ssh/environment
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
echo succeeded
chmod 600 ${SSH_ENV}
. ${SSH_ENV} > /dev/null
/usr/bin/ssh-add;
}
@ambethia
ambethia / gist:254408
Created December 11, 2009 18:47
Rename *.html.erb to *.erb
for x in `find . -type f -name \*.html.erb`; do
mv $x `echo $x | sed 's/\(.*\.\)html\.erb/\1erb/'`;
done
#!/usr/bin/env ruby
#
# auth-aloha.rb - OpenVPN auth script for Aloha
#
# Created by Jason Perry on 2009-12-12.
# Copyright (c) 2009 Gray's College Bookstore. All rights reserved.
#
# Usage:
# auth-user-pass-verify /path/to/auth-aloha.rb via-file
#

Autodesk Animator

http://forums.tigsource.com/index.php?topic=2916.0

Home, sweet Home! This is the interface you'll have for most of the time. As a rule of thumb, left mouse button (LMB) will do standard actions, while right mouse button (RMB) will go into relevant setup/option interface of some sort. For example, LMB on the Zoom button will let you select an area to zoom into. RMB on the Zoom button will allow to to pick the degree of zoom. So, if you use the LMB in the open area, you will draw with the selected tools. RMB will hide and show the Home frame. You can also use "Space" for this. Oh, and if you ever get stuck in an interface bit where you want to exit, you can just RMB over the open area, or press "Space".

Now, onto the specifics!

@ambethia
ambethia / rails-3.0-pre-dev-stack-snow-leopard.md
Created February 3, 2010 17:31
Rails Dev Stack on Snow Leopard

Rails Dev Stack on Snow Leopard

(from a scratch install). Kinda, I imported my user home (~) from a Time Machine backup.

Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
@ambethia
ambethia / CXMLNode+JSON.h
Created February 5, 2010 00:12
Category for TouchXML to convert a node to JSON. It won't provide fully valid JSON from any XML data, but it met my needs.
//
// CXMLNode+JSON.h
//
// Created by Jason L Perry on 1/24/10.
// Copyright 2010 Ambethia. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TouchXML.h"
HoptoadNotifier.notify(:error_class => "video_manipulator:thumbnail",
:error_message => ex.message,
:backtrace => ex.backtrace,
:parameters => {:options => options})
versus
HoptoadNotifier.notify( :error_class => "video_manipulator:thumbnail",
:error_message => ex.message,
:backtrace => ex.backtrace,
@ambethia
ambethia / extract_value.c
Created February 23, 2010 00:34
Regex example in c
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
char *extract_value(char *string, char *pattern)
{
int begin, end, length, i, w=0;
char *word = NULL;
regex_t regex;
regmatch_t match[2];
@ambethia
ambethia / html5-upload-progress.js
Created March 9, 2010 04:17
HTML5 Upload Progress
var xhr = new XMLHttpRequest();
xhr.upload['onprogress'] = function(xhrpe) {
console.log(xhrpe);
};
var file = document.getElementById('source').files[0];
xhr.open("POST", this.action, true);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");