Skip to content

Instantly share code, notes, and snippets.

💭
🚀 Building Focus, RemoteHabits and something new

Brad Jasper bradjasper

💭
🚀 Building Focus, RemoteHabits and something new
Block or report user

Report or block bradjasper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View itunesicon.rb
#!/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:
View 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
View remove_focus.sh
#!/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 Jan 9, 2015
Small BASH script to check if Focus is currently activated
View is_focus_active
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 Feb 1, 2015
Copy & restore Focus preferences
View gist:212337463f826660fec2
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 Oct 30, 2009
Dead simple event tracking with celery and git
View demo.py
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()})
View gist:302283
@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")
View mixpanel.py
# 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.
View mixpanel.py
# 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
View 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"
}
You can’t perform that action at this time.