Skip to content

Instantly share code, notes, and snippets.

View cameronhunter's full-sized avatar

Cameron Hunter cameronhunter

View GitHub Profile
@cameronhunter
cameronhunter / semver.sh
Last active April 9, 2022 04:12
Parse a semver string in bash using a regular expression
#!/usr/bin/env bash
##
# Get the major/minor/patch semver from a string.
#
# Author: Cameron Hunter <hello@cameronhunter.co.uk>
# License: MIT 2022
#
# Examples:
# semver v14.22.1 major → 14

Keybase proof

I hereby claim:

  • I am cameronhunter on github.
  • I am cameronhunter (https://keybase.io/cameronhunter) on keybase.
  • I have a public key ASA3DI6aob5qHrmI2Zhe3-leKg8teAhnP4cFdtwJP9vsRwo

To claim this, I am signing this object:

@cameronhunter
cameronhunter / responsive-abbreviations.html
Created October 2, 2012 12:31
Responsive abbreviations in HTML using CSS
<!doctype html>
<html>
<head>
<title>Responsive Abbreviations</title>
<style type="text/css">
/* Show "U.K." */
abbr {cursor:default; border:none;}
/* Show "United Kingdom" */
@media (min-width: 481px) {
{
"v": 2,
"parserID": "babylon7",
"toolID": "babelv7",
"settings": {
"babylon7": null
},
"versions": {
"babylon7": "7.0.0",
"babelv7": "7.0.0"
@cameronhunter
cameronhunter / keybase.md
Created November 19, 2016 22:04
keybase.md

Keybase proof

I hereby claim:

  • I am cameronhunter on github.
  • I am cameronhunter (https://keybase.io/cameronhunter) on keybase.
  • I have a public key whose fingerprint is 96DA 316E C416 C535 0DBA 285A B518 7FF2 2BD2 4938

To claim this, I am signing this object:

@cameronhunter
cameronhunter / Data Binding Thoughts
Created July 31, 2013 18:33
Some research and thoughts around data-binding for flight.
## Definition ##
"Data binding is general technique that binds two data/information sources together and maintains synchronization of data." – http://en.wikipedia.org/wiki/Data_binding
UI data binding binds UI elements to an application domain model. Most frameworks employ the Observer pattern as the underlying binding mechanism. To work efficiently, UI data binding has to address input validation and data type mapping.
A bound control is a widget whose value is tied to a field in a recordset (i.e., a column in a row of a table). Changes made to data within the control are automatically saved to the database when the control's exit event triggers.
## Execution ##
From http://www.lucaongaro.eu/blog/2012/12/02/easy-two-way-data-binding-in-javascript/
@cameronhunter
cameronhunter / options-or-overloads.scala
Created April 19, 2013 18:44
Option doesn't solve everything. Sometimes overloaded functions provide a less confusing API.
/* Function using Option */
object Hello {
def to(name: Option[String] = None) =
"Hello " + (name getOrElse "world")
}
println(Hello.to(null)) // Causes NullPointerException
@cameronhunter
cameronhunter / holyrood9a.tsv
Created October 25, 2012 17:05
Holyrood 9a Order
archie Guacamole Burger Piri piri
stevenm Spiced Lamb Burger Plain
smithali Texas BBQ Burger Piri piri
caluml Guacamole Burger Plain
andthomp Pioneer Burger Plain
drewb Cheese Burger Plain
dominics Chilli Burger Piri piri
ajbailey Shroom Italienne Plain
gthubron Cheese and Bacon Burger Piri piri
andmell Pioneer Burger Piri piri
@cameronhunter
cameronhunter / gist:3343413
Created August 13, 2012 19:17
Responsive design incantation
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
@cameronhunter
cameronhunter / gist:978987
Created May 18, 2011 16:50
I've always liked Ruby's "rescue" keyword. I've implemented something similar in Javascript.
rescue = do(console) ->
(expression, fallback) ->
try expression?() || expression
catch e
console?.warn?( 'Rescued from', e, '. Using fallback value', fallback )
return fallback