Skip to content

Instantly share code, notes, and snippets.

View nickcharlton's full-sized avatar
🐢
I'm swamped at the moment and will respond when I can!

Nick Charlton nickcharlton

🐢
I'm swamped at the moment and will respond when I can!
View GitHub Profile
@nickcharlton
nickcharlton / README.md
Last active December 21, 2015 14:28
A collection of archived VMs provisioned like the default Vagrantboxes – but newer.

So, I've been assembling a set of scripts to build Vagrant boxes. The intial idea was to build updated, reasonably well documented versions of the ones which already exist, from which I can then reuse to build more complex boxes.

Eventually, this will be a project called [boxes][]. But for now, here are some of the outputs from what I've been working on. I'm working on adding Debian (stable, unstable) and the current and LTS version of Ubuntu. It's just the current Ubuntu LTS right now.

The eventual idea is to have the box building scripts run through some sort of CI server so that it's automatically rebuilt and tested. I haven't got here yet, but that's why the boxes have no timestamps — the links should work forever.

@nickcharlton
nickcharlton / gist:6422871
Last active December 22, 2015 05:19
Simple (cached) RFC3339 Date Parser in Objective-C.
static NSDateFormatter *rfc3339Formatter = nil;
if (rfc3339Formatter == nil) {
rfc3339Formatter = [[NSDateFormatter alloc] init];
// set a static locale
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[rfc3339Formatter setLocale:enUSPOSIXLocale];
[rfc3339Formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZ"];
}
@nickcharlton
nickcharlton / README.md
Last active December 23, 2015 01:49
A simple shell script which generates docs for Cocoa projects using appledoc.

[Cocoadocs][] is turning into a great collection of documentation for projects which are also in [Cocoapods][]. They're automatically generated everytime a new pod version is created. Additionally, the new version of Xcode (5) has much better support for docs, and for the libraries I commonly use I want to be able to subscribe to an atom feed of documentation.

The problem with Cocoadocs was for me caused by [AFNetworking][]. I wanted docs, but version 2.0 breaks compatibility with previous iOS versions and Cocoadocs doesn't have atom feeds for more than the current release of a pod. This was a bit of a problem. (Also, I wanted to play around with Appledoc.)

So, I wrote this. It's based quite heavily on how Cocoadocs generates it's own documentation, but it's much simpler. It will generate a docset (including the HTML) in ./Docs/AFNetworking, assuming that ./AFNetworking contains the AFNetworking

Rural data
Rural average temperature 22.14314927
Latitude Longitude Temperature Delta temperature (temperature minus rural average temperature)
50.689423 -3.549081 20.83380248 -1.309346787
50.699427 -3.580324 21.22029034 -0.922858929
50.743985 -3.580324 24.68239512 2.539245853
50.752891 -3.515436 23.58182023 1.438670963
50.762665 -3.521272 21.01284363 -1.130305634
50.761796 -3.60264 20.35362728 -1.789521989
50.715299 -3.430635 21.96305372 -0.180095545
//To read from blue sky sensor
int blueSensorPin = A2;
int UnfilteredSensorPin = A0;
float ratio;
int UnfilteredSensorValue = 0;
int blueSensorValue = 0;
//Setup runs once to initialise.
@nickcharlton
nickcharlton / vimrc
Created April 22, 2014 11:20
Ubuntu (12.04) Global vimrc
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
@nickcharlton
nickcharlton / gist:7020be064021365464de
Created June 11, 2014 14:09
strptime_l vs. NSDateFormatter Benchmarks
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
static size_t const iterations = 10000;
uint64_t t_0 = dispatch_benchmark(iterations, ^{
@autoreleasepool {
NSString *dateStr = @"Sat Sep 15 05:52:10 +0000 2012";
@nickcharlton
nickcharlton / gist:6969eb8685b24c7580d2
Created September 11, 2014 11:36
ActiveSupport Pluralizes "cafe" as "caves".
[1] pry(main)> require 'active_support/inflector'
=> true
[2] pry(main)> "cafe".pluralize
=> "caves"
[3] pry(main)>
@nickcharlton
nickcharlton / readline.patch
Created September 15, 2014 19:27
Improved Ruby 2.0.* series patch which works without intervention with ruby-install.
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -19,6 +19,10 @@ def readline.have_func(func)
return super(func, headers)
end
+def readline.have_type(type)
+ return super(type, headers)
+end
+
@nickcharlton
nickcharlton / forecast.py
Created April 27, 2015 12:09
Cached 7-day Hourly Forecast
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from datetime import datetime, timedelta
import requests
class ForecastException(Exception):