Skip to content

Instantly share code, notes, and snippets.

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 7, 2025 23:53
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
package main
import (
"encoding/json"
"fmt"
)
var jsonStr = []byte(`
{
"things": [
@esimov
esimov / prime_goroutine.go
Last active September 26, 2018 02:55
Filter prime numbers in Go lang concurently using goroutines
package main
import "fmt"
// Generate the input values passing through the go channel pipe
func generate(ch chan int) {
go func() {
for i := 2; ; i++ {
ch <- i
}
@javierarques
javierarques / protractorAPICheatsheet.md
Last active March 3, 2025 17:08
Protractor API Cheatsheet
@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);
@wojteklu
wojteklu / clean_code.md
Last active May 10, 2025 21:00
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

@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'.

@alexellis
alexellis / k8s-pi.md
Last active December 13, 2024 23:24
K8s on Raspbian
@posener
posener / go-table-driven-tests-parallel.md
Last active April 24, 2025 20:46
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()
@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"