Skip to content

Instantly share code, notes, and snippets.

View wlib's full-sized avatar
🔙
delete all code

Daniel Ethridge wlib

🔙
delete all code
View GitHub Profile
@wlib
wlib / bookmarklet.md
Last active November 19, 2019 00:51
Toggle quizlet test answers on and off every time you press the escape key
javascript:script=document.createElement("script");script.src="https://cdn.rawgit.com/wlib/0d4c68436f7930a8804a109afe484317/raw/quizletTestAnswers.js";document.body.appendChild(script);//
@wlib
wlib / e.rb
Last active February 14, 2017 00:22
Calculate E in Ruby
#!/usr/bin/env ruby
# Watch how E changes as n increases
# For good display, I set the cursor off
# To make your cursor appear again, try ``printf "\033[?25h"
def e(rounds)
print "\033[?25l"
for n in 1..rounds do
e = (1 + 1.0 / n) ** n
if n % 10 == 0
@wlib
wlib / parseQuery.js
Last active December 15, 2016 02:40
Parse a URL query i.e. https://example.com/page?queryKey=value&embeddedJson={"json":{"can":"be%20embedded","nested":true}} into an object using javascript. Parses both key=value pairs and nested JSON just fine.
// Without an argument, just parse the current page's URL, if an argument is supplied, parse that
function parseQuery(query = window.location.search.substring(1)) {
// Decode the URL-safe query string into a regular string e.g.("%20" => " ")
const decodedQuery = decodeURIComponent(query);
// Split that string at every "&" to get all the key=value pairs
const allpairs = decodedQuery.split("&");
// Declare an object to hold our output
const out = {};
// This regex matches what seems to look like valid JSON
const regex = /^[\[|\{](\s|.*|\w)*[\]|\}]$/g;
@wlib
wlib / yt-sig.js
Last active June 11, 2019 11:52
Does a youtube video have a scrambled signature or not?
function parse(query) {
const allpairs = query.split("&");
const out = {};
for (let i = 0; i < allpairs.length; i++) {
let pair = allpairs[i].split("=");
let key = pair[0];
let val = pair[1];
out[key] = val;
}
return out;
@wlib
wlib / .bashrc-apt-functions
Created December 31, 2016 00:46
Bash functions to quickly install programs with apt, from a repository and from any .deb file
# Add this to your ~/.bashrc file for quick installation of .deb files, you can then update programs with `debinst URL`
inst() {
sudo apt install $1 --assume-yes
}
debinst() {
wget $1 -O /tmp/install.deb
sudo dpkg -i /tmp/install.deb
inst -f
@wlib
wlib / get_favicon.rb
Last active January 5, 2017 16:26
Get a website's favicon via duckduckgo
def get(path="/", domain="https://api.duckduckgo.com")
require 'open-uri'
endpoint = "#{domain}/#{path}"
body = open(endpoint).read
return body
end
def get_favicon(page)
favicon = get("/i/#{page}.ico")
require 'digest'
@wlib
wlib / summ
Last active February 10, 2017 06:46
Summarize a file with freesummarizer.com
#!/usr/bin/env ruby
# Summarize a long file
# Uses the wonderful freesummarizer.com API
# Implemented by Daniel Ethridge
require 'uri'
require 'net/http'
# Get the text to summarize
@wlib
wlib / githubCodeWindowEnlarger.js
Last active February 22, 2017 03:15
Make the gist or github online editor larger
javascript:(function(){const editor%3Ddocument.querySelector("div.commit-create > div.CodeMirror");editor.setAttribute("style"%2C"height%3A50%25");})();//
@wlib
wlib / githubOpenHTML.js
Created February 22, 2017 03:29
Open a gist or github code window as html in a new tab
javascript:(function(){const code%3Ddocument.querySelector("div.commit-create > textarea").value;const tab%3Dwindow.open();tab.document.write(code)})();//
@wlib
wlib / duolingoVocab.js
Last active February 24, 2017 14:55
Get all your duolingo vocab words, then import them to quizlet as a set
// You must run this on the website because of the
// authentication method and CORS
// We get the definitions here
function callback(defs) {
window.quizlet = "";
for (let word in defs) {
quizlet += (word + "\t" + defs[word].join(", ") + "\n");
}
console.log(quizlet);