Skip to content

Instantly share code, notes, and snippets.

View danthemango's full-sized avatar

danthemango danthemango

View GitHub Profile
@danthemango
danthemango / .vimrc
Created September 23, 2015 22:38
My .vimrc
"if you're unsure, every setting is avalable in the help menu
"just type :help (setting) to check what every setting does
set mouse=a "mouse controls
set shiftwidth=3 "number of spaces per tab
set tabstop=3
set expandtab "spaces instead of tabs
set smarttab
set ai "automatically indent line when pushing enter set si "smart indent
"set lbr "automatic line break
"set tw=94
@danthemango
danthemango / Makefile
Last active February 2, 2018 04:06
Testcasing Makefile
###############################################
## Filename: Makefile
## Author: Daniel Guenther
## Date: 2018-01-31
## Purpose: To quickly create and run test cases for a small program
###############################################
program=gcl -f lab3.cl
testdir=Tests
@danthemango
danthemango / throwclass.cpp
Created February 21, 2018 04:42
Minimal C++ Exceptions with exception class
// example program which throws a class exception
#include <iostream>
using namespace std;
// my error class
class WrongFormat{
public:
string what(){
return string("Wrong Format!");
}
# builds a roadmap of Vancouver, coloured by road suffix
# most of the code taken from github.com/erdavis1/RoadColors
# install the packages, you only need to do this once.
install.packages(c('sf', 'foreign', 'tidyverse', 'lwgeom'))
# load in the necessary libraries
library(sf)
library(foreign)
library(tidyverse)
@danthemango
danthemango / faceviewer.py
Created August 9, 2020 03:03
opens a webcam, and zooms-in on a detectable face
import numpy as np
import matplotlib.pyplot as plt
import cv2
def getFaceCrop(image):
# get image classifier
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image_copy = np.copy(image)
gray_image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
@danthemango
danthemango / xkcdnav.js
Last active July 26, 2021 02:53
userscript to navigate XKCD with J and K
// ==UserScript==
// @name XKCD Nav
// @namespace http://tampermonkey.net/
// @version 0.1
// @description move back and forth in xkcd comic with J and K
// @match https://*.xkcd.com/*
// @grant none
// ==/UserScript==
// main
(function() {
@danthemango
danthemango / livechatpusher.js
Last active March 13, 2024 00:07
Userscript to keep youtube chat to "live chat" (instead of "top chat")
// ==UserScript==
// @name YouTube Persistent Live Chat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Try to keep youtube livestream chat in "live chat" or "live chat replay" mode
// @include https://www.youtube.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@danthemango
danthemango / dlclip.sh
Last active February 24, 2022 08:40
Bash script to dowload a video section by timestamp via youtube-dl and ffmpeg (works for youtube, twitch, etc.)
#!/bin/bash
function printUsage() {
echo "usage: bash $0 -i <inurl> -ss <starttime> -t <duration> -o <outfile>"
echo ' other args are passed directly to youtube-dl; eg, -r 40K'
}
if [ "$#" -eq 0 ]; then
printUsage
exit
@danthemango
danthemango / getURLTime.js
Created February 15, 2022 23:00
quick javascript function to fetch youtube timestamp from livestream, for pasting into devtools
(function getURLTime() {
const params = (new URL(document.location)).searchParams
if(params.has('v')) {
const v = params.get('v');
const ytplayer = document.getElementById("movie_player");
const t = Math.round(ytplayer.getCurrentTime())
const newUrl = `https://youtu.be/${v}?t=${t}`;
return newUrl;
}
return document.location;
@danthemango
danthemango / string2json.sh
Created July 3, 2023 02:20
Factorio blueprint share string to json
# note: zlib-flate is part of the 'qpdf' package
tail -c +2 factoriostring.txt | base64 -d | zlib-flate -uncompress