Skip to content

Instantly share code, notes, and snippets.

@trevershick
trevershick / gist:4648928
Last active December 11, 2015 19:29
Simple Python List Comprehension Example
>>> [ (e.id, e.title) for e in Entry.objects.all() if e.status == Entry.STATUS_LIVE ]
[(5, u'Test Entry 2'), (3, u'Test Title 0')]
@trevershick
trevershick / MakeYojimboNoteFromFlaggedEmail.applescript
Last active December 22, 2015 01:19
Applescript to take flagged e-mail in Apple Mail and create Yojimbo items tagged with 'todo'. I sourced quite a bit of this from multiple places. I apologize for not keeping the references...
#! /usr/bin/osascript
set _count to 0
if not (application "Mail" is running and application "Yojimbo" is running) then
return
end if
tell application "Mail"
repeat with _account in accounts
try
set _inbox to _account's mailbox "Inbox"
@trevershick
trevershick / WatchMe.java
Created October 16, 2013 13:56
Sample code showing how even after a Guava transform, the underlying collection may still be altered.
import static com.google.common.collect.Collections2.transform;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@trevershick
trevershick / console.js
Last active August 29, 2015 14:15
Simple, easy to use console replacement script for use in JsFiddle...
if (typeof($) === 'undefined') {
alert('jquery is required');
}
$("body").append($('<div id="console-log"></div>').css({
backgroundColor:'black',
color:'#33FF00',
padding:3
}));
var consoleLineCss = {
// thanks https://gist.github.com/thomseddon/3511330
function formatBytes(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
@trevershick
trevershick / svn_short_log
Last active September 12, 2018 22:13 — forked from plexus/svn_short_log
svn log, one line per commit
#!/usr/bin/awk -f
# Convert the "svn log" output into a one liner format, which is easier to grep
# or use in scripts. Pipe "svn log" into this script
# When we get a line that starts with a revision number, put the data in variables
/^r[0-9]+/ {
rev=$1
user=$3
date=$5
@trevershick
trevershick / diff_from_trunk
Last active August 29, 2015 14:27
Subversion - Lists out all files that have changes when compared to trunk
# Lists out all files that have changes when compared to trunk
# this assumes the name of the current directory
# is the name of the folder in ^/trunk/<<folder>>
BASE=$(pwd); BASE=$(basename $BASE); svn diff ^/trunk/$BASE . | grep Index | grep "\." | cut -d " " -f2 | xargs basename | sort | uniq
@trevershick
trevershick / mvncolor.sh
Last active September 17, 2015 13:24 — forked from katta/mvncolor.sh
Script to add colors to maven output
#!/usr/bin/env bash
# Formatting constants
export BOLD=`tput bold`
export UNDERLINE_ON=`tput smul`
export UNDERLINE_OFF=`tput rmul`
export TEXT_BLACK=`tput setaf 0`
export TEXT_RED=`tput setaf 1`
export TEXT_GREEN=`tput setaf 2`
export TEXT_YELLOW=`tput setaf 3`
var bucket = "a-bucket";
var filename = "logs/abc";
var event = {
"Records": [
{
"s3": {
"object": {