Skip to content

Instantly share code, notes, and snippets.

View dwaard's full-sized avatar

Daan de Waard dwaard

  • HZ University of Applied Sciences
  • Middelburg, Netherlands
View GitHub Profile
@dwaard
dwaard / object-array-demo.ts
Last active June 2, 2017 08:41
Voorbeeld over het werken met een verzameling objecten in Typescript
class Student
{
readonly studentnummer : number;
readonly volledigenaam : string;
constructor(nummer : number, naam : string)
{
this.studentnummer = nummer;
this.volledigenaam = naam;
}
@dwaard
dwaard / template.blade.php
Created February 5, 2018 09:46
Template for a page in Laravel with AdminLTE plugin from JeroenNoten
@extends('adminlte::page')
@section('title', '[Title as shown in browser tab]')
@section('content_header')
<h1>Title as shown on top of page</h1>
@stop
@push('js')
{{-- place your javascripts here --}}
// include the library code:
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
lcd.print("program me daddy");
lcd.setCursor(0,1);
@dwaard
dwaard / rps.php
Created May 27, 2019 07:12
Simple Rock-Paper-Scissors game in PHP
<?php
//Now, let's play
$returnText = 'You have not played yet. Select your weapon and hit the Play button';
if (userHasValidSelection()) {
$userChoice = $_GET['userSelect'];
//Let the computer make a choice
$computerChoice = letComputerChoose();
//Now, let's play, and return the result text!
$returnText = "The server chose $computerChoice. ";
$result = compare($userChoice, $computerChoice);
@dwaard
dwaard / Vector.ts
Last active November 19, 2021 14:18
Typescript class that represents a 2D Vector
/**
* This class represents a mathematical (Euclidian) Vector mainly used in
* physics and engineering to represent directed quantities. Basically it's
* responsible for holding a x- and y-coordinate, length and angle. It can also
* perform basic vector operations like adding, subtracting and scaling.
*
* The state of a vector object is immutable. This means that it is by design
* not allowed to change the internal state of the vector. The different
* computation methods that perform different computations like adding,
* subtracting, scaling and mirroring all return a new Vector object or just a
@dwaard
dwaard / product_vision_board.md
Last active May 4, 2023 21:36
Example of a Product Vision Board in markdown

The Product Vision Board

👀 VISION To give music lovers better access to more artists
<?php
namespace App\Console\Commands;
use App\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class CreateAdminCommand extends Command
{
@dwaard
dwaard / StrongPassword.php
Created June 18, 2020 07:52
A strong password custom validation rule, based on Matt Kingshotts article: https://itnext.io/laravel-validation-rule-passwords-70364ae0f349
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class StrongPassword implements Rule
{
/**
* Create a new rule instance.
@dwaard
dwaard / KeyListener.ts
Last active November 18, 2021 15:23
Example implementation of a class that listens to KeyboardEvents and holds the state of the keyboard.
/**
* This class handles the keyboard events. It knows the last known state of its
* keys
*
* Some parts of this class are pretty complex, but the class itself is fairly
* easy to use. You just instantiate one object in your game and us the method
* `isKeyDown()` to check if a specific key is currently pressed down by the
* user.
*
* NOTE: It is known that the MouseEvent.keyCode property is deprecated, which
@dwaard
dwaard / GameLoop.ts
Created November 9, 2020 14:26
Example of an implementation of a Game Loop design pattern with "play catch up".
/**
* This class implements a game loop using the "Play catch up" method. It will
* update the game using a fixed time step because that makes everything simpler
* and more stable for physics and AI. But it will allow flexibility in when we
* render in order to free up some processor time.
*
* It goes like this: A certain amount of real time has elapsed since the last
* turn of the game loop. This is how much game time we need to simulate for the
* game’s “now” to catch up with the player’s. We do that using a series of
* fixed time steps.