Skip to content

Instantly share code, notes, and snippets.

@douglascayers
douglascayers / docker-destroy.sh
Last active April 3, 2024 16:19
🗑 Delete all docker services, containers, images, and volumes
#!/usr/bin/env zsh
# Exit when any command fails
set -e
# https://docs.docker.com/engine/reference/commandline
SCRIPT_NAME=$(basename ${0})
DELETE_BUILDER_CACHE=0
@MatteoJoliveau
MatteoJoliveau / what.cr
Created June 22, 2018 12:23
A minimal POC to validate an IoC container in Crystal
abstract struct Any; end
record A(T) < Any, this : T
class What
def hello()
puts "Hello!"
end
end
container = {} of String => Any
@dominikwilkowski
dominikwilkowski / README.md
Created February 22, 2017 23:11
Flatten javascript objects into a single-depth object with ES6

Flatten a deep javascript object into single-depth object with ES6

Call it via:

const flat = flatten( realDeepObject );

Test case:

@saurabhshri
saurabhshri / pip.md
Last active June 7, 2024 12:58
Install and use pip in a local directory without root/sudo access.

Install and use pip in a local directory without root/sudo access.

Why?

Many users when are given server access, do not have root (or sudo) privileges and can not simply do sudo apt-get install python-pip . Here's an easy way you can install and use pip without root (or sudo) access in a local directory. Note : This works without easy_install too.

How?

// http://www.2ality.com/2013/09/javascript-unicode.html
function toUTF16(codePoint) {
var TEN_BITS = parseInt('1111111111', 2);
function u(codeUnit) {
return '\\u'+codeUnit.toString(16).toUpperCase();
}
if (codePoint <= 0xFFFF) {
return u(codePoint);
}
@kdabir
kdabir / heredoc_json.bash
Last active January 11, 2024 02:25
json in heredoc in bash script alongwith variable substitution
_BUCKET_NAME="foo.example.com"
_POLICY=$(cat <<EOT
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
@bds
bds / .vimrc
Created November 14, 2015 20:54
.vimrc
set nocompatible " We are using Vim
syntax on
" * PLUGINS
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
@bds
bds / .bashrc
Last active January 14, 2021 19:12
dotfiles
# Cult of Vi
set -o vi
export VISUAL=vim
export EDITOR="$VISUAL"
# Colors!
alias ls='ls -G'
# History
export HISTFILE=~/.bash_history
@bds
bds / .vimrc
Created August 6, 2015 22:08
Minimal .vimrc
set nocompatible " We are using Vim
syntax on
set colorcolumn=80
set ruler
hi StatusLine ctermfg=0 ctermbg=3 cterm=bold " Window highlighting
hi StatusLineNC ctermfg=white ctermbg=4 cterm=none
hi Folded ctermfg=244 ctermbg=0 cterm=none " Code folding highlight
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active July 15, 2024 19:07
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on