This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const notificationGrantedPromise = () => { | |
if (!('Notification' in window)) { | |
return Promise.reject(); | |
} | |
return (Notification.permission !== 'default') ? Promise.resolve(Notification.permission) : Notification.requestPermission(); | |
}; | |
const notify = (...args) => notificationGrantedPromise().then((permission) => permission === 'granted' ? new Notification(...args) : null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
EXAMPLE MESSAGE | |
!poll question? | |
option 1 | |
option 2 | |
*/ | |
class Script { | |
/** | |
* @params {object} request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* source: http://stackoverflow.com/a/37511463/646056 | |
*/ | |
function removeDiacritics(s) { | |
return s.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Confluence fancybox enhance navigation | |
// @version 0.0.1 | |
// @description add navigation through image previews | |
// @author Jonathan Gotti | |
// @match http://*/* | |
// @match https://*/* | |
// ==/UserScript== | |
// update match rules for your domain | |
(function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 failing | |
1) 2.3.3: Otherwise, if `x` is an object or function, 2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise` 2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)` `y` is a thenable for a thenable `y` is a thenable that tries to fulfill twice for an asynchronously-fulfilled custom thenable `then` calls `resolvePromise` synchronously via return from a fulfilled promise: | |
Error: timeout of 200ms exceeded | |
at null.<anonymous> (/tmp/D.js/node_modules/promises-aplus-tests/node_modules/mocha/lib/runnable.js:165:14) | |
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15) | |
2) 2.3.3: Otherwise, if `x` is an object or function, 2.3.3.3: If `then` is a function, call it with `x` as `this`, first argument `resolvePromise`, and second argument `rejectPromise` 2.3.3.3.1: If/when `resolvePromise` is called with value `y`, run `[[Resolve]](promise, y)` `y` is a thenable for a then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* return a selector to use with document.querySelector to retrieve given node | |
* @param {DOMElement} node | |
* @returns {string} | |
*/ | |
function getSelector(node){ | |
// check for node.id avoiding autogenerated ids by ignoring any ids containing numeric values | |
// and checking that the id is unique in the document. | |
if (node.id && node.id.match(/^\D+$/) && document.querySelectorAll(node.id).length === 1) { | |
return '#' + node.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# pre-commit git hook. | |
files=$(git diff --cached --name-only --diff-filter=ACMR -- \*.js **/*.js) | |
pass=true | |
errorJscs=0 | |
errorJshint=0 | |
if [ "$files" != "" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pgr="most" | |
tmpFile="/tmp/pager_$(uuidgen)" | |
cat - /dev/stdin > $tmpFile; | |
nblines=$(wc -l $tmpFile |awk '{print($1)}'); | |
if [ "$nblines" -gt "$(tput lines)" ]; then | |
$pgr $tmpFile | |
else | |
cat $tmpFile && echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get user step on command line or default to 1 | |
USERSTEP=${1:-1} | |
# get max and current values of brightness | |
MAX=`/usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-max-brightness` | |
CUR=`/usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness` | |
# define step and min to apply regarding the max value to have approximatively ten levels of settings | |
STEP=$(($MAX/10)) | |
MIN=$((STEP/2)) | |
# calc new user wanted value |