Skip to content

Instantly share code, notes, and snippets.

@dimitrovs
dimitrovs / convert-blob.js
Created December 27, 2020 03:14
Blob<>JSON
// credits: https://stackoverflow.com/questions/27232604/json-stringify-or-how-to-serialize-binary-data-as-base64-encoded-json
// Blob to JSON
const blobToBase64 = (blob) => {
return new Promise((resolve) => {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function () {
resolve(reader.result);
};
@dimitrovs
dimitrovs / Android-Emulator-on-AWS-EC2.txt
Last active December 15, 2019 21:07 — forked from atyachin/Android-Emulator-on-AWS-EC2.txt
Installing and running Android Emulator on Amazon AWS EC2 (Ubuntu 16.04 / m5.xlarge)
Steps for installing the Android Emulator from EC2 console:
-----------------------------------------------------------
sudo apt install default-jdk unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d android-sdk
sudo mv android-sdk /opt/
export ANDROID_SDK_ROOT=/opt/android-sdk
echo "export ANDROID_SDK_ROOT=/opt/android-sdk" >> ~/.bashrc
echo "export PATH=$PATH:$ANDROID_SDK_ROOT/tools" >> ~/.bashrc
. .bashrc
@dimitrovs
dimitrovs / gist.sh
Created August 27, 2017 04:42
Most useful Docker command
docker images -q | xargs docker rmi
@dimitrovs
dimitrovs / gist:124efbfb95ed27616b48bb2fe505c513
Created March 29, 2017 00:22
Start iPython in current directory
docker run -d -v $(pwd):/home/jovyan/work -p 8888:8888 jupyter/minimal-notebook
events {
worker_connections 4096;
}
http {
client_max_body_size 0;
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:3000/;
@dimitrovs
dimitrovs / client_up.sh
Created October 5, 2016 01:48
OpenVPN Client Up Script
#!/bin/bash
#Clear all routes on vpn routing table (this is to make sure there isn't any crap left over from a previous vpn connection
/sbin/ip route flush table 100
#Copy routing table from main routing table into vpn table
/sbin/ip route show table main | grep -Ev ^default | while read ROUTE ; do ip route add table vpn $ROUTE; done
#Add default gateway to vpn routing table
/sbin/ip route add default via ${route_vpn_gateway} dev ${dev} table 100
/sbin/ip rule add from ${ifconfig_local} table 100
@dimitrovs
dimitrovs / IndexController.js
Created August 19, 2016 04:55
Sails.js SPA routes
module.exports = {
index: function(req, res) {
res.sendfile(__dirname, 'index.html');
}
};
@dimitrovs
dimitrovs / crontab
Created July 31, 2016 00:11
Script to update IPv6 tunnel when IPv4 changes
0,15,30,45 * * * * sh *full path to script here*/*scriptnamehere*.sh &>/dev/null
@dimitrovs
dimitrovs / dockerhost.sh
Last active September 17, 2017 20:36
Add the IP of a dockerhost to the /etc/hosts file of a Docker container if not already there.
#!/bin/bash
if [[ -z $(grep dockerhost /etc/hosts) ]]
then
echo `/sbin/ip route|awk '/default/ { print $3 }'` dockerhost >> /etc/hosts
fi
setInterval(function() {
var ts = Math.round((new Date()).getTime() / 1000);
client.query('BEGIN', function(err, result) {
if (err) {
return console.error('error running query', err);
}
for (var k in big_dict) {
// use hasOwnProperty to filter out keys from the Object.prototype
if (big_dict.hasOwnProperty(k)) {
var symbol = k;