Skip to content

Instantly share code, notes, and snippets.

View jkantr's full-sized avatar

Jared Kantrowitz jkantr

  • The Witzend Group
  • Metro NY Area
View GitHub Profile
@jkantr
jkantr / .js
Last active January 5, 2018 17:46 — forked from hmpmarketing/memcached.js
const Promise = require('bluebird');
const memcache = require('./memcached.js');
const lifetime = 100 // i don't actually know what this is.. fill in the correct thing :p
Promise.try(() => {
return memcache.add('foo', 'bar', lifetime);
}).then(() => {
return memcache.get('foo');
}).then((foo) => {
@jkantr
jkantr / app.js
Last active December 8, 2017 19:35 — forked from nomoney4me/app.js
require('dotenv').config()
const Promise = require('bluebird')
const WmiClient = require('wmi-client')
// let's boiler plate this to use later in the #map
const promisifiedClient = opts => Promise.promisifyAll(new WmiClient(opts))
/* wmi queries functions */
async function getWMI(wmi) {
@jkantr
jkantr / parsefile.js
Last active November 30, 2017 22:13 — forked from enricopolanski/node
var fs = require("fs");
var path = require("path");
var cheerio = require("cheerio");
module.exports = (mypath) => {
var inputFile = fs.readFileSync(mypath, "utf8");
var $ = cheerio.load(inputFile, {xmlMode:true});
// defines the selector
@jkantr
jkantr / myDerps.js
Last active November 30, 2017 20:05 — forked from bobfrankly/myDerps.js
const shell = require('node-powershell');
let ps = new shell({
executionPolicy: 'Bypass',
noProfile: true
});
function psPing(thisIP) {
ps.addCommand('Test-Connection -quiet -count 1 ' + thisIP)
return ps.invoke()
import requestLanguage from 'express-request-language';
import models, { Locale, User, UrlManager } from './data/models';
app.use(async (res, req, next) => {
const locales = await Locale.findAll({}).then(locales => locales.map(loc => loc.locale));
//app.set('locales', locales);
req.locales = locales;
next();
const checkStatus = (response) => {
if (response.status >= 200 && response.status < 300) return response
const error = new Error(`Error ${response.status}: ${response.statusText}`)
error.response = response
throw error
}
const parseResponse = (response) => {
const authToken = response.headers.get(`Authorization`)
return response.json().then(json => ({ authToken, json }))