Skip to content

Instantly share code, notes, and snippets.

@delucis
delucis / readernaut.js
Created October 3, 2012 10:41 — forked from adampolselli/readernaut.js
Fork of Adam Polselli’s Readernaut widget script to work with new API
function parseResponse(data) {
var bookshelf = document.getElementById("books");
for (var i=0; i<4; i++) {
var cover = data.objects[i].book_edition.cover;
var title = data.objects[i].book_edition.book.title;
var author = data.objects[i].book_edition.book.authors[0].full_name;
var permalink = data.objects[i].book_edition.short_url;
var link = document.createElement("a");
#page #torso .member .composerav .audio li {
width: 48%;
margin-right: 4%;
margin-bottom: 1.5em;
float: left;
border-top: 1px solid rgba(0,0,0,0.1);
box-shadow: 0 .1em .75em -0.16em #999;
background: url("../img/absurdidad.png") center;
background-color: rgba(0,0,0,.01);
overflow: hidden;
@delucis
delucis / max-deletion-flags.js
Last active August 29, 2015 14:19
Handling loadbang() and notifydeleted() conflicts in Javascript in Max/MSP
// G L O B A L V A R I A B L E S
// set ID for module
var modulename = 'my-module';
// or if the [js] object is given a first argument, use that
if (jsarguments.length > 1) {
modulename = jsarguments[1];
}
// set unique ID for each module instance with random number generator
@delucis
delucis / GenerateDocumentation.sh
Last active March 13, 2016 04:04
Iterative bash script for Swift documentation generation in dn-m
#!/bin/bash
WORK_DIR=${PWD}
if [ $2 ]; then
SITE_DIR=$2
else
SITE_DIR=$WORK_DIR
fi
if [ $1 ]; then
FRAMEWORKS_DIR=$1
@delucis
delucis / rename-files.sh
Created May 11, 2017 19:15
Bash rename multiple files
# use string replacement to rename parts of all matching filenames
# based on http://stackoverflow.com/questions/7450818/rename-all-files-in-directory-from-filename-h-to-filename-half
for file in *.wav; do mv "$file" "${file/selection/substitution}"; done
#!/bin/bash
# Check all required CLIs are available
dependencies=( pdftoppm convert )
for dependency in "${dependencies[@]}"; do
command -v $dependency >/dev/null 2>&1 || { echo >&2 "‘$dependency’ command is required but it’s not installed. Aborting."; exit 1; }
done
# Create a directory to hold extracted images
if [ ! -d "images" ]; then
@delucis
delucis / copy-file-sha.sh
Created August 16, 2017 17:31
Copy a sha256 hash of a file to the clipboard
shasum -a 256 name-of-your-file | awk '{printf $1}' | pbcopy
@delucis
delucis / async-loop.js
Created November 13, 2017 15:31
Asynchronous, parallel loops ➰➰➰
// ES7 with async/await and Promise.all
async function loopIt(array) {
await Promise.all(array.map(async member => {
// asyncStuff() will be called in parallel for all array members
let result = await asyncStuff(member)
}))
}
@delucis
delucis / deleteScrobbles.js
Last active July 27, 2020 10:49
Programmatically delete scrobbles from a Last.fm library page
/**
* Delete all (or some of) the scrobbles on a Last.fm library page
* (e.g. https://www.last.fm/user/USERNAME/library)
*
* @param {Number} [count=0] Number of scrobbles on page to delete
* @param {Number} [start=0] Index to start deleting from
*
* @example
* // delete first 20 scrobbles on page
* deleteScrobbles(20)
@delucis
delucis / README.md
Last active April 21, 2022 12:24
Extending boardgame.io storage connectors

You can extend a boardgame.io storage adapter to add custom functionality.

This example wraps the original setState method to accomplish some other task when the game is over — in this case posting the game logs elsewhere via a hypothetical dumpEndOfGameLog function.

(The example uses the FlatFile storage class, but should work with any other boardgame.io storage class.)