Skip to content

Instantly share code, notes, and snippets.

@lukemartin
lukemartin / gist:4121867
Created November 20, 2012 23:00
AppleScript: Smart Archive for multiple inboxes in Mail.app
tell application "Mail"
set selected_messages to selection
repeat with a_message in selected_messages
set a_message_mailbox to name of mailbox of a_message
if a_message_mailbox is "INBOX" then
tell application "Mail"
move the a_message to mailbox "INBOX/Archive" of account "FastMail"
end tell
else if a_message_mailbox is "anotherinbox" then
@lukemartin
lukemartin / gist:4071683
Created November 14, 2012 11:44
Shell: Unzip all zips in directory with containing folder
#!/bin/bash
for f in *.zip; do
dir=${f%.zip}
unzip -d "./$dir" "./$f"
done
@lukemartin
lukemartin / gist:4058590
Created November 12, 2012 10:41
Copy public key to remote authorized_files
cat ~/.ssh/id_rsa.pub | ssh user@machine "cat >> ~/.ssh/authorized_keys"
@lukemartin
lukemartin / routes.php
Created June 22, 2012 10:51
Output checkboxes with appropriate 'checked' attributes in Laravel
Route::get('edit', function() {
// fetch our post, and it's associated categories
$post = Post::with('cats')->where('id', '=', $id)->first();
// fetch all of our categories
$cats = Cat::all();
// create our empty array
$post_cats = array();
@lukemartin
lukemartin / gist:2230018
Created March 28, 2012 20:02
JavaScript: jQuery Namespaced Function
Web.Global = (function($) {
function init()
{
}
return {
init: init
}
@lukemartin
lukemartin / gist:1292433
Created October 17, 2011 11:27
Regex: Remove comma from last object property
Find: (\S+:\s*[\S]+),(\s+})
Replace: $1$2
@lukemartin
lukemartin / gist:1162843
Created August 22, 2011 16:34
RegEx - Add spaces to Zen Coding's replacements
Find:
("[\S]+": ")([a-z\-]+:)([a-z\-|]+)
Replace:
$1$2 $3
@lukemartin
lukemartin / gist:1096955
Created July 21, 2011 10:53
JavaScript: JSHint parameters
/*jshint asi: false, curly: true, debug: false, eqeqeq: true, onevar: true, undef: true */
/*global jQuery: true, setTimeout: true */
@lukemartin
lukemartin / gist:1094751
Created July 20, 2011 10:43
CSS: Horizontally centre list items
ul {
float: left;
left: 50%;
margin: 0;
padding: 0;
position: relative;
}
ul li {
float: left;
left: -50%;
@lukemartin
lukemartin / gist:1094564
Created July 20, 2011 08:16
Facebook: Auto-resize height of iframe
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: 'APP_ID_HERE',
status: true,
cookie: true,
xfbml: true
});