Skip to content

Instantly share code, notes, and snippets.

View jamesdavidson's full-sized avatar

James Davidson jamesdavidson

View GitHub Profile
@jamesdavidson
jamesdavidson / pom.xml
Created April 19, 2016 08:30
Removing extraneous artifacts from the Java SDK for AWS
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example.lambda</groupId>
<artifactId>jisho-b36491</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jisho-b36491</name>
<url>http://maven.apache.org</url>
<dependencies>
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 2 (connect to TX of other device)
* TX is digital pin 3 (connect to RX of other device)
@jamesdavidson
jamesdavidson / euclids.hs
Created April 18, 2015 06:34
Euclid's algorithm
-- Euclid's algorithm for calculating the greatest-common-divisor.
gcd :: Integer -> Integer -> Integer
gcd x y =
if r == 0 then y else (gcd y r)
where r = (mod x y)
@jamesdavidson
jamesdavidson / queue.c
Last active August 29, 2015 14:18
A queue of integer values, implemented as a linked-list.
// A queue of integer values, implemented as a linked-list.
// Careful, don't pop the queue if it's empty!
// Copyright (c) James Davidson 2015.
// Publicly released under the terms of the MIT License.
// For educational purposes only, obviously; no warranty implied.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
@jamesdavidson
jamesdavidson / async-factorial.js
Created April 7, 2015 04:27
Recursion is fun! Node javascript factorial, sync and async.
module.exports = function (n,cb) {
function helper (sum,i) {
if (i == 0) return cb(sum);
else process.nextTick( helper.bind(null,sum*i,i-1) );
};
return helper(1,n);
}
@jamesdavidson
jamesdavidson / fruit
Last active August 29, 2015 14:17
Recognising single spoken words using CMU Sphinx4.
APPLE AE P AH L
ORANGE AO R AH N JH
PEAR P EH R
MANDARIN M AE N D ER AH N
GRAPE G R EY P
BANANA B AH N AE N AH
@jamesdavidson
jamesdavidson / gist:65b16dc4c5f964cb3ead
Created March 25, 2015 04:56
Make a HTML list of names from S3 bucket meta-data.
; Retrieve a list of buckets.
; Retrieve the access-control-list.
; For each, print the owner's display-name.
(ns com.example
(:use amazonica.core
amazonica.aws.s3
clojure.pprint))
(defn retrieve-name [bucket]
@jamesdavidson
jamesdavidson / foo.clj
Created March 23, 2015 12:16
Get AWS resource data using Amazonica
; Use Amazonica from https://github.com/mcohen01/amazonica
(ns com.example
(:use amazonica.aws.ec2
amazonica.aws.s3
amazonica.aws.route53))
(describe-instances)
(list-buckets)
(map :name (list-buckets))
(list-hosted-zones)
@jamesdavidson
jamesdavidson / gist:c24b6e97f4f0cad593a2
Created February 26, 2015 00:41
FizzBuzz in Haskell
main = mapM_ putStrLn $ take 25 fizzbuzz
fizzbuzz = map (\(f,b) -> f ++ b) $ zip fizzes buzzes
fizzes = map (moddy "fizz" 3) [1..]
buzzes = map (moddy "buzz" 5) [1..]
moddy str b i = if i `mod` b == 0 then str else ""
{-# OPTIONS -Wall #-}
module Main where
import Control.Concurrent (threadDelay)
import System.Environment (getArgs)
import System.INotify
main :: IO ()
main = do