Skip to content

Instantly share code, notes, and snippets.

View elliotchance's full-sized avatar
🤓
Building awesome stuff with V

Elliot Chance elliotchance

🤓
Building awesome stuff with V
View GitHub Profile
package main
import (
"fmt"
"strings"
"sync"
"time"
)
type ChannelPerf struct {
@posener
posener / go-table-driven-tests-parallel.md
Last active March 7, 2024 16:09
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()
@byrnedo
byrnedo / ComputeHmac256.go
Created September 12, 2016 07:32
Compute a hmac for a message in golang
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
@jehaby
jehaby / README.md
Last active January 25, 2024 14:43 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@BretFisher
BretFisher / .travis.yml
Created February 15, 2016 21:26
Travis-CI Docker Image Build and Push to AWS ECR
sudo: required #is required to use docker service in travis
language: php #can be any language, just php for example
services:
- docker # required, but travis uses older version of docker :(
install:
- echo "install nothing!" # put your normal pre-testing installs here
@weavenet
weavenet / delete_all_object_versions.sh
Created May 4, 2015 05:21
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
@brandonmwest
brandonmwest / example.cs
Last active January 16, 2024 15:52
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
@abreckner
abreckner / waitsForAndRuns.js
Created May 9, 2014 01:56
Jasmine 2 plug in to re-enable waitsFor and runs functionality
// This is the equivalent of the old waitsFor/runs syntax
// which was removed from Jasmine 2
waitsForAndRuns = function(escapeFunction, runFunction, escapeTime) {
// check the escapeFunction every millisecond so as soon as it is met we can escape the function
var interval = setInterval(function() {
if (escapeFunction()) {
clearMe();
runFunction();
}
}, 1);
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active March 26, 2024 11:27
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@leongersen
leongersen / TypeHint.js
Last active October 31, 2021 08:58
Proof of concept for adding type-hinting to JavaScript.
// Set testable values;
window.Type = {
Number: 1,
String: 'a',
Function: function(){}
}
// Add a hint method;
Function.prototype.hint = function(){