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
// ES7, async/await | |
function sleep(ms = 0) { | |
return new Promise(r => setTimeout(r, ms)); | |
} | |
(async () => { | |
console.log('a'); | |
await sleep(1000); | |
console.log('b'); | |
})() |
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
{ | |
"editor.fontFamily": "Operator Mono, Menlo, Monaco, 'Courier New', monospace", | |
"editor.fontSize": 13, | |
"window.zoomLevel": 0, | |
"editor.tabSize": 2, | |
"editor.fontLigatures": true, | |
"workbench.colorTheme": "Default Light+", | |
"editor.cursorBlinking": "solid", | |
"editor.minimap.enabled": false, | |
"editor.tokenColorCustomizations": { |
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
Raven.config(dsn, { | |
dataCallback(data) { | |
const normalize = filename => filename.split('/www/', 2)[1] | |
data.exception.values[0].stacktrace.frames.forEach(frame => { | |
frame.filename = normalize(frame.filename) | |
}) | |
data.culprit = data.exception.values[0].stacktrace.frames[0].filename |
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
<?php | |
use Illuminate\Database\Eloquent\Collection; | |
class BaseCollection extends Collection { | |
public function sortByOrder($order, $delimeter = ',') | |
{ | |
$order = is_array($order) ? $order : explode($delimeter, $order); | |
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
<?php | |
// this is the base controller which parses output to HTML/CSV/JSON depending on the format in the URL | |
use Illuminate\Support\Collection; | |
class FormatController extends Controller { | |
protected $fileName = 'export'; | |
protected $view = 'reports.output'; |
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
var xhr = new XMLHttpRequest(); | |
xhr.upload.addEventListener('progress', function(e) { | |
var percent = parseInt(e.loaded / e.total * 100, 10)+'%'; | |
console.log('progress', percent); | |
}, false); | |
xhr.onreadystatechange = function(e) { | |
if (xhr.readyState === 4 && xhr.status === 200) { | |
console.log('done!'); |
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
machine: | |
php: | |
version: 5.6.5 | |
dependencies: | |
cache_directories: | |
- vendor | |
- node_modules | |
pre: | |
- sudo pip install awscli |
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
// decorate the class, composition | |
function waitFor(prop) { | |
return ChildComponent => class extends Component { | |
render() { | |
return this.props[prop] ? <ChildComponent {...this.props} /> : null | |
} | |
} | |
} | |
// decorate the class, inheritance |
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 { execSync } = require('child_process') | |
const SENTRY_URL = 'https://app.getsentry.com/api/0/projects/radweb/inventorybase-go/releases' | |
const SENTRY_API_KEY = process.env.SENTRY_API_KEY | |
const VERSION = process.env.CIRCLE_SHA1 | |
function createSentryRelease() { | |
execSync(`curl ${SENTRY_URL} -u ${SENTRY_API_KEY} -X POST -d '${JSON.stringify({ version: VERSION })}' -H 'Content-Type: application-json'`) | |
} | |
function uploadToSentry(file, filename) { |
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
// would've been awesome if `speechSynthesis.speak` returned a promise which resolves on finish.. :( | |
const sleep = ms => new Promise(r => setTimeout(r, ms)) | |
async function go(msg) { | |
for (let v of speechSynthesis.getVoices()) { | |
speechSynthesis.speak(u = new SpeechSynthesisUtterance(msg), u.voice = v, u) | |
await sleep(1000) | |
} | |
} |