Skip to content

Instantly share code, notes, and snippets.

Avatar

Brendan Berg brendanberg

View GitHub Profile
@brentsimmons
brentsimmons / gist:5810992
Last active May 31, 2020
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
View gist:5810992
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
@malarkey
malarkey / Contract Killer 3.md
Last active Sep 23, 2020
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

View gist:3693480
public final static RuntimeException= new RuntimeException("┻━┻");
public void ノಠ益ಠノ彡(RuntimeException t) { throw t; }
public void ノಠ益ಠノ彡(Throwable t) { throw new RuntimeException(t); }
public int hashCode() {
ノಠ益ಠノ彡(ᚇ);
return 0;
}
View gist:3299167
javascript:(function(){ var body=document.getElementsByTagName("body")[0];var mckayla="http://f.cl.ly/items/1A1w013w0Q3p380a2N3x/mckayla.png";var mckaylaDiv=document.createElement("img");mckaylaDiv.src=mckayla;mckaylaDiv.style.position="absolute";mckaylaDiv.style.width="300px";mckaylaDiv.style.right=0;mckaylaDiv.style.bottom=0;body.appendChild(mckaylaDiv) })();
@unclebob
unclebob / apology.
Created Apr 27, 2012
Apology to Women Programmers.
View apology.
Today I gave a keynote at ACCU in Oxford. In the midst of it I made two (count them) two statements that I should have known better than to make. I was describing the late '70s, and the way we felt about the C language at the time. My slide said something like: "C was for real men." Emily Bache, whom I know and hold in high regard, spoke up and said "What about women?". And I said something like: "We didn't allow women in those days." It was a dumb crack, and should either not have been said, or should have been followed up with a statement to the effect that that was wrong headed.
The second mistake I made was while describing Cobol. I mentioned Adm. Grace Hopper. I said something like "May she rest in peace." I don't know that any of the words were actually demeaning, but the tone was not as respectful as it should have been to an Admiral in the United State Navy, and one who was so instrumental in our industry; despite what I feel about Cobol.
I am a 59 year old programmer who was brought up
@gordonbrander
gordonbrander / construct.js
Created Mar 5, 2012
construct -- an alternate way to invoke constructor functions
View construct.js
// Bind another function as the `this` context for `construct` to create
// a method that will construct the given function and return the object
// directly, enabling immediate chaining.
//
// A bound version of `construct` can be thought of as a Functor, converting data in (the function)
// to a new kind of data out (the constructed object).
//
// Before:
//
// var f = new F();
@brendanberg
brendanberg / lisp.coffee
Created Aug 24, 2011
Lisp list functions in CoffeeScript
View lisp.coffee
cons = (h, t) -> (m) -> m(h, t)
car = (x) -> x((h, t) -> h)
cdr = (x) -> if x then x((h, t) -> t) else null
map = (ls, f) ->
cons (f car ls), if cdr ls then map cdr(ls), f else null
foldl = (ls, f, n) ->
f (car ls), if cdr ls then foldl (cdr ls), f, n else n
@fbuchinger
fbuchinger / gist:674212
Created Nov 12, 2010
OxJs - jQuery for your Bytes
View gist:674212

OxJs - jQuery for your Bytes

OxJs (speak: HexaJs) is a utility library for javascript, that facilitates parsing and creation of binary data in Javascript. While this sounds weird in the first moment, there are a few areas where OxJs can come in handy:

  • If you need to transfer huge amounts of numercial data via AJAX, binary encoding can be much more space-efficient than transfering it in JSON. The number 41239 for example needs 5 Bytes in JSON, but only 2 Bytes in binary encoding (unsigned short). A more practical example is the The Google Maps Polyline Utility, which saves over 80% of the json payload by binary encoding. However, de- and encoding binary information can be a quite tricky and this is were OxJs helps.

  • For client-side file parsing: Recent enhancements in Javascript allow us byte access for to-be-uploaded files. This can be used to perform enhanced sanity che

You can’t perform that action at this time.