Skip to content

Instantly share code, notes, and snippets.

@tamc
tamc / reset-media-on-simulators.rb
Created April 16, 2019 13:10
Script to set the photos and videos in the gallery to be the same in all iOS simulators
#!/usr/bin/env ruby
require 'json'
require 'optparse'
$shutDownSimulators = false
$bootSimulators = false
$leaveExisting = false
$alterDates = true
@tamc
tamc / # ffmpeg - 2017-05-04_14-29-48.txt
Created May 4, 2017 13:41
ffmpeg on macOS 10.12.4 - Homebrew build logs
Homebrew build logs for ffmpeg on macOS 10.12.4
Build date: 2017-05-04 14:29:48
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiMulti.h>
// This code
// 1. Connects to a WiFi network
// 2. Loops:
// a. Makes an http request to a URL
// b. Parses the response, expecting an integer between 0 and 1000
// c. Outputs that on PIN D0 as a voltage between 0 and 3.6V
@tamc
tamc / cloudwatch-lambda.js
Created September 22, 2016 13:51
AWS Lambda Method to return CloudWatch metrics as JSON
'use strict';
var AWS = require('aws-sdk');
var cloudwatch = new AWS.CloudWatch({apiVersion: '2010-08-01'});
function getMetric(metricName, callBack) {
var now = new Date();
var anHourAgo = new Date()
anHourAgo.setHours(now.getHours()-1);
var params = {
@tamc
tamc / primary_energy.js
Created December 12, 2014 18:13
Example of how to scale 2050 energy chart automatically
window.twentyfifty.views.primary_energy_chart = function() {
// This is the maximum value of the energy charts
max_value = 4000; // CHANGED
// This is called before the view is first selected
// and produces the three empty charts
this.setup = function() {
$('.primary_energy_notes').show();
@tamc
tamc / README.md
Last active August 29, 2015 14:04
A Cates plot in d3

A Cates plot in d3

A Cates plot in d3, styled after that of David Spiegelhalter.

Licence

The MIT License (MIT)

© 2014 Tom Counsell

@tamc
tamc / macro.bas
Last active August 29, 2015 14:01
A macro to list all cells in a workbook that contain external references
Sub ShowAllLinksInfo() 'requires a worksheet to be added to the 'workbook and named LinksList
Dim aLinks As Variant
Dim i As Integer
Dim anyWS As Worksheet
Dim anyCell As Range
Dim reportWS As Worksheet
Dim nextReportRow As Long
Set reportWS = ThisWorkbook.Worksheets("LinksList")
reportWS.Cells.Clear
# Setup
require 'active_record'
require 'paperclip'
require 'sqlite3'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:')
class AddTables < ActiveRecord::Migration
@tamc
tamc / CodeThatDoesNotWork.html
Created September 15, 2011 08:59
D3.js nested data
<!DOCTYPE html>
<html>
<header>
<script src="http://mbostock.github.com/d3/d3.js" type="text/javascript" ></script>
</header>
<body>
<script type='text/javascript'>
function draw(data) {
var lists = d3.select("body").selectAll("ul")
@tamc
tamc / snippet.txt
Created August 10, 2010 20:24
use erb to create metapost files
require 'erb'
metapost_command = 'mpost'
puts "Loading template '#{ARGV[0]}'"
template = IO.readlines(ARGV[0]).join
support_library = File.basename(ARGV[0],'.*')
support_module = support_library.split(/[^a-zA-Z0-9]/).map { |w| w.capitalize }.join
metapost_name = ARGV[1] || (File.basename(ARGV[0],'.*') + '.mp')