Skip to content

Instantly share code, notes, and snippets.

View mgirouard's full-sized avatar
🤘

Michael Girouard mgirouard

🤘
View GitHub Profile
@mgirouard
mgirouard / git-snippets.markdown
Created February 29, 2012 15:29
Random, but incredibly awesome Git snippets to remember

Set an existing local branch to track another local branch

Use git-branch with a --set-upstream flag:

$ git branch --set-upstream v1.0.10 development
Branch v1.0.10 set up to track local branch development.

Set an existing local branch to track a remote branch

Similar to the above, git branch be used to set an existing local branch to track an upstream remote, without push'ing:

@mgirouard
mgirouard / sample.conf
Created March 5, 2012 22:14
302 via mod_rewrite
RewriteRule   ^.*$  http://example.com/ [R=301,L]
@mgirouard
mgirouard / ie-newline-bug.php
Created March 7, 2012 21:15
Source code to break IE text rendering for long lines.
<?php
header('content-type: text/plain');
if (isset($_GET['s'])) {
die(file_get_contents(__FILE__));
}
$text = 'Thequickbrownfoxjumpedoverthelazydog';
<?php
Example::app(function ($app) {
extract($app->load('request', 'response', 'security', 'error'));
$security->authenticated()
|| $error->send(302, '/login');
extract($app->load('router'));
@mgirouard
mgirouard / 960-12.css
Created March 28, 2012 02:42
Minimal Boilerplate for HTML5 Apps
/*
Variable Grid System.
Learn more ~ http://www.spry-soft.com/grids/
Based on 960 Grid System - http://960.gs/
Licensed under GPL and MIT.
*/
/*
Forces backgrounds to span full width,
<?php
/**
* Method to handle cart Action - add product
*
* @param string forward destination
* @param url parameters
*/
function actionAddProduct($goto, $parameters) {
global $messageStack, $db;
@mgirouard
mgirouard / gist:2779213
Created May 24, 2012 03:09
Git, Simply.
# Create a new project
mkdir my-project
cd my-project
git init
echo '.DS_Store' >> .gitignore
echo '*.sw*' >> .gitignore
git add .gitignore && git commit -m 'First!'
git branch development
# Set up a development remote
@mgirouard
mgirouard / states.html
Last active September 21, 2018 16:09
US State List
<select name="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
@mgirouard
mgirouard / chmod.sh
Created April 5, 2013 04:05
Setting proper directory permissions for server user + standard user
# MacOS only
sudo chmod +a "USERNAME allow delete,write,append,file_inherit,directory_inherit" TARGET
@mgirouard
mgirouard / setup-import-db.sh
Created April 7, 2013 21:52
One-liner to quickly set up a MySQL DB and import data from a given file
#!/bin/bash
#
# $U = DB User
# $N = DB Name
#
mysql -u $U -p <<< "CREATE DATABASE $D DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; use $D; source data/$D.sql;"