Skip to content

Instantly share code, notes, and snippets.

View rmehner's full-sized avatar
🤷‍♀️
¯\_(ツ)_/¯

Robin Mehner rmehner

🤷‍♀️
¯\_(ツ)_/¯
View GitHub Profile
@rmehner
rmehner / delete-databases.js
Last active April 4, 2024 09:18
Delete all indexedDB databases
// Credit to @steobrien from https://gist.github.com/rmehner/b9a41d9f659c9b1c3340#gistcomment-2940034
// for modern browsers, this works:
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
// for older browsers, have a look at previous revisions of this gist.
/**
* @flow
*/
'use strict';
/*
* Flow types for the Babylon AST.
*/
@rmehner
rmehner / install_pdftk.sh
Last active May 6, 2021 03:54
Install PDFTk without touching up the permissions
#!/usr/bin/env bash
# This is based on this excellent gist https://gist.github.com/jvenator/9672772a631c117da151
# Nothing of this is my original work, except that I made the download link an argument
# to this script, so it installs on OSX 10.11
#
# Thank you jvenator & sethetter
set -e
error() { info "$1"; exit 1; }
@rmehner
rmehner / dexie-unique-compound-indizes.js
Last active March 3, 2020 18:46
Using unique compound indizes with Dexie.js
const db = new Dexie('friends')
db.version(1).stores({
friends: '++id,&[name+age]',
})
async function main() {
await db.friends.add({ name: 'Robin', age: 1337 })
// this will fail with:
// ConstraintError: A mutation operation in the transaction failed because a constraint was not satisfied.
await db.friends.add({ name: 'Robin', age: 1337 })
diff --git "a/test/fixture/r\303\266ck/d\303\266ts" "b/test/fixture/r\303\266ck/d\303\266ts"
new file mode 100644
index 0000000..e69de29
diff --git a/test/index.js b/test/index.js
index 22efd0d..fd749ee 100644
--- a/test/index.js
+++ b/test/index.js
@@ -27,11 +27,16 @@ function testSpecialChars() {
assert.equal(trueCasePathSync('test/fixture/F[U&N%K)Y'), path.join(__dirname, 'fixture/f[u&n%k)y'), 'works with file names w/ special chars')
}
@rmehner
rmehner / remove-android-sdk.sh
Last active March 1, 2017 19:01
Remove everything related to Android for a clean start (OHAI cordova)
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm -Rf ~/Library/Preferences/com.google.android.*
rm -Rf ~/Library/Preferences/com.android.*
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
rm -Rf ~/.AndroidStudio*
rm -Rf ~/AndroidStudioProjects
rm -Rf ~/.gradle
<?php
#### configuration ####
$email = 'YOUR_EMAIL_ADDRESS';
$token = 'YOUR_API_TOKEN';
$hostName = 'all'; // use 'all' if you want to update all hosts
#### cURL request below ####
$json_data = json_encode(array(
#!/usr/bin/env bash
set -e
info() { echo "$0: $1"; }
skip() { info "${1}. Skipping build."; exit 0; }
[[ "$TRAVIS_PULL_REQUEST" == "false" ]] || {
skip "This build was triggered by a pull request"
}
@rmehner
rmehner / fly_little_drone_fly.js
Created July 9, 2013 14:41
Sample drone script, just to show how easy it is
/**
* Play around with the numbers and the method names!
*
* For example: use counterClockwise and see what happens
*/
var arDrone = require('ar-drone');
var client = arDrone.createClient();
client.takeoff();
@rmehner
rmehner / to_query_string.js
Created May 1, 2013 16:50
Just a tiny helper function to get the query string out of an object (one level deep)
// note: this does not work for nested objects
var toQueryString = function(obj) {
return Object.keys(obj).map(function(key) {
return key + '=' + obj[key];
}).join('&');
};
toQueryString({}); // returns ''
toQueryString({foo: 'bar'}); // returns 'foo=bar'
toQueryString({billable: true, locked: false}); // returns 'billable=true&locked=false'