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
/*jshint esnext:true*/ | |
// see https://gitlab.com/help/web_hooks/web_hooks for full json posted by GitLab | |
const NOTIF_COLOR = '#6498CC'; | |
const refParser = (ref) => ref.replace(/^.*?([^\/]+)$/,'$1'); | |
class Script { | |
process_incoming_request({request}) { | |
try { | |
switch(request.headers['x-gitlab-event']){ | |
case 'Push Hook': |
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
/*jshint esnext:true*/ | |
const DESC_MAX_LENGTH = 140; | |
const JIRA_LOGO = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACRElEQVRYhbWXsUscQRTGf4iIyHHIISIWIsHisMgfkNIiBJFwiKQIkipVqpA/wEZEggSxEkmZwiKI5A84REKKkIMQrINYBQmHBDmEHJdNMW+42dk3d3O76wcDu2/e973vZvfN7EF+PAfaMjYL6AzFJFBRYh0gkdEBpryciuQVwjPgFugCu068CvQcAz1g2pnfEc6taOTGL6dIAjxw5nad+FsnvuhxrosYuPbElrz5Rc8Ucu9yfhcxsAncYZZ4fwTeO+HcUcILWgFqOXg1si9vFBrAXB7iEMySfYQZzGCeWxdoAq+Bh8BYjoJjwn0jWrYrqsOIbdIvUQLseTmPgHXgiYx1ibnYU3RuYpyfKMQ/mNWx+KzkfHHmZ4Tj55zGGNhQiAlw5OQ8VeYbzvxRQCNqUxoHLgMCa07eRyd+4sTXAtwrYCLGAJje1URugLrkVIHvMuyLVZccjfsitrhFMyD0k36bTtA/cOZkTuOckaOTFtA7IgEuSG9ONeBHILctWrnwGNO/mvA3zAk4LddaThfTpoXwKiBuVyL0yxPhloLtAUVCY7us4hb7IxQ/KLu4xWFE8cP7Kg6mld4PKH5BvoNrZBMfBphohKnFMAusyvU48ClgoA3M34eBUynwUu6ngK8BE1Gn3ihYccR79Jd5nuyXsx0rZRo498Q7mK8dMDudZuC8rOLLgQI7Ts5xIGe5DANbinCP9AfmEul/SnZslWHgTBFuKnna8a3lpRCzadSVWMiAj6GPIMbAX+/+H9BS8loyN4ibwX9j/jIXDkk+pgAAAABJRU5ErkJggg=='; | |
function stripDesc(str) { | |
return str.length > DESC_MAX_LENGTH ? str.slice( |
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
/* | |
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
const enchainProxifier = (target, promise = Promise.resolve()) => { | |
return new Proxy(target, { | |
get(target, propName) { | |
if (propName === 'promise') { | |
return promise; | |
} else if (propName === 'then') { | |
return (...args) => promise.then(...args); | |
} | |
if (target[propName] instanceof Function) { | |
return (...args) => enchainProxifier(target, promise.then(() => target[propName](...args))); |
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
//const tpl = makeTemplate('hello ${name}') | |
//const name = 'world'; | |
//tpl({name}); | |
const makeTemplate = (templateString) => { | |
return (templateData) => new Function(`{${Object.keys(templateData).join(',')}}`, 'return `' + templateString + '`')(templateData); | |
} |
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
function urlBase64ToUint8Array(base64String) { | |
const padding = '='.repeat((4 - base64String.length % 4) % 4); | |
const base64 = (base64String + padding) | |
.replace(/\-/g, '+') | |
.replace(/_/g, '/') | |
; | |
const rawData = window.atob(base64); | |
return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0))); | |
} |
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
-- deactivates all triggers and constraints | |
SET session_replication_role = replica; | |
-- restore triggers and constraints | |
SET session_replication_role = DEFAULT; | |
-- treat out-of-sync auto-increment sequence fields (use double quote arround table names to preserve uppercase letters) | |
SELECT pg_catalog.setval(pg_get_serial_sequence('"table_name"', 'id'), MAX(id)) FROM "table_name"; |