Skip to content

Instantly share code, notes, and snippets.

View nielsdoorn's full-sized avatar
🏗️
Building better software testing education

Niels Doorn nielsdoorn

🏗️
Building better software testing education
View GitHub Profile
@nielsdoorn
nielsdoorn / madlib.py
Created May 11, 2022 08:04
An example of a MadLib Python exercise
v = input("Insert a verb:")
pn = input("Insert a plural noum:")
n = input("Insert a noun:")
a = input("Insert an adjective:")
print("\nWhether you "+ v+ "\n"
"computer programs to\n"
"solve "+pn+" or just\n"
"for "+ n+ ", it is very\n"
"important that you\n"
@nielsdoorn
nielsdoorn / animationPolyfill.js
Last active December 28, 2020 01:06
Eyes that follow your mouse cursor. Using HTML5 canvas.
// Paul Irish animation loop polyfill
// https://gist.github.com/paulirish/1579671
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|| window[vendors[x]+'CancelRequestAnimationFrame'];
@nielsdoorn
nielsdoorn / fade.js
Last active January 4, 2016 13:59
Espruino fade in and out script with light string (individual addressable lights)
// change this if you use another port or if your lights work with 32 instead of 64 baud
SPI1.setup({baud:6400000, mosi:A7});
var rgb = new Uint8Array(25*3); // 25 x RGB lights
// turn off board leds
digitalWrite(LED1,0);
digitalWrite(LED2,0);
digitalWrite(LED3,0);
@nielsdoorn
nielsdoorn / OOPJavaScript.js
Created December 31, 2013 13:24
OOP in JavaScript
// constructor
function Person(name) {
// public member, accesible from inside and outside
this.name = name;
// private member, not accesible from outside and public functions
var secret = 3;
// By convention, we make a private that variable.
// This is used to make the object available to the private methods.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Canvas animatie</title>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas id="animatie" width="640" height="480"></canvas>
syntax on
set tabstop=2 " The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set shiftwidth=2 " Indents will have a width of 4
set softtabstop=2 " Sets the number of columns for a TAB
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Canvas animatie</title>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas id="animatie" width="640" height="480"></canvas>
@nielsdoorn
nielsdoorn / gist:7702288
Created November 29, 2013 06:37
Request animation frame JavaScript code
window.onload = init;
// variabelen
var canvas;
var x = 10;
var y = 10;
// init wordt eenmalig uitgevoerd om alles op te bouwen
function init() {
@nielsdoorn
nielsdoorn / dabblet.css
Created June 14, 2013 11:50
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
@import url(http://fonts.googleapis.com/css?family=Nothing+You+Could+Do);
div {
background-color: black;
padding: 5px;
}
#blokje {
width: 300px;
height: 600px;
border: 1px solid black;
background-color: #353;
transition: 1s;
}