Skip to content

Instantly share code, notes, and snippets.

@wearhere
wearhere / keep_current_file_open.sh
Created February 9, 2012 09:34
Keep your current source file open in Xcode after a run completes (a.k.a don't die in main.m)
#! /bin/sh
# On alternate invocations, this script
# saves the path of the source file currently open in Xcode
# and restores the file at that path in Xcode.
#
# By setting Xcode (in Behaviors) to run this script when "Run Starts"
# and when "Run Completes", you can prevent it from switching to main.m
# when a run finishes.
# See http://stackoverflow.com/questions/7682277/xcode-4-2-jumps-to-main-m-every-time-after-stopping-simulator
@wearhere
wearhere / toggle_uiautomation_views.scpt
Created February 10, 2012 10:52
Toggle Between Script and Editor Log Views in UIAutomation Instrument
(*
Running this script will cause Instruments to become active
and switch from the Script view (where you edit your UIAutomation script)
to the Editor Log view (where you see the logs of executing those scripts)
or vice versa.
*)
-- JW: This block only needs to be executed once, and can then be removed.
-- I don't know if leaving it in might cause a performance hit;
@wearhere
wearhere / clear_xcode_console.scpt
Created February 20, 2012 04:16
Clear Xcode Console from the Simulator
# Clears Xcode's console,
# then switches back to the iOS Simulator.
activate application "Xcode"
tell application "System Events"
tell process "Xcode"
click menu item "Clear Console" of menu 1 of menu item "Debug" of menu 1 of menu bar item "Product" of menu bar 1
end tell
end tell
activate application "iPhone Simulator"
@stephenmcd
stephenmcd / requirements_report.py
Created June 18, 2012 00:45
Build a report of Python requirements for multiple repositories.
#!/usr/bin/env python
"""
Given the current directory contains multiple repositories, each with a
requirements/project.txt file, build a report of all requirements.
"""
import os
reqs = {}
@pcote
pcote / hn_screen_scraper.py
Created June 28, 2012 19:52
Screen scraper that Pulls URLs and Titles from the Front Page of Hacker News
# hn_screen_scraper.py
# A screen scraper for the front page of hacker news done out of a fit of boredom.
from urllib import request
import re
# read in the data and split it into a raw list of entries
url_path = "http://news.ycombinator.com"
sock = request.urlopen(url_path)
raw_data = str(sock.read())
data_set = re.split("arrow\.gif", raw_data)
@rcaldwel
rcaldwel / gist:3213143
Created July 31, 2012 02:59
bash: unix: applescript: set a bash var to the output of a scpt
the_app=$(
osascript 2>/dev/null <<EOF
tell application "System Events"
name of first item of (every process whose frontmost is true)
end tell
EOF
@demogar
demogar / template-functions.php
Created July 31, 2012 03:41
Adding support for title, id, class to icl_link_to_element
<?php
// Add this to template-functions.php
// Disclaimer: I based icl_get_anchor_attributes on the _stringify_attributes function on CodeIgniter framework. I made my own function, but I believe this function is just better (and proved to work fine)
function icl_get_anchor_attributes($attributes) {
if (is_object($attributes) && count($attributes) > 0) {
$attributes = (array) $attributes;
}
if (is_array($attributes)) {
@testingbot
testingbot / python_parallel_webdriver.py
Created August 3, 2012 16:36
python parallel webdriver testing on testingbot
from threading import Thread
from selenium import webdriver
import time
API_KEY = "key"
API_SECRET = "secret"
def get_browser(caps):
return webdriver.Remote(
desired_capabilities=caps,
#!/usr/bin/env python
import datetime
import feedparser
import json
import os
from urlparse import urlparse
def readConfigFile():
"""Read the config file ~/.youtube-rss and return a dictionary"""
@DHuckaby
DHuckaby / NonsenseGenerator.java
Created October 30, 2012 13:26
This generator can construct headlines and news articles by randomly composing sentences.
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software