Skip to content

Instantly share code, notes, and snippets.

View dannycroft's full-sized avatar

Danny Croft dannycroft

View GitHub Profile
npm config set cache-min 9999999
CACHE ALL THE THINGS!!!
─────────────────────────────▄██▄
─────────────────────────────▀███
────────────────────────────────█
───────────────▄▄▄▄▄────────────█
──────────────▀▄────▀▄──────────█
──────────▄▀▀▀▄─█▄▄▄▄█▄▄─▄▀▀▀▄──█
@dannycroft
dannycroft / quicksort.elm
Created March 7, 2017 19:00
Elm - Quicksort
import Html exposing (text)
main =
text (toString (quicksort [5,3,8,1,9,4,7]))
quicksort : List comparable -> List comparable
quicksort list =
case list of
[] ->
[]
@dannycroft
dannycroft / mergesort.elm
Created March 7, 2017 19:02
Elm - Mergesort
import Html exposing (text)
main =
text (toString (mergesort [5,3,8,1,9,4,7]))
{-| Sorts a list of values by:
1. If the list has zero or one element, it is sorted!
2. If it is longer, split it into two sublists
3. Sort those sublists
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
file=$2
aws_path=$3
bucket='my-aws-bucket'
date=$(date +"%a, %d %b %Y %T %z")
#!/bin/sh
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
append_to_zshrc() {
fetch('//freegeoip.net/json/').then(r => r.json()).then(r => console.log(r));
curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" https://google.com
#!/bin/bash
# ./ttfb https://www.google.com ~/your-log-file.txt
function ttfb() {
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
-w "%{time_connect} %{time_starttransfer} %{time_total}" \
$1
}
@dannycroft
dannycroft / tti.js
Created June 16, 2017 06:06
TTI - console measurement
var t = window.performance.timing;
var interactive = t.domInteractive - t.domLoading;
var dcl = t.domContentLoadedEventStart - t.domLoading;
var complete = t.domComplete - t.domLoading;
console.log('interactive: ' + interactive + 'ms, ' + 'dcl: ' + dcl + 'ms, complete: ' + complete + 'ms');
@dannycroft
dannycroft / main.go
Created September 22, 2017 17:09
Fibonacci in GO
package main
import "fmt"
func fibonacci() func() int {
first, second := 0, 1
return func() int {
ret := first
first, second = second, first+second
return ret