Skip to content

Instantly share code, notes, and snippets.

@munificent
munificent / generate.c
Last active September 15, 2024 03:16
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@auxten
auxten / Golang Elliptic Curve benchmark.md
Last active December 22, 2021 03:41
Golang Elliptic Curve benchmark
@peterhellberg
peterhellberg / pixel-atkinson-plasma.go
Created February 13, 2018 21:15
Atkinson dithered plasma rendered by Pixel
package main
import (
"image"
"image/color"
"image/draw"
"time"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
@peterhellberg
peterhellberg / pixel-random-squares.go
Created February 13, 2018 19:53
Random squares effect rendered by Pixel. Inspiration: https://youtu.be/IGOD2eN21qI?t=3m59s
package main
import (
"image/color"
"math/rand"
"time"
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
"github.com/faiface/pixel/pixelgl"
@posener
posener / go-table-driven-tests-parallel.md
Last active September 16, 2024 16:35
Be Careful with Table Driven Tests and t.Parallel()

Be Careful with Table Driven Tests and t.Parallel()

We Gophers, love table-driven-tests, it makes our unittesting structured, and makes it easy to add different test cases with ease.

Let’s create our table driven test, for convenience, I chose to use t.Log as the test function. Notice that we don't have any assertion in this test, it is not needed to for the demonstration.

func TestTLog(t *testing.T) {
	t.Parallel()
@alexellis
alexellis / k8s-pi.md
Last active September 24, 2024 14:36
K8s on Raspbian
@fernandohu
fernandohu / Reading configuration files before application startup in Angular2 final release.md
Last active July 7, 2024 19:31
Reading configuration files before application startup in Angular2 final release

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

@wojteklu
wojteklu / clean_code.md
Last active October 4, 2024 19:21
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@ditam
ditam / extrapolateFizzBuzz.js
Created August 30, 2015 18:22
fizzbuzz extrapolation function - sample for article at ditam.github.io
function extractPatterns(sample){
var markers = {};
sample.forEach(function(element, i){
if(isNaN( Number(element) )){
var parts = element.split(/(?=[A-Z])/);
parts.forEach(function(part){
if(!markers[part]){
markers[part] = [];
}
markers[part].push(i+1);
@javierarques
javierarques / protractorAPICheatsheet.md
Last active August 20, 2024 11:27
Protractor API Cheatsheet