Skip to content

Instantly share code, notes, and snippets.

// 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 / gist:2207826
Created March 26, 2012 17:58
Convert files from .scss to .sass
sass-convert -F scss -T sass application_styles.css.scss application_styles.css.sass
@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 / docker-gdb.sh
Last active September 3, 2018 19:45
Use gdb with Docker
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined
@bds
bds / osx-gui-notify.sh
Created September 1, 2018 19:34
OSX GUI notification
osascript -e 'display notification "Lorem ipsum dolor sit amet 2" with title "Title"'
@bds
bds / inotify-compile.sh
Created September 1, 2018 19:31
Use inotify modify events to compile Crystal Lang
#! /usr/bin/env sh
#
# https://github.com/rvoicilas/inotify-tools/wiki#inotifywait
#
CURPATH=`pwd`
inotifywait -mr \
--exclude "[^c][^r]$" \
--timefmt '%d/%m/%y %H:%M:%S' --format '%T %w %f' \
-e modify /usr/src/app/my-app/src | while read date time dir file; do
@bds
bds / scrappy.rb
Created March 13, 2014 20:47
Scraping web pages with Ruby for fun and profit
# print the numbers 1 to 5
(1..5).each do |page|
puts page
end
# print a url string with a page number inside
(1..5).each do |page|
puts "http://blog/scripted.com/page/#{page}"
end
@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?

@bds
bds / gist:2285686
Created April 2, 2012 17:53
Dump OSX Internet Keychain Contents
sudo security dump-keychain -d login.keychain | grep inet -A23