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 / duolingoTanslateAPI.rb
Last active February 24, 2017 02:53
Duolingo translate API
# Duolingo's unofficial translation API
# Please comment or send me a message if you find more endpoint and/or info
require "open-uri"
require "json"
require "cgi"
def ask()
# Get languages
puts "* Use language codes, i.e. `en`, `de`, `ru` *"
@wlib
wlib / windowForkBomb.js
Last active June 3, 2023 11:19
JS window fork bomb
// Make sure to allow pop ups, or your browser will stop the window.open() (thankfully)
function fork() {
const win = window.open();
const script = win.document.createElement("script");
script.innerHTML = fork + "\n" + "fork();";
win.document.head.appendChild(script);
setTimeout(function() {
win.close();
fork();
pro = new Promise(function(resolve, reject) {
setTimeout(function() {
if (true) {
resolve("Yay");
}
else {
reject("Uh oh");
}
}, 1000);
});
@wlib
wlib / localFiles.js
Last active March 4, 2017 20:44
Load local files from disk and return blobs, or read them as text, uses promises
function loadFile() {
const input = document.createElement("input");
input.type = "file";
input.click();
return new Promise(function(resolve, reject) {
input.onchange = function() {
resolve( input.files[0] );
};
});
}
@wlib
wlib / fib.js
Created April 7, 2017 20:00
How on earth is this calculated so quickly?
function fib(length) {
const values = [0, 1];
for (let i = 0; i < length - 2; i++) {
let a = values[i];
let b = values[i + 1];
values[i + 2] = a + b;
}
return values;
}
async function uriToArrayBuffer(uri) {
const fetched = await fetch(uri)
const body = await fetched.body.getReader();
const read = await body.read();
return read.value.buffer;
}
@wlib
wlib / enableChromeDino.bookmarklet.md
Created September 6, 2017 03:02
Enterprise enrolled chromebooks at schools disable the chrome dino game. This is a work-around to make life without wifi fun again.
  1. Copy the bottom line of code
  2. If the bookmarks bar is hidden, use the keystoke (Control + Shift + B)
  3. Right click on Bookmarks Bar
  4. Select "Paste"
  5. Click that bookmark whenever you are offline, right before you actually start playing the dino game
  6. To test this out now, type "chrome://dino" in the url box

javascript:Runner.instance_.loadImages();style=document.createElement("style");document.head.appendChild(style);style.sheet.insertRule(".snackbar-show { animation: unset }");

async function getEthereumAssets(address) {
const baseURL = "https://api.ethplorer.io/getAddressInfo/";
const fetched = await fetch(`${baseURL}${address}?apiKey=freekey`);
const { tokens } = await fetched.json();
for (let i in tokens) {
const token = tokens[i];
const name = token.tokenInfo.name;
const balance = token.balance / (10 ** token.tokenInfo.decimals);
const rate = token.tokenInfo.price.rate;
console.log(`${name}: $${balance * rate}`);
async function getEthereumAssets(address) {
const baseURL = "https://api.ethplorer.io/getAddressInfo/";
const fetched = await fetch(`${baseURL}${address}?apiKey=freekey`);
const { tokens } = await fetched.json();
for (let i in tokens) {
const token = tokens[i];
const name = token.tokenInfo.name;
const balance = token.balance / (10 ** token.tokenInfo.decimals);
const rate = token.tokenInfo.price.rate;
console.log(`${name}: $${balance * rate}`);
<html>
<head>
<title>Zalgo Generator</title>
<script src="./zalgo.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.5.2/css/bulma.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<section class="hero is-info is-fullheight is-bold">
<section class="section">