Skip to content

Instantly share code, notes, and snippets.

@hangst
hangst / toyaml.js
Last active April 20, 2020 08:16
Stringifies Javascript object to YAML
function toYAML(src, pad=0, nested_list=false){
function f(i, nested_list, size){
if (i == 0 && !nested_list) return `\r\n${" ".repeat(size)}`
else if(i != 0) return `${" ".repeat(size)}`
return ""
}
var tabsize = 2
var dst = ""
if(Array.isArray(src)){
src.forEach(function(s, i){
@hangst
hangst / key_solver.py
Last active April 7, 2020 13:59
Solution to the key problem
#!/usr/bin/env python
"""
Problem statement: Find the three digit number
147 - One digit is right but in the wrong place
189 - One digit is right and in its place
964 - Two digits are correct but both are in the wrong place
523 - All digits are wrong
286 - One digit is right but in the wrong place
"""
@hangst
hangst / mwc.sh
Last active September 19, 2020 14:06
Bundles and minifies Material Web Components
folder=mwc_$(date +%s%N)
mkdir $folder
cd $folder
sudo apt-get -qq --assume-yes install minify npm
eval npm install \
@material/mwc-button \
@material/mwc-checkbox \
@material/mwc-circular-progress \