Skip to content

Instantly share code, notes, and snippets.

@bds
bds / docker-shell.sh
Created June 17, 2019 17:06 — forked from falvarez/docker-shell.sh
Run docker container, mount current working directory and get interactive shell
docker run -ti -v $(pwd):/tmp DOCKER_IMAGE /bin/bash
@bds
bds / jwtRS256.sh
Created May 27, 2019 04:00 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
// 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);
}
@bds
bds / http_streaming.md
Created September 24, 2018 16:12 — forked from CMCDragonkai/http_streaming.md
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

@bds
bds / rules for good testing.md
Created April 11, 2018 20:06 — forked from Integralist/rules for good testing.md
Sandi Metz advice for writing tests

Rules for good testing

Look at the following image...

...it shows an object being tested.

You can't see inside the object. All you can do is send it messages. This is an important point to make because we should be "testing the interface, and NOT the implementation" - doing so will allow us to change the implementation without causing our tests to break.

@bds
bds / pip.md
Created February 21, 2018 03:22 — forked from saurabhshri/pip.md
Install and use pip in a local directory without root/sudo access.

#Install and use pip in a local directory without root/sudo access. #####By: @saurabhshri

##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?

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@bds
bds / gist:613122
Created October 6, 2010 10:10 — forked from retr0h/gist:98308
CONTENT_TYPES = {:html => 'text/html', :css => 'text/css', :js => 'application/javascript'}
before do
request_uri = case request.env['REQUEST_URI']
when /\.css$/ : :css
when /\.js$/ : :js
else :html
end
content_type CONTENT_TYPES[request_uri], :charset => 'utf-8'
end