Skip to content

Instantly share code, notes, and snippets.

View bradjasper's full-sized avatar
💭
🚀 Building Focus, RemoteHabits and something new

Brad Jasper bradjasper

💭
🚀 Building Focus, RemoteHabits and something new
View GitHub Profile
#!/usr/bin/ruby
# encoding: utf-8
#
# Grab iTunes Icon - Brett Terpstra 2014 <http://brettterpstra.com>
#
# Retrieve an iOS app icon at the highest available resolution
# All arguments are combined to create an iTunes search
# The icon for the first result, if found, is written to a filename based on search terms
#
# example:
@bradjasper
bradjasper / LICENSE
Last active August 29, 2015 14:07 — forked from jamztang/LICENSE
Copyright (c) 2013 Jamz Tang <jamz@jamztang.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@bradjasper
bradjasper / remove_focus.sh
Last active August 29, 2015 14:09
Remove Focus
#!/bin/bash
ACTIVE_NETWORK=$(echo "open|||get Setup:/Network/Service/$(echo "open|||get State:/Network/Global/IPv4|||d.show" | tr '|||' '\n' | scutil | grep "PrimaryService" | awk '{print $3}') |||d.show" | tr '|||' '\n' | scutil | grep "UserDefinedName" | awk -F': ' '{print $2}')
echo "Active network is '$ACTIVE_NETWORK'"
echo "Turning off active network PAC"
sudo networksetup -setautoproxystate "$ACTIVE_NETWORK" off
echo "Removing NSUserDefaults"
@bradjasper
bradjasper / is_focus_active
Created January 9, 2015 19:18
Small BASH script to check if Focus is currently activated
ACTIVE_NETWORK=$(echo "open|||get Setup:/Network/Service/$(echo "open|||get State:/Network/Global/IPv4|||d.show" | tr '|||' '\n' | scutil | grep "PrimaryService" | awk '{print $3}') |||d.show" | tr '|||' '\n' | scutil | grep "UserDefinedName" | awk -F': ' '{print $2}')
FOCUS_BLACKHOLE_PID=$(ps aux | grep FocusBlackholeProxy | grep -v grep | awk '{print $2}')
PROXY_URL_OUTPUT=$(networksetup -getautoproxyurl "$ACTIVE_NETWORK")
if [[ $PROXY_URL_OUTPUT == *"focus"* ]]
then
echo "Focus is active!"
else
echo "Focus is not active"
@bradjasper
bradjasper / gist:212337463f826660fec2
Created February 1, 2015 21:46
Copy & restore Focus preferences
Here's how to copy & restore Focus preferences
1) (On old computer) Copy preferences file to desktop. This BradJasper.Focus.plist file saves all of your settings. You can back this up in Dropbox if you want.
cp ~/Library/Preferences/BradJasper.Focus.plist ~/Desktop/
2) (On new computer) Kill focus & preferences monitor
killall Focus; killall cfprefsd;
@bradjasper
bradjasper / demo.py
Created October 30, 2009 20:06
Dead simple event tracking with celery and git
from mixpanel.tasks import TrackEvent
# Inside a view
def my_view(request):
TrackEvent.delay("search_view", {
"ip": request.META['REMOTE_ADDR'],
"distinct_id": session_id,
"time": time.time()})
@import blueprint/reset.sass
@import partials/base.sass
@import blueprint
@import blueprint/modules/scaffolding.sass
@import compass/utilities.sass
+blueprint-typography("body.bp")
+blueprint-scaffolding("body.bp")
# This isn't perfect for high traffic sites, if you need something more production ready
# please tell us or stay tuned as we will open it up shortly.
import subprocess
import base64
import simplejson
def track(event, properties=None):
"""
A simple function for asynchronously logging to the mixpanel.com API.
# Example of adapting Mixpanel task to work with Celery
import base64
import simplejson
import urllib2
def track(event, properties=None):
"""
A simple function for asynchronously logging to the mixpanel.com API.
@param event: The overall event/category you would like to log this data under
@bradjasper
bradjasper / show
Created April 20, 2011 18:38 — forked from tekacs/show
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".tekacs.com"
REMOTE="$2$DOMAIN"
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost"
}