TDD-focused mini tutorial for an imaginary, minimal feature described below.
Goals: Deeply think about features, expectations and limitations. Write code last.
Based on the '5 Step Method' described on CodeUtopia.
| // Get random of 3 elements | |
| this.spriteVariant = parseInt((Math.random() * 100) % 3); | |
| // On every reached interval (ms), do sth. | |
| // - e.g. increase difficulty in a game | |
| this.time++; | |
| this.interval = 1000; | |
| const difference = (this.time % this.interval) ? 0 : 1; | |
| // Fade away effect over total time (max. to zero). |
| import useFetch from 'useFetch' | |
| const url = 'https://pokeapi.co/api/v2/pokemon/pikachu' | |
| function ExampleComponent () { | |
| const {isLoading, data} = useFetch(url) | |
| return ( | |
| <> | |
| {isLoading && <p>Loading ...</p>} |
| /** | |
| * WOYTON Salad bar - Food scraper. | |
| * | |
| * About | |
| * - Tech demo of a functioning real world scraper, that actually worked and resulted in random salad orders. | |
| * Not judging if these actually tasted good or not ;) ... As of 2023, the technology is outdated | |
| * and you might find tools like Puppeteer easier to use, than the messy Selenium + browser stack. | |
| * | |
| * Note | |
| * - Any URLs and personal data have been censored to avoid messing around with their website ;) |
TDD-focused mini tutorial for an imaginary, minimal feature described below.
Goals: Deeply think about features, expectations and limitations. Write code last.
Based on the '5 Step Method' described on CodeUtopia.
| /** | |
| * Generate random hex color of defined length. | |
| * | |
| * Color function returns 1-2 values on each call. | |
| * The result is filled up from a potentially missing value. | |
| * | |
| * @example | |
| * getRandomHexColor(6); // #ffffff | |
| * getRandomHexColor(8, ''); // ffffffff | |
| * @param {Number} hexLength 6|8 for full RGB|ARGB range. |
| <?php | |
| declare(strict_types=1); | |
| namespace App; | |
| use PDO; | |
| use function is_array; |
| -- CONFIG | |
| SET @prefix = 'wp_XXXX'; | |
| -- DEV -> LIVE | |
| SET @url_from = 'http://127.0.0.1'; | |
| SET @url_to = 'https://www.example.com'; | |
| -- LIVE -> DEV | |
| /* * / |
| -- Change user IDs for security. | |
| -- | |
| -- Also change manually: | |
| -- * AUTO_INCREMENT value of 'users' table, e.g. > 10000 | |
| -- * Fields in 'users' and 'usermeta' that disclose the login name | |
| -- example.com | |
| UPDATE wp_1234_users SET ID = 12345 WHERE ID = 1; | |
| UPDATE wp_1234_usermeta SET user_id = 12345 WHERE user_id = 1; | |
| UPDATE wp_1234_posts SET post_author = 12345 WHERE post_author = 1; |
| /** | |
| * Extended math functionality. | |
| * | |
| * Features | |
| * - Distance calculation | |
| * - Angle calculation and conversion | |
| */ | |
| class MathHelper { | |
| /** | |
| * Constructor |
| /** | |
| * Canvas 2D API helper functions. | |
| * | |
| * Features | |
| * - Clear/Reset canvas data. | |
| * - Simplify translation + rotation. | |
| * - Draw points, boxes, lines as visual helpers. | |
| */ | |
| class CanvasHelper { | |
| #optionsDefault = { |