Skip to content

Instantly share code, notes, and snippets.

@dat-boris
dat-boris / lcs.py
Created January 24, 2019 16:48
Solving longest common subsequence from a set of words
""" A snippet for calculating longest subsequence of list of words
"""
import re
# copy and paste seperation into here
INPUT = filter(len, """
fuad-not-distressed
arrows_counterclockwise
""".split('\n'))
@dat-boris
dat-boris / treemap_scripts.py
Created October 23, 2018 19:28
A hack of the out of date treemap
"""
This is scripts.py from
https://pypi.org/project/treemap/#description
TODO: update API to talk to latest coverage version
"""
import operator
import random
import colorsys
@dat-boris
dat-boris / compare_page_perf.ipynb
Created October 18, 2018 23:12
A notebook for identifying difference in page performance
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dat-boris
dat-boris / get_ga_data.py
Created September 27, 2018 23:08
Get GA data via service account
#!/usr/bin/python
from __future__ import print_function
import os
import sys
from googleapiclient.errors import HttpError
from googleapiclient import discovery
from oauth2client.service_account import ServiceAccountCredentials
from dateutil.parser import parse
@dat-boris
dat-boris / async-puzzle.js
Last active September 15, 2018 17:09
A small async-await puzzle
/**
A small puzzle from a stupid bug today - what do you need to fill in at `XXX` to make the second assertion true?
I learn quiet a bit more `async` `await` from this…. before this I intuitively sees it async and await as countering each other:
• `async` wraps a promise layer
• `await` unwraps a promise layer
but this bug certainly expose my misunderstanding….
*/
@dat-boris
dat-boris / get_stackdriver_metrics.py
Created August 29, 2018 00:19
Getting metrics from stackdriver
"""
Code for exporting datastore consumption for last month
DOC:
https://cloud.google.com/monitoring/docs/reference/libraries#client-libraries-usage-python
Code snippet:
https://cloud.google.com/monitoring/custom-metrics/reading-metrics
"""
import csv
@dat-boris
dat-boris / PingboardVacationSync.js
Last active January 31, 2025 23:04
Syncing pingboard calendar to my own calendar via Google app script
/**
* To use:
* 1. customize the script (see CUSTOMIZE below)
* 2. Add this to your Google App Script dashboard https://script.google.com/a/xxx.org/
* 3. Test run and you should see new event added to your calendar
* 4. Add a trigger - e.g. to run every minute
*
* Originally from
* https://webapps.stackexchange.com/questions/108132/how-to-automatically-forward-events-from-one-google-calendar-to-another
*
@dat-boris
dat-boris / tensorflow_opencv_ubuntu_deps.sh.txt
Last active September 16, 2017 21:34 — forked from CapCap/tensorflow_opencv_ubuntu_deps.sh.txt
Paperspace tensorflow+opencv setup for both python2 and python3 on ubuntu 16
#!/bin/bash -xe
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Stuff for making stuff
sudo apt-get update
sudo apt-get install -y build-essential gcc checkinstall cmake pkg-config git unzip wget gdb
@dat-boris
dat-boris / neural_style.md
Last active September 17, 2017 13:08
Getting started with Neural Style learning
@dat-boris
dat-boris / setup_vpn_docker.sh
Created June 10, 2017 16:52
Simple VPN docker setup
#!/bin/bash -xe
# https://www.digitalocean.com/community/tutorials/how-to-run-openvpn-in-a-docker-container-on-ubuntu-14-04
OVPN_DATA="ovpn-data"
docker run --name $OVPN_DATA -v /etc/openvpn busybox
docker run --volumes-from $OVPN_DATA --rm kylemanna/openvpn ovpn_genconfig -u udp://fly.techie.im:1194
docker run --volumes-from $OVPN_DATA --rm -it kylemanna/openvpn ovpn_initpki
# generate the client - x4SLFY6MbvmqbVfe
docker run --volumes-from $OVPN_DATA --rm -it kylemanna/openvpn easyrsa build-client-full pacman nopass
docker run --volumes-from $OVPN_DATA --rm kylemanna/openvpn ovpn_getclient pacman > pacman.ovpn