Skip to content

Instantly share code, notes, and snippets.

View bradvogel's full-sized avatar

Brad Vogel bradvogel

View GitHub Profile
@bradvogel
bradvogel / bookmark.js
Created March 19, 2020 13:56
Browser bookmark to open a jira in a new tab
javascript:let dest=prompt("Issue ID?");if (dest) window.open("https://[subdomain].atlassian.net/browse/" + dest, '_blank');
// or
javascript:const tab = window.open('about:blank', '_blank');tab.document.write("<script>window.location.href=`https://[subdomain].atlassian.net/browse/${window.prompt('number')}`</script>");tab.document.close();
@bradvogel
bradvogel / consumer.js
Created December 13, 2016 18:12
bull
var Bull = require('bull');
var queue = new Bull('contacts', 6383, 'localhost');
var concurrency = process.argv[2] ? parseInt(process.argv[2]) : 1;
function handler(job, done) {
console.log('processing job', job.jobId);
setTimeout(() => {
done();
@bradvogel
bradvogel / script.js
Created October 30, 2016 03:28
mongo querying range of search results
db.sequences.aggregate([
{
"$match": {
$text: { $search: 'test' }
}
},
{
$sort: {
score: { $meta: "textScore" },
_id: -1
/**
* This script will automatically sync all updates from one database to another. It is meant to be run while
* syncing the database using mongodump and mongorestore.
*
* Example:
* node livesync.js mongodb://<user>:<pass>@dbhost.com:10645/app-production \
* mongodb://<user>:<pass>@dbhost.com:10499/local?authSource=app-production \
* app-production \
* mongodb://<user>:<pass>@newdbhost.com/app-prod
*/
@bradvogel
bradvogel / lacona-basic-parsing-es5.js
Last active April 8, 2018 01:54
Lacona (natural language parser) basic example using ES5
var lacona = require('lacona');
var laconaPhrase = require('lacona-phrase');
var datetime = require('lacona-phrase-datetime');
var string = require('lacona-phrase-string');
var parser = new lacona.Parser({
grammar: laconaPhrase.createElement('sequence', {
children: [
laconaPhrase.createElement('literal', {
text: 'remind me to '
}),
/**
*
*/
$(window).on('message', function(e) {
var data = e.originalEvent.data;
if (data.method !== 'createIFrame') return;
var proxyUrl = chrome.runtime.getURL('/src/iframeProxy/proxy.html');
/**
* Run this by downloading this script to your computer, then:
* 1. $ npm install express
* 2. $ node thisscript.js
* 3. Open localhost:8030/nocache and then localhost:8030/nostore
*/
var app = require('express')();
app.get('/nocache', function(req, res) {
<script async src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
<script async src="https://d14s452uta6ylv.cloudfront.net/63f05514e61391320f7915439f20f128a86c2ac5/lib/chrono.min.js"></script>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.2/handlebars.runtime.min.js"></script>
<!-- Our application Javascript -->
<script src="https://d14s452uta6ylv.cloudfront.net/63f05514e61391320f7915439f20f128a86c2ac5/build.js"></script>
var timing = window.performance.timing;
keen.addEvent('page load time to first byte', {
ttfb: timing.responseStart - timing.connectEnd
});