This file contains hidden or 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 setChildTextNode(elementId, text) { | |
document.getElementById(elementId).innerText = text; | |
} | |
// Tests the roundtrip time of sendRequest(). | |
function testRequest() { | |
setChildTextNode("resultsRequest", "running..."); | |
chrome.tabs.query({active: true, currentWindow: true}, tabs => { | |
const start = new Date().getTime(); | |
chrome.tabs.sendMessage(tabs[0].id, {counter: 1}, function handler(response) { | |
console.log(response); |
This file contains hidden or 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 chain = require("connect-chain"); | |
function paramMiddleware(param) { | |
return chain(namedMiddleware, (req, res, next) => { | |
// do something with param | |
next(err); | |
}); | |
} |
This file contains hidden or 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 strict"; | |
const Company = { | |
org: "Mobiquity", | |
employees: [{ | |
title: "Vice President", | |
employees: [ | |
{ | |
title: "Sales Lead", | |
employees: [{title: "Salesman"}], |
This file contains hidden or 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 strict'; | |
const Promise = require("bluebird"); | |
const prompt = Promise.promisifyAll(require("prompt")); | |
const inquirer = Promise.promisifyAll(require("inquirer")); | |
const inquirerp = require("inquirer-promise"); | |
const co = require("co"); | |
prompt.start(); | |
co(function* () { |
This file contains hidden or 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
extern crate hyper; | |
use hyper::Client; | |
use hyper::header::ContentLength; | |
const KEY: &'static str = "52633f4973cf845e55b18c8e22ab08d5"; | |
const SEARCH_HOST: &'static str = "http://www.gainesvillemls.com"; | |
fn main() { | |
let client = Client::new(); |
This file contains hidden or 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
describe('MainCtrl', () => { | |
let $controller; | |
beforeEach(inject(_$controller_ => { | |
$controller = _$controller_; | |
})); | |
function createCtrl() { | |
return $controller('MainCtrl'); | |
} |
This file contains hidden or 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
module.exports = { | |
entry: "./src/index.js", | |
output: { | |
path: __dirname + "/lib", | |
filename: "index.js", | |
}, | |
preLoaders: [{ | |
test: /\.js$/, | |
loader: 'babel', | |
query: { |
This file contains hidden or 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 fs = require("fs"); | |
const JSONStream = require("JSONStream"); | |
const AWS = require("aws-sdk"); | |
const csd = new AWS.CloudSearchDomain({endpoint: process.env.CSD_ENDPOINT, region: "us-east-1"}); | |
const writeFile = fs.createWriteStream("big.json"); | |
// const stringifier = JSONStream.stringify("[", ",", "]"); | |
const stringifier = JSONStream.stringify(); | |
stringifier.pipe(writeFile); |
This file contains hidden or 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 fs = require("fs"); | |
const JSONStream = require("JSONStream"); | |
const parser = JSONStream.parse('*'); | |
const stream = fs.createReadStream("./bl"); | |
stream.pipe(parser); | |
parser.on("data", data => { | |
let len = Buffer.byteLength(data.result); | |
if (len > 500000) { |
This file contains hidden or 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 delay from "timeout-as-promise" | |
(async () => { | |
let actions = (new Array(50)).fill(0).map(() => Math.random() * (1000 - 500) + 500); | |
let promises = []; | |
try { | |
actions.forEach(time => promises.push( | |
async () => { | |
try { |