Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Justin Shenk justinshenk

🎯
Focusing
View GitHub Profile
@justinshenk
justinshenk / hetzner-dedicated-wipe-and-install-nixos.sh
Last active Sep 22, 2019 — forked from nh2/hetzner-dedicated-wipe-and-install-nixos.sh
Example script to install NixOS on a Hetzner dedicated server via the Hetzner rescue mode
View hetzner-dedicated-wipe-and-install-nixos.sh
#!/usr/bin/env bash
# Installs NixOS on a Hetzner server, wiping the server.
#
# This is for a specific server configuration; adjust where needed.
#
# Prerequisites:
# * Update the script to adjust SSH pubkeys, hostname, NixOS version etc.
#
# Usage:
@justinshenk
justinshenk / setup_instance.sh
Last active Jun 18, 2019
Setup Google Cloud instance for conda and jupyter notebook
View setup_instance.sh
#!/bin/bash
# Configure remote instance for jupyter notebook
# Justin Shenk - June 2019
# Create jupyter config, ip = 0.0.0.0
wget https://gist.githubusercontent.com/justinshenk/6c9ea44e46b481e49c51efd48569a0a2/raw/45b7f8b1443978b49a1b82ea86b6d13805988a08/jupyter_notebook_config.py -P ~/.jupyter
@justinshenk
justinshenk / jupyter_notebook_config.py
Last active Jun 27, 2019
Jupyter Notebook config for Google Cloud instance
View jupyter_notebook_config.py
c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.open_browser = False
@justinshenk
justinshenk / background.js
Created May 13, 2019
Background script for Agreed - Slack Chrome Extension
View background.js
chrome.commands.onCommand.addListener(function(command) {
if (command === "agree-first-reaction") {
chrome.tabs.executeScript({
code: `
function clickFirstReaction() {
const query = "div.c-reaction_bar > button:nth-child(1):not(.c-reaction--reacted)";
const reactionsToClick = document.querySelectorAll(query);
const beforeCount = reactionsToClick.length;
if (reactionsToClick.length) {
@justinshenk
justinshenk / background.js
Last active May 13, 2019
Agreed - Chrome Extension for agreeing with reactions on Slack
View background.js
chrome.commands.onCommand.addListener(function(command) {
if (command === "agree-first-reaction") {
chrome.tabs.executeScript({
code: ` ... // code from clickFirstReaction.js
`
})
} else if (command === "agree-every-reaction") {
chrome.tabs.executeScript({
code: ` ... // code form clickEveryReaction.js
`
@justinshenk
justinshenk / agree.js
Last active May 12, 2019
Click the first reaction in an open Slack channel
View agree.js
// How to use: open Console (View -> Developer -> Developer Tools -> Console)
// and paste one of the following:
/**
* Agree with ~first~ reaction in active Slack channel, poll every 10 seconds.
**/
function clickFirstReaction() {
$("div.c-reaction_bar > button:nth-child(1):not(.c-reaction--reacted)").click()
}
var timerID = setInterval(clickFirstReaction, 10000);
@justinshenk
justinshenk / style_transfer_webcam.py
Created Dec 9, 2018
Neural style transfer with OpenVINO and webcam
View style_transfer_webcam.py
#!/usr/bin/env python
"""
Copyright (c) 2018 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
View create_pb.py
#! /usr/bin/env python3
"""Run from root directory of repo https://github.com/lengstrom/fast-style-transfer to
create a .pb for use with OpenVINO.
"""
import sys
sys.path.insert(0, 'src')
import transform
import argparse
import tensorflow as tf
import os
@justinshenk
justinshenk / distance.py
Last active Sep 11, 2018
Posture Monitor Server for Walabot
View distance.py
#!/usr/local/env python
from __future__ import print_function
from sys import platform
from os import system
import WalabotAPI
try: # for Python 2
import Tkinter as tk
except ImportError: # for Python 3
import tkinter as tk
@justinshenk
justinshenk / idle-shutdown.sh
Last active Sep 15, 2020
Google Cloud Platform (GCP) instance idle shutdown
View idle-shutdown.sh
#!/bin/bash
# Add to instance metadata with `gcloud compute instances add-metadata \
# instance-name --metadata-from-file startup-script=idle-shutdown.sh` and reboot
# NOTE: requires `bc`, eg, sudo apt-get install bc
# Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage
threshold=0.1
count=0
wait_minutes=60
while true
You can’t perform that action at this time.