A Pen by Craig Palermo on CodePen.
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 { getName } from '../models/user'; | |
| jest.mock('../models/user', {} => ({ | |
| getName: jest.fn() | |
| })); | |
| test('if user model is mocked', () => { | |
| getName.mockReturnValue('bob') | |
| expect(getName()).toEqual('bob'); |
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 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) => { |
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
| """ | |
| Description: Import DOGnzb watchlist into CouchPotato | |
| Author: Craig Palermo | |
| Date: 1/14/2017 | |
| """ | |
| import argparse | |
| import json | |
| import logging | |
| import sys |
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
| ls /etc/apache2/sites-enabled/* | xargs cat | grep ServerName | uniq |
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
| <VirtualHost *:80> | |
| ServerAdmin me@mydomain.com | |
| ServerName dev.mydomain.com | |
| ProxyPreserveHost On | |
| # setup the proxy | |
| <Proxy *> | |
| Order allow,deny | |
| Allow from all | |
| </Proxy> |
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
| from datetime import datetime, timedelta | |
| from sets import Set | |
| import argparse | |
| import sys | |
| import os | |
| import time | |
| import shutil | |
| import re |
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
| var promiser = function (callback) { | |
| var promise = new Promise(function(resolve, reject){ | |
| console.log("Promise created"); | |
| window.setTimeout(function(){ | |
| resolve("Hello from Promise Land"); | |
| }, 3000); | |
| }); | |
| promise.then(function(){ | |
| callback(); |
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
| /* | |
| Credit to CSS-Tricks.com ~ https://css-tricks.com/copy-paste-the-web/ | |
| */ | |
| $('#ta').on("focus", function(e) { | |
| e.target.select(); | |
| $(e.target).one('mouseup', function(e) { | |
| e.preventDefault(); | |
| }); | |
| }); |
By consolidating HTML templates, CSS stylesheets, and JavaScript, we can greatly reduce the amount of time spent waiting for requests to retrieve external resources and make transitions between routes appear much smoother.
NewerOlder