Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Vey Way

View GitHub Profile
@Way
Way / fetch-urls.js
Created Apr 20, 2020
Fetch and wait for multiple requests using async, await, and Promise.all
View fetch-urls.js
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 Mar 20, 2018
Disconnect apps where you used facebook to login #deleteFacebook
View fb-remove-apps-script.js
// 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 Aug 9, 2015
Error handling for JSON.parse with lodash
View parseLodash.js
// 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 Jul 26, 2015
Git hook "post-merge" to check and run npm, bower & composer on changed files
View post-merge.sh
#!/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 Aug 29, 2015
Batch rename files to lowercase
View rename-files
# 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 Oct 6, 2014
Ghost Keyboard Writer
View ghostwriter.js
/**
* 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 Aug 29, 2015 — forked from JoelBesada/README.md
Backtick "gmail" Command
View README.md

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.
You can’t perform that action at this time.