Skip to content

Instantly share code, notes, and snippets.

View nickcharlton's full-sized avatar

Nick Charlton nickcharlton

View GitHub Profile
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):
@nickcharlton
nickcharlton / date_accessor.rb
Created July 16, 2015 07:10
An example of creating a custom accessor type to parse inputs.
#!/usr/bin/ruby
require 'date'
class Resource
def initialize(hash = {})
hash.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
end
class << self
$ bundle exec bin/run
dyld: lazy symbol binding failed: Symbol not found: _rb_str_new_static
Referenced from: /Users/nickcharlton/.gem/ruby/2.2.2/gems/json-1.8.3/lib/json/ext/parser.bundle
Expected in: flat namespace
dyld: Symbol not found: _rb_str_new_static
Referenced from: /Users/nickcharlton/.gem/ruby/2.2.2/gems/json-1.8.3/lib/json/ext/parser.bundle
Expected in: flat namespace
[1] 72256 trace trap bundle exec bin/run
% vagrant provision
The following berks command failed to execute:
/Users/nickcharlton/.gem/ruby/2.2.2/bin/berks --version --format json
The stdout and stderr are shown below:
stdout:
stderr: /Users/nickcharlton/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'berkshelf' (>= 0) among 84 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/nickcharlton/.vagrant.d/gems:/opt/vagrant/bin/../embedded/gems', execute `gem env` for more information