Skip to content

Instantly share code, notes, and snippets.

@nbogie
nbogie / zipHaloShakeToSpin.ts
Created January 22, 2019 01:29
simple microbit zip halo / neopixel program to spin a light around when the device is shaken
let factor2 = 0
let strip: neopixel.Strip = null
let maxNeighbourBrightness = 0
let pxPos = 0
let maxBrightness = 0
let factor = 0
let fPos = 0
let braking = 0
let accel = 0
let speed = 0
@nbogie
nbogie / draw-random-points-exercise.js
Created January 19, 2019 02:40
experimental exercise for cyf to read and tweak a p5.js sketch by filtering an array of points to only keep those near to (or far from) the centre of the screen.
//Change the value of var pointsToDraw only (near line 60)
//Ignore these functions until draw()
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
//call draw only once - don't animate
noLoop();
}
// This set of exercises is based on the game "Scrabble"
//
// In the game, words are arranged from tiles.
// Each word is scored by summing the points for each of its letters.
// Different letters have different points.
// Example: The word 'happy' would score 10 points because:
// h = 3, a = 1, p = 2, p = 2, y = 2
//
// You will be provided with a function, scoreLetter(letter), which tells you the score of ONE letter.
// You will have to use the function to find the score for some words.
@nbogie
nbogie / custom.ts
Created January 15, 2019 13:48
simplest failing case for wc leung's compilation issue: array of big numbers. This doesn't compile when added as a custom block in makecode (if you try to have your code call the provided custom block).
//% color="#1E66A6"
//% block="Prop. Font"
//% icon="\uf031"
namespace proportionalFont {
const fontData = [
1, 185, 24603, 92102485, 19655237, 216566685, 170063685, 25,
4466, 3722, 85189717, 34858021, 6274, 34636837, 129, 25795,
119155, 7954, 186771, 87435, 2353764, 79291, 79219, 32011,
87379, 120211, 81, 6786, 145310757, 86592085, 34687629, 21771,
// Copyright 2018 Leung Wing-chung. All rights reserved.
// Use of this source code is governed by a MIT License, that can
// be found in the LICENSE file.
//% color="#1E66A6"
//% block="Prop. Font"
//% icon="\uf031"
namespace proportionalFont {
// The font data from ASCII codes 32 to 126. Index padded by 32.
// Format (bit 0 = lowest bit):
@nbogie
nbogie / sayHelloFull.js
Created December 16, 2018 04:51
An example broken js, needing reduced.
function sayHiInEnglish(){
console.log("Hello!");
}
function sayHiInSpanish(){
console.log("Hola
}
function sayHiInPortuguese(){
console.log("Oi");
@nbogie
nbogie / exampleCommandLineLog.txt
Created December 16, 2018 01:29
An example command-line log of a problematic Git session.
Last login: Thu Dec 13 17:05:20 on ttys000
AlicePC:~ alice$
AlicePC:~ alice$ cd ~/Documents
AlicePC:Documents alice$ pwd
/Users/alice/Documents
AlicePC:Documents alice$ git add Egusi_recipe.txt
fatal: not a git repository (or any of the parent directories): .git
AlicePC:Documents alice$ git clone https://github.com/CodeYourFuture/cookbook
fatal: destination path 'cookbook' already exists and is not an empty directory.
AlicePC:Documents alice$ cd cookbook/recipes
@nbogie
nbogie / sayHello.js
Created December 16, 2018 00:36
An example broken javascript program
function sayHiInSpanish(){
console.log("Hola
}
sayHiInSpanish();
@nbogie
nbogie / custom-background-tasks.ts
Last active December 3, 2018 17:11
example of custom makecode blocks scheduling ongoing background work. NOT best practice.
/**
* Use this file to define custom functions and blocks.
* Read more at https://makecode.microbit.org/blocks/custom
*/
/**
* Custom blocks
*/
//% weight=100 color=#0fbc11 icon=""