Skip to content

Instantly share code, notes, and snippets.

View theasta's full-sized avatar

Alexandrine Boissière theasta

View GitHub Profile
@theasta
theasta / comparejsmin
Created October 5, 2014 22:38
Compare js file size before and after minification with uglifyJS2
function comparejsmin() {
local origsize=$(wc -c < "$1")
local uglifysize=$(uglifyjs "$1" | wc -c)
local ratio=$(echo "$uglifysize * 100/ $origsize" | bc -l)
printf "Unminified file: %d bytes\n" "$origsize"
printf "Minified file: %d bytes (%2.2f%%)\n" "$uglifysize" "$ratio"
}
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@theasta
theasta / radix-conversion.js
Created March 29, 2015 16:39
Decimal, Hexadecimal, Binary Conversion in JavaScript
// Convert from decimal to binary
(11).toString(2) // “1011"
// Convert from decimal to hexadecimal
(255).toString(16) // ‘ff'
// Convert from binary to decimal
parseInt("1011", 2); // 11
// Convert from binary to hexadecimal
@theasta
theasta / openLC
Last active March 31, 2021 08:41
Download and open a file at a specific line and column
#!/bin/bash
# $1 has to match this pattern: http://example.com/file.js:3:10
# First get back the url, the line and the column
regex="(https?:.*):([0-9]+):([0-9]+)"
dir="/tmp/"
[[ $1 =~ $regex ]]