Skip to content

Instantly share code, notes, and snippets.

View craigpalermo's full-sized avatar

Craig Palermo craigpalermo

View GitHub Profile
@craigpalermo
craigpalermo / dognzb_watchlist_to_couchpotato.py
Last active January 17, 2017 04:24
Import a DOGnzb watchlist into your CouchPotato wanted list
"""
Description: Import DOGnzb watchlist into CouchPotato
Author: Craig Palermo
Date: 1/14/2017
"""
import argparse
import json
import logging
import sys
@craigpalermo
craigpalermo / asyncAwaitHttpExample.js
Created April 22, 2017 23:00
This example demonstrates a function that makes an HTTP request and uses async/await to handle the function it calls that returns a promise.
const request = require('request');
// request doesn't return a Promise, so it needs to be wrapped in a function
// that does for this example
function getRequest(url, qs = {}) {
return new Promise((resolve) => {
request
.get({ url, qs })
.on('response', (response) => {
response.on('data', (data) => {
import { getName } from '../models/user';
jest.mock('../models/user', {} => ({
getName: jest.fn()
}));
test('if user model is mocked', () => {
getName.mockReturnValue('bob')
expect(getName()).toEqual('bob');