Skip to content

Instantly share code, notes, and snippets.

View gjb2048's full-sized avatar
👨‍🚀
On a mission

Gareth J Barnard gjb2048

👨‍🚀
On a mission
View GitHub Profile
@gjb2048
gjb2048 / dr_route_selector.ino
Last active February 7, 2024 12:20
Dad Rail Route Selector test
int s1 = 2; //entry button 1
int s2 = 3; //entry button 2
int e1 = 4; //exit button 1
int e2 = 5; //exit button 2
int r1 = 6; //route set indicator 1
int r2 = 7; //route set indicator 2
int r3 = 8; //route set indicator 3
int r4 = 10; //route set indicator 4
int timeout = 11;//Route time out indicator light
@gjb2048
gjb2048 / PiInfo.java
Last active August 29, 2015 14:16
PiRMI Version two.
/*
* PiRMI.
* Copyright (C) 2015 Gareth J Barnard
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@gjb2048
gjb2048 / .bash_profile
Created February 19, 2015 17:30
Nibble Of A Byte
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-armhf/
export GRADLE_HOME=~/gradle-2.3
export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-armhf/bin:$GRADLE_HOME/bin
@gjb2048
gjb2048 / Squence.java
Created September 25, 2013 15:44
Sequence to calculate x = y * y - y
/*
* Sequence.
* © G J Barnard 2013 - Attribution-NonCommercial-ShareAlike 3.0 Unported - http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB.
*/
package sequence;
/**
* This class outputs a sequence where x = y * y - y.
*
* @author G J Barnard
@gjb2048
gjb2048 / PiInfo.java
Created August 20, 2013 17:43
RMI on the Raspberry Pi
/*
* Pi RMI.
* © G J Barnard 2013 - Attribution-NonCommercial-ShareAlike 3.0 Unported - http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB.
*/
package pirmi;
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
@gjb2048
gjb2048 / ThreadPool.java
Last active December 19, 2015 17:19
Program to demonstrate how threads can be employed to generate and consume data.
/*
* Thread Pool.
* © G J Barnard 2012
* License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0).
* See: http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
package threadpool;
import java.util.Date;
import java.util.LinkedList;
@gjb2048
gjb2048 / ExceptionTest.java
Created July 8, 2013 11:27
Custom exception example.
/*
* Custom exception example.
* © G J Barnard 2013 - Attribution-NonCommercial-ShareAlike 3.0 Unported - http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB.
*/
package myexception;
/**
* Demonstrate how custom exceptions can be defined and employed.
*/
public class ExceptionTest
@gjb2048
gjb2048 / FreeSpace.java
Created July 1, 2013 13:06
Java JNI with C on a Raspberry Pi
/*
* FreeSpace JNI class.
* © G J Barnard 2013 - Attribution-NonCommercial-ShareAlike 3.0 Unported - http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB.
*
* Defines the native functions to use and loads the resulting 'libfreespace.so' for Java to use at runtime.
*
* Start here.
* So with this file operating above the package folder:
* javac miniwebserver/FreeSpace.java to generate the .class file for FreeSpaceMiniWebServer.
* javah miniwebserver.FreeSpace to generate the miniwebserver_FreeSpace.h file with the function declarations to implement.
@gjb2048
gjb2048 / Union.c
Created May 19, 2013 12:09
For Using C Unions on a Raspberry Pi -> https://www.youtube.com/watch?v=Q-uwhWtfy2I
#include <stdio.h>
union
{
unsigned int i;
unsigned char c;
} aunion;
int main()
{
@gjb2048
gjb2048 / Recursion.c
Created May 19, 2013 12:07
For "The difference between loops and recursion in Java and C on a Raspberry Pi" -> https://www.youtube.com/watch?v=TU7P5mqbo5Q
/* Recursion vs loops example.
(c) G J Barnard May 2013
License:
http://creativecommons.org/licenses/by-nc-nd/3.0/
*/
#include <stdio.h>
#include <sys/time.h>
unsigned char aNumber = 42;