Skip to content

Instantly share code, notes, and snippets.

View jamesnesfield's full-sized avatar

James Nesfield jamesnesfield

View GitHub Profile
@jamesnesfield
jamesnesfield / replace recursive
Created July 18, 2013 11:48
a multi-file hierarchical "find and replace" that plays nice with spaces in names.
#!/bin/bash
startdirectory="/Users/jamesnesfield/Desktop/replaceTest/"
searchterm="foo"
replaceterm="bar"
i=0
IFS=$'\n';
for file in $( grep -l -R $searchterm $startdirectory)
do
@jamesnesfield
jamesnesfield / phaseballs.css
Last active January 4, 2016 05:39
phaseballs
body {
margin: 0;
padding: 0;
background: #191f27;
}
.container {
width: 200px;
height: 100px;
padding-top: 100px;
@jamesnesfield
jamesnesfield / annotateEdinburgh.html
Created January 23, 2014 16:56
annotateEdinburgh
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<body>
<div id='map'></div>
@jamesnesfield
jamesnesfield / github_ribbon
Created January 24, 2014 12:36
github ribbon
<a href="https://github.com/jamesnesfield/lineofsite"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub"></a>
@jamesnesfield
jamesnesfield / googlemapstyle.json
Created January 24, 2014 17:44
google map style
Map data ©2014 Google
Terms of Use
Visual refresh
Report a map error
//http://stackoverflow.com/questions/15757872/manually-color-fading-from-one-uicolor-to-another
- (UIColor *)colorFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor amount:(float)amount // 0 < amount < 1
{
float dec = amount;
CGFloat fRed, fBlue, fGreen, fAlpha;
CGFloat tRed, tBlue, tGreen, tAlpha;
CGFloat red, green, blue, alpha;
if(CGColorGetNumberOfComponents(fromColor.CGColor) == 2) {
[fromColor getWhite:&fRed alpha:&fAlpha];
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
#define IS_OS_5_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0)
#define IS_OS_6_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
#define IS_OS_7_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
@jamesnesfield
jamesnesfield / singleton macro
Created February 7, 2014 14:39
singleton macro iOS
//from Urban Airship iOS SDK "1.1.2"
#define SINGLETON_INTERFACE(CLASSNAME) \
+ (CLASSNAME*)shared; \
#define SINGLETON_IMPLEMENTATION(CLASSNAME) \
\
static CLASSNAME* g_shared##CLASSNAME = nil; \
\
@jamesnesfield
jamesnesfield / DebugLog
Created February 10, 2014 12:52
iOS debug-only logging
/* place in pch
from http://stackoverflow.com/questions/9621143/debuglog-format-string-is-not-a-string-literal
*/
#ifdef DEBUG
#define DebugLog(s, ...) NSLog(s, ##__VA_ARGS__)
#else
#define DebugLog(s, ...)
@jamesnesfield
jamesnesfield / git submodules
Created March 2, 2014 12:30
clone and init all submodules.
git submodule update --init --recursive