Skip to content

Instantly share code, notes, and snippets.

View mgirouard's full-sized avatar
🤘

Michael Girouard mgirouard

🤘
View GitHub Profile
@mgirouard
mgirouard / uri.js
Created October 9, 2013 22:27 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
<?php
$properties = array(
'y' => 'years',
'm' => 'years',
'd' => 'years',
'h' => 'years',
'i' => 'years',
's' => 'years',
);
@mgirouard
mgirouard / scroll-to.js
Created September 27, 2013 17:33
How to animate a scroll to an element on a page, without a plugin
// via http://stackoverflow.com/questions/6677035/jquery-scroll-to-element
$('html,body').animate({ scrollTop: $('#target').offset().top }, 500)
var years = {};
$('.blog-sidebar .widget_archive a').each(function () {
var year = this.innerHTML.match(/\d{4}/)[0];
if (!years[year]) years[year] = [];
years[year].push(this);
});
_.each(years, function (links, year) {
var li = $('<li/>'), a = $('<a/>'), ul = $('<ul/>');
<?php
header('Content-type: text/plain');
print_r($_REQUEST);
exit;
@mgirouard
mgirouard / git-deploy
Last active December 22, 2015 02:20
A minimal git deployment script
#!/bin/bash
git push $1 +HEAD:master
git fetch $1
git push origin --tags
@mgirouard
mgirouard / post-receive
Last active December 17, 2015 22:09
An informative post-receive hook. Useful if you do git deployments.
#!/bin/sh
# Receive <oldrev> <newrev> <refname>
read oldrev newrev refname
# The darget of the deployment
target=/var/www/vhosts/www.example.com
echo Deploying to $target
echo =======================================================
@mgirouard
mgirouard / gist:5679951
Created May 30, 2013 18:23
Tag a deployment, on the quick
git tag deployment-`date +'%Y%m%d%H%M%S'`
@mgirouard
mgirouard / gist:5670408
Created May 29, 2013 13:53
An easy way of updating a local WordPress site from a production instance.
cd /path/to/Example
scp [email protected]:production.sql
mysql -u root dev_example < production.sql
mysql -u root dev_example <<< 'UPDATE wp_options SET option_value = "http://example.local" WHERE option_name IN ("home","siteurl")'
rm production.sql
scp [email protected]:uploads.tgz .
tar -xvzf uploads.tgz
rm uploads.tgz
@mgirouard
mgirouard / zip-locater.js
Last active December 17, 2015 17:09
A simple zip code locater component
// http://jsfiddle.net/6R5Ea/3/
// App Namespace
(function ($j, $u, $b) {
var App = window.app = {};
})(window.jQuery, window._, window.Backbone);
// Zip Locater Application
// =======================
(function ($j, $u, $b) {