Skip to content

Instantly share code, notes, and snippets.

@kylekyle
kylekyle / sync_grades.rb
Created December 13, 2019 16:29
Canvas -> AMS with Watir
require 'csv'
require 'watir'
raise "Need a TSV with grades!" if ARGV.empty?
puts "Navigate to your Grade Book to continue ...";
browser = Watir::Browser.new :chrome, :switches => %w[--log-level=3 --test-type]
browser.goto 'https://apps.westpoint.edu/ams/main.cfm'
browser.wait_until(timeout: 3600) { browser.title[/Grade Book/] }
@kylekyle
kylekyle / urllib.py
Last active February 11, 2020 23:35
urllib parsing
import pandas as pd
from urllib.parse import urlparse
df = pd.read_csv("onions.txt", names=["domain"])
df[df["domain"].apply(lambda x: urlparse("http://"+x).netloc).duplicated(keep=False) == True]
@kylekyle
kylekyle / blackjack-agent.ipynb
Last active March 6, 2020 18:29
keras-rl based deep q-learning agent using OpenAI Gym’s Blackjack-v0 environment that runs in Google Colab.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylekyle
kylekyle / digital_picture_frame.rb
Created March 17, 2020 18:34
Prep pictures for display on a VIEWline widescreen digital picture frame
# Prep pictures for display on a VIEWline widescreen digital picture frame
# - The file types Google Photo dumped out: heic, mov, jpg, mp4
# - To check that you don't have any others:
# > Dir.entries('.').reject{|f| f.start_with? '.'}.map(&:downcase).map{|f| File.extname f}.uniq
# - Recommend doing orientation adjustments before exporting
require 'mini_magick'
require 'securerandom'
files = Dir.entries('.').select do |file|
@kylekyle
kylekyle / onion_search.rb
Last active March 26, 2020 19:17
Search the Common Crawl for dark web domains
# a few flags will make this run a skosh faster:
# jruby -0 -J-Xmn512m -J-Xms2048m -J-Xmx2048m -J-server onion_search.rb
# For details on reading WARC records:
# https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.0/#file-and-record-model
require 'csv'
require 'fileutils'
# using java for two reasons: Java has native threads
# and Java's gzip reader supports concatenated zips
@kylekyle
kylekyle / using-aquamentus-to-train-neural-networks.ipynb
Last active April 11, 2020 17:14
Using Aquamentus to Train Neural Networks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylekyle
kylekyle / titanic.ipynb
Created April 20, 2020 17:31
titanic.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylekyle
kylekyle / style_transfer.py
Last active May 20, 2020 00:42
Large resolution style transfer
# -*- coding: utf-8 -*-
# style_transfer.py <content> <style>
# CUDA_VISIBLE_DEVICES=3 python style_transfer.py walk.jpg kandinsky.jpg
import sys
content_path = sys.argv[1]
style_path = sys.argv[2]
max_dim = 1024
total_variation_weight=30
@kylekyle
kylekyle / garageDoor.c
Last active June 20, 2020 20:38
Control a garage door with a Raspberry Pi and Echo
// A script that runs a raspberry pi to receive commands from an echo
// and control a garage door opener wired to the GPIO
// To set up the Echo, follow this guide:
// https://read.acloud.guru/how-to-build-your-own-alexa-voice-activated-iot-smart-lamp-for-less-than-35-9820ccd07516
// To compile this script, use the Makefile in the subscribe_publish_sample of the AWS IoT Device SDK. You'll
// need to link in the wiringPi library.
// If you are having policy issues, you can create a super-permissive policy that will let your device do anything:
@kylekyle
kylekyle / washing_machine_monitor.js
Created July 2, 2020 20:13
Monitor when an appliance turns on/off using a Tuya compatible (Smart Life and a bunch of other brands) smart plug
const axios = require('axios')
const TuyAPI = require('tuyapi');
var connected = false;
var washerWasOn = false;
// follow these instructions to get the key and id for your plug:
// https://github.com/AMoo-Miki/homebridge-tuya-lan/wiki/Setup-Instructions
const washer = new TuyAPI({
id: 'YOUR ID',