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
async function track (msg) { | |
return Promise.resolve(foo) // intentially triggering ReferenceError for undefined `foo` | |
} | |
async function process (msg, done) { | |
try { | |
const res = await track(msg) | |
return done(null, res) | |
} catch (e) { |
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
async function track (msg) { | |
return Promise.resolve(foo) // intentially triggering ReferenceError for undefined `foo` | |
} | |
function process (msg, done) { | |
try { | |
track(msg).then(res => done(null, reqs)).catch(err => done(err, reqs)) | |
} catch (e) { | |
err.code = 'INTERNAL' |
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
import analytics | |
import uuid | |
import random as r | |
import time | |
import fixtures | |
from faker import Faker | |
fake = Faker() | |
analytics.write_key = "CaobGxGZFxAA2UEwfgk8z9OaImSYkPJo" | |
user_agent_list = ['Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FSL 7.0.6.01001)','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FSL 7.0.7.01001)','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FSL 7.0.5.01003)','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0','Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8','Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0','Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)','Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/201 |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
const PROMPT = "go>> " |
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 test = '{[()]}'; | |
function balancedParens(str) { | |
var parens = { | |
'{': '}', | |
'[': ']', | |
'(': ')' | |
} | |
var stack = [] | |
for (var i = 0; i < str.length; i++) { |
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
a = [3, 4, 6, 10, 11, 15] | |
b = [1, 5, 8, 12, 14, 19] | |
# plan is to create a pipeline and solve using recursion | |
# going to crunch through each array, testing at each iteration to see | |
# which value at index 0 of either array is lower, removing that from the array | |
# and appending that value to the result array. | |
# | |
# Finally, check to see if either array is empty | |
# If so, just going to append the remaining array to the end of the result |
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
import express from 'express' | |
import Analytics from 'analytics-node' | |
import { stringify } from 'qs' | |
const app = express() | |
const analytics = new Analytics('write-key') | |
app.use((req, res, next) => { | |
const { query, cookies, url, path, ip, host } = req |
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
<script type="text/javascript"> | |
function setCookie(name, value, days){ | |
var date = new Date(); | |
date.setTime(date.getTime() + (days*24*60*60*1000)); | |
var expires = "; expires=" + date.toGMTString(); | |
document.cookie = name + "=" + value + expires + ";path=/"; | |
} | |
function getParam(p){ | |
var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search); | |
return match && decodeURIComponent(match[1].replace(/\+/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
int binary_search(int value, int values[], int min, int max) | |
{ | |
if (max < min) | |
{ | |
return -1; | |
} | |
int midpoint = (min + max) / 2; | |
if (values[midpoint] < value) | |
{ | |
return binary_search(value, values, midpoint + 1, max); |
NewerOlder