Skip to content

Instantly share code, notes, and snippets.

@nbogie
nbogie / rough-notation-devtools-oneliner.js
Last active May 29, 2020 09:53
An example one-liner to annotate all 'p' and 'a' tags in the current page. Paste it into the devtools. (if you trust the 'rough-notation' module)
(async () => {
const RoughNotation = await import('https://unpkg.com/rough-notation?module');
const pick = (arr) => arr[Math.floor(Math.random() * arr.length)];
const colorNames = "#66FF66 #FD5B78 #FF9966 #FFFF66 #50BFE6 #FF00CC".split(" ");
document.querySelectorAll('p').forEach(elem => {
RoughNotation.annotate(elem, { type: 'box', color: 'black', strokeWidth: pick([1, 2, 10]) }).show();
});
document.querySelectorAll('a').forEach(elem => {
@nbogie
nbogie / high-scores.js
Created May 20, 2020 16:32
data for high score table react quick exercise
let allCountryScores = [
{
name: "Ethiopia",
scores: [ {n: "Hanif", s: 999999999}, {n: "neill", s: 999999}, {n: "bob", s: "4134234"}, {n: "Hanif", s: "700"}]
},
{
name: "Scotland",
scores: [ {n: "lucy", s: 9999}, {n: "groundkeeper willie", s: 4000}, {n: "braveheart", s: 200}]
},
{

Getting create-react-app working on Ubuntu (19.04)

problems and solutions

Main success conditions to be met:

We will be done if...

  • npx create-react-app is runs and completes successfully
  • student can run the react app created by the above
@nbogie
nbogie / creative-coding-lunch.md
Last active August 20, 2020 20:10
creative coding lunch

1. make the tree structure shape

  • make single vertex

  • extrude it

2. skin it

  • add skin modifier

adjust thicknesses:

  • in edit mode
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nbogie
nbogie / gist:d8b4f207c4f30f2d622c33c1a58010b7
Last active October 23, 2019 13:50
pygamezero move actor in direction faced
import math
car = Actor("car_blue")
car.x = 200
car.y = 200
car.speed = 1
accel = 0.5
turning_speed = 1
def update():
# handle player inputs
@nbogie
nbogie / inverse_kinematics.py
Created October 18, 2019 17:04
inverse kinematics tentacles - bad bad python code
# Inverse Kinematics tenacles with python and pygamezero
# Roughly following Daniel Shiffman's algorithm:
# https://www.youtube.com/watch?v=xXjRlEr7AGk
# pygamezero docs:
# https://pygame-zero.readthedocs.io/en/stable/builtins.html
import math
import random
from pypercard import Inputs, CardApp, Card
import random
my_cards = [
Card(
"entrance",
text="You are in the top of a tall tower ,a locked door to the left and a window to the right",
buttons=[
{"label": "Try and pick the lock", "target": "locked door"},
{"label": "Go out of the window", "target": "falling"},