Skip to content

Instantly share code, notes, and snippets.

View purarue's full-sized avatar
📀
:)

purarue

📀
:)
View GitHub Profile
#!/bin/bash
# enter length on command line. e.g. genpasswd 50
#B8G6I1l0OQDS5Z2 are problematic characters, could be mistaken as others characters when trying to read passwords.
passwordChars="abcdefghijkmnopqrstuvwxyzACEFHJKLMNPRTUVWXY()~%^&*-+=|{}[]<>,.?/3479"
passwdLength=$1 # get length from CLI
if [[ "$passwdLength" -le 0 ]]; then
passwdLength=30 # default length if not given
fi
# on average (1000 tests), the amount of characters that comes from /dev/urandom that fit the passwordChars
# is 26.1%. Reduced down by tr, 1000 characters fro had a min of 217 and a max of 310, with a standard deviation
@purarue
purarue / Hide E501 Warnings
Last active October 29, 2024 22:08
Hides E501 ('line too long') errors on pep8online.
// ==UserScript==
// @name Hide E501 Warnings
// @namespace github.com/purarue
// @version 0.1
// @description Hides E501 ('line too long') errors on pep8online.
// @author purarue
// @match http://pep8online.com/checkresult
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==
// ==UserScript==
// @name add link to all python versions to favorite tags
// @namespace https://gist.github.com/purarue
// @version 0.2
// @description add a link which takes you your watched tags which takes you to questions for every python version on stackoverflow
// @author You
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @include /^https?:\/\/stackoverflow\.com\/?(questions)?\/?(tagged)?\/?
// @exclude /^https?:\/\/stackoverflow\.com\/questions\/\d+
// @grant none
@purarue
purarue / yotube-dl-install.sh
Last active February 21, 2019 23:37
Install youtube-dl on mac
# Open a terminal, and run these:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update && brew upgrade
brew install youtube-dl
cd ~/Downloads # the music should be downloaded to Downloads
youtube-dl -f best --extract-audio --audio-format mp3 SONG/VIDEO_URL_HERE # to convert a video to mp3/download a mp3
youtube-dl -f best VIDEO_URL_HERE # download a video
@purarue
purarue / killdpkg.sh
Created May 1, 2019 05:39
This kills all apt processes, and removes and reconfigures dpkg locks and starts apt upgrade on a new VM
sudo killall apt apt-get
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
sudo dpkg --configure -a
sudo apt update && sudo apt upgrade
@purarue
purarue / lagtracker.py
Created June 28, 2019 03:16
LagTracker
# Didnt end up using this, but it could be useful in the future.
class LagTracker:
"""A class representing a moving average; lag time between sending messages"""
__slots__ = ["latency", "cur_avg"]
def __init__(self):
self.latency = []
self.cur_avg = 0
@purarue
purarue / chromedriver.md
Last active October 29, 2024 21:46
Chromedriver Installation

Binary downloads for all OS's here.


Mac with brew:

brew install chromedriver

Located at /usr/local/bin/chromedriver

@purarue
purarue / flexbox_row_example.html
Created July 10, 2019 19:17
Basic example using a horizontal flexbox
<!DOCTYPE html>
<html lang="en">
<head>
<title>Flexbox Example</title>
<style>
.flexbox {
margin: 100px auto 0 auto; /* basic margins */
min-height: 400px; /* minimum height of 500px, as long as the things inside dont grow beyond that */
height: auto; /* if div's inside are larger than 500px, this should 'auto'matically grow */
width: 80%; /* 80% of page next container up (the body, whole page) */
@purarue
purarue / trivial_flask_example.py
Last active July 11, 2019 03:49
basic one file Flask example to explain routes and replacement fields
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
return "Hello world"
def generate_style(class_name, color):
@purarue
purarue / xkcd-read.py
Last active July 11, 2019 22:31
Opens xkcd's downloaded using xkcd-dl chronologically, waiting for user input between each comic
#!/usr/bin/env python3
"""
Opens xkcd's downloaded using xkcd-dl chronologically using the show_xkcd function from
https://github.com/tasdikrahman/xkcd-dl/
Assumes you already have the xkcd's downloaded in the xkcd_archive folder (i.e. using --download-all)
(though you could just have the start/end folders in xkcd_archive and xkcd-dl would download them when asked to open)
Can pass a start xkcd like: