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 requests.adapters import HTTPAdapter | |
from requests.packages.urllib3.poolmanager import PoolManager | |
import ssl | |
class MyAdapter(HTTPAdapter): | |
"""Create http adapter that uses TLSv1 protocol.""" | |
def init_poolmanager(self, connections, maxsize, block=False): | |
self.poolmanager = PoolManager(num_pools=connections, |
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 pymongo import MongoClient | |
def get_db(): | |
try: | |
connection = MongoClient('localhost', 27019) | |
db = connection['db_name'] | |
collection = db['collection_name'] | |
return collection, connection | |
except Exception as e: |
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
""" | |
Expose methods to return new header dictionary. Supports only GET requests at the moment. | |
(Using phantomJS to throw them off. Maybe overkill. Could have used simple get request.) | |
""" | |
from selenium import webdriver | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
# edit desired capabilities | |
dcap = dict(DesiredCapabilities.PHANTOMJS) |
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
// @see http://stackoverflow.com/a/17944367/2317794 | |
var myApp = angular.module('myApp', []); | |
//Service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" | |
}; | |
}); |
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
<script src="https://code.highcharts.com/highcharts.js"></script> | |
<script src="https://code.highcharts.com/modules/exporting.js"></script> | |
<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div> |
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
{ | |
"env": { | |
"browser": true, // browser global variables. | |
"node": false, // Node.js global variables and Node.js-specific rules. | |
"worker": false, // web workers global variables. | |
"amd": false, // defines require() and define() as global variables as per the amd spec. | |
"mocha": false, // adds all of the Mocha testing global variables. | |
"jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0. | |
"phantomjs": false, // phantomjs global variables. | |
"jquery": true, // jquery global variables. |
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 PubSub = (function(){ | |
var mapping = {}; | |
return { | |
sub: function(eventName, callback, obj){ | |
callback = callback || _.noop; | |
if(!_.isFunction(callback)){ | |
console.error("callback is not a function"); | |
return; | |
} |
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 foo(){ | |
var callback = arguments[0] || function(){return "do nothing"}; | |
var options = arguments[1] || {}; | |
return [callback(), options.a || "no A", options.b || "no B", this]; | |
} | |
// try these out to understand how to use apply and what it means to write functions which might be called in this way | |
foo(null, {a:1, b:2}); | |
foo.apply("apples", [function(){return "do something"}, {a:1, b:2}]); |