Skip to content

Instantly share code, notes, and snippets.

View damiensawyer's full-sized avatar

Damien Sawyer damiensawyer

  • Melbourne, Australia
View GitHub Profile
@damiensawyer
damiensawyer / rainbow.ts
Last active December 27, 2021 03:32
Micro:bit rotating rainbow
// Rotating Rainbow for GlowBit Rainbow and Micro:Bit (https://core-electronics.com.au/glowbit-rainbow.html)
// Can run with https://makecode.microbit.org
// Nb: You must import 'neopixel' extension into makecode before running
input.onButtonPressed(Button.A, function () {
maxb = maxb <= 0 ? 0 : Math.max(maxb - 10,0)
})
input.onButtonPressed(Button.B, function () {
maxb = maxb >= 255 ? 255 : Math.min(maxb + 10,255)
@damiensawyer
damiensawyer / microbit rainbow
Last active October 31, 2021 21:50
Neopixels moving between rainbow colours
input.onButtonPressed(Button.A, function () {
maxb = maxb <= 0 ? 0 : Math.max(maxb - 10,0)
})
input.onButtonPressed(Button.B, function () {
maxb = maxb >= 255 ? 255 : Math.min(maxb + 10,255)
})
input.onLogoEvent(TouchButtonEvent.Pressed, function() {
reverse = !reverse
@damiensawyer
damiensawyer / index.ts
Created September 30, 2021 04:14
MIcrobit Reaction Game With Sound
let initialMode = 0
let countdownMode = 100
let cheatedMode = 200
let playingMode = 300
let finishedMode = 400
let soundDuration = 300
let p1Wins = false
let randomTime = 0
let gameStartTime = 0
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#script
# https://en.wikipedia.org/wiki/YAML
# https://stackoverflow.com/questions/55657444/how-to-run-different-steps-in-a-yml-file-depending-on-the-branch-trigger
trigger:
batch: true
branches:
include:
- master
- develop
control.onEvent(EventBusSource.MICROBIT_ID_BUTTON_AB, EventBusValue.MICROBIT_BUTTON_EVT_CLICK, function () {
if (Button_B_state == 1) {
Button_B_state = 0
setNose()
} else {
Button_B_state = 1
setNose()
}
radio.sendValue("Lights", Button_B_state)
})
@damiensawyer
damiensawyer / reaction
Created December 7, 2019 02:52
Microbit Rection Game Code
let initialMode = 0
let countdownMode = 100
let cheatedMode = 200
let playingMode = 300
let finishedMode = 400
let p1Wins = false
let randomTime = 0
let gameStartTime = 0
let activeMode = initialMode
@damiensawyer
damiensawyer / test
Created January 21, 2016 04:04
Gist from LinqPad
Test file
@damiensawyer
damiensawyer / gist:3438e1cfa308464beabf
Last active March 8, 2017 18:11 — forked from Wysie/gist:7487571
route traffic from home network through VPN selectively.
#!/bin/sh
# Script to route traffic from home network through VPN selectively.
# Based off the discussion at http://www.smallnetbuilder.com/forums/showthread.php?t=9311
# The setup is a Roku box, a Home PC running Plex, and a Synology NAS with a torrent client running a web interface.
# The aim is to have all traffic from Roku go through the VPN, all traffic from the Home PC (and all other devices) bypassing the VPN,
# and the Synology NAS using the VPN. There are however some exceptions. Since Plex uses port 32400, Roku has to bypass the VPN when
# using that port. In addition, port 9091 has to bypass the VPN as well in order to access the Synology torrent client.
#
# Requirements: Asuswrt-Merlin with OpenVPN already set up