Skip to content

Instantly share code, notes, and snippets.

View Way's full-sized avatar

Alexander Vey Way

View GitHub Profile
@Way
Way / fetch-urls.js
Created April 20, 2020 19:50
Fetch and wait for multiple requests using async, await, and Promise.all
async function fetchUrls(urls) {
try {
// Using Promise.all() coalesce multiple promises into a single "super-promise"
return await Promise.all(
// map urls to fetch requests and parse their response as json
urls.map(url => fetch(url).then(response => response.json()))
);
} catch (error) {
console.error(error);
}
@Way
Way / fb-remove-apps-script.js
Last active March 20, 2018 22:04
Disconnect apps where you used facebook to login #deleteFacebook
// Go to https://www.facebook.com/settings?tab=applications and open Devtools > Console.
// run until you die...
setInterval(function(){
// find and click delete of the first app
document.getElementById('delete-icon').click()
// wait until the confirm modal pops up
setTimeout(function(){
// find and click the confirm button to delete the app
document.getElementsByClassName('uiButton')[1].children[0].click()
@Way
Way / parseLodash.js
Created August 9, 2015 19:34
Error handling for JSON.parse with lodash
// With Lodash
function parseLodash(str){
return _.attempt(JSON.parse.bind(null, str));
}
parse('a'); // false
parseLodash('a'); // Return an error object
parse('{"name": "colin"}'); // Return {"name": "colin"}
parseLodash('{"name": "colin"}'); // Return {"name": "colin"}
@Way
Way / post-merge.sh
Created July 26, 2015 13:31
Git hook "post-merge" to check and run npm, bower & composer on changed files
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
@Way
Way / rename-files
Last active August 29, 2015 14:08
Batch rename files to lowercase
# Found it here: http://superuser.com/questions/65302/is-there-a-way-to-batch-rename-files-to-lowercase
# Go to the directory and run the following command:
for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")
# Recursive version (added /r to dir):
for /f "Tokens=*" %f in ('dir /l/b/a-d/r') do (rename "%f" "%f")
@Way
Way / ghostwriter.js
Created October 6, 2014 22:09
Ghost Keyboard Writer
/**
* Ghost Keyboard Writer
* Let the keyboard write for yourself.
* Simply use the following command:
* START()
*
* To control the speed of writing, use the first parameter
* to define the delay between to characters in milliseconds.
* START(50)
*/
@Way
Way / README.md
Last active August 29, 2015 14:06 — forked from JoelBesada/README.md
Backtick "gmail" Command

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.