Skip to content

Instantly share code, notes, and snippets.

View prwhite's full-sized avatar

Payton White prwhite

View GitHub Profile
@prwhite
prwhite / gist:1250016
Created September 29, 2011 05:04
Complete Makefile targets in tcsh
# first grep finds lines with potential commands
# second grep throws away pure comment lines
# then sed throws away anything after initial target name (which should just be the : now)
# final uniq throws away dups
# could be more optimal :)
# could probably do something to generate completes from -f makefile name
alias makeCommands 'echo `egrep --only-matching "^.*?: " Makefile | egrep -v "^[[:space:]]*#" | sed "s/\(:.*\)//" | uniq`'
complete make 'n/*/`makeCommands`/'
@prwhite
prwhite / NSJSONSerialization+jsonXpath.m
Created January 20, 2013 09:55
For primitive xpath-like functionality built on Apple's NSJSONSerialization. Based on this: http://iphonedevsdk.com/forum/iphone-sdk-development/95463-query-value-from-json-with-a-xpath.html But, it adds the ability to find non-leaf nodes, and it tacks onto NSJSONSerialization as a category.
@implementation NSJSONSerialization (jsonXpath)
+ (NSObject *)objectForPath:(NSString *)jsonXPath container: (NSObject*) currentNode
{
if (currentNode == nil) {
return nil;
}
// we cannot go any further
if(![currentNode isKindOfClass:[NSDictionary class]] && ![currentNode isKindOfClass:[NSArray class]]) {
@prwhite
prwhite / gist:5846493
Created June 23, 2013 20:46
Q&D node.js script to pull out any Google Reader items tagged with a public label, e.g., "starred".
#!/usr/bin/env node --harmony
"use strict";
var req = require ( "request" );
var fs = require ( "fs" );
# replace these... could be command line args but that would have taken like 15 seconds more.
var userid = "06674516782868565233";
var label = "starred";
@prwhite
prwhite / copy-headers.sh
Last active December 31, 2015 11:59
Script for copying header files in an Xcode library/framework project while retaining their hierarchical structure. This requires creating a headers-bom file listing relative paths to the headers to be copied. Using rsync makes things relatively painless and potentially even more efficient than other methods.
#!/bin/sh
echo PWD = ${PWD}
echo SRCROOT = ${SRCROOT}
echo BUILT_PRODUCTS_DIR = ${BUILT_PRODUCTS_DIR}
# just to be sure
cd ${SRCROOT}
# using . as source below might not be what you want... feel free to change, etc.
@prwhite
prwhite / Makefile
Last active December 23, 2024 11:43
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
@prwhite
prwhite / gist:b95fe6154bd3d559eff2
Created March 25, 2015 19:04
Simple ObjC augmentation for NSLog to add file, line number and pretty function name. Compiles out in release (assuming DEBUG is not set in release)
#ifdef DEBUG
#define NSLogDebug(format, ...) \
NSLog(@"<%s:%d> %s, " format, \
strrchr("/" __FILE__, '/') + 1, __LINE__, __PRETTY_FUNCTION__, ## __VA_ARGS__)
#else
#define NSLogDebug(format, ...)
#endif
@prwhite
prwhite / feedly-tag-dropdown-shortcut.user.js
Last active December 28, 2017 08:45
Add keyboard shortcut ('t') to show the tag list dropdown for the active [floating] entry.
// ==UserScript==
// @name Feedly Open Tags Dropdown
// @namespace http://prw.prehiti.net/
// @version 0.9.14
// @description Show the Feedly tag entry dropdown with a keyboard shortcut. This functionality should be builtin!
// @author Payton R White
// @include http://feedly.com/*
// @include https://feedly.com/*
// @include http://*.feedly.com/*
// @include https://*.feedly.com/*
@prwhite
prwhite / feedly-colorful-list-view.user.js
Last active May 15, 2020 21:10 — forked from yamalight/README.md
Feedly Colorful Listview [more subtle colors]
// ==UserScript==
// @name Feedly Colorful Listview
// @namespace http://feedly.colorful.list.view
// @description Colorizes items headers based on their source
// @include http*://feedly.com/*
// @include http*://*.feedly.com/*
// @version 0.8.9
// @grant GM_addStyle
// ==/UserScript==
@prwhite
prwhite / syncout.hpp
Created March 4, 2022 17:26
Cheesy thread-synchronized std::cout output.
////////////////////////////////////////////////////////////////////////////////
// Class to substitute for cout to get synchronization of output.
// Usage: syncout << "foo " << 0xff << syncendl;
using namespace std;
class syncostringstream : public ostringstream {};
#define syncout syncostringstream()
ostream &syncendl(ostream &ostr)
{
if(auto *sostr = dynamic_cast< syncostringstream* >( &ostr ))
{