This file contains 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_futures.sessions import FuturesSession | |
import os | |
urls = [] | |
num_workers = os.cpu_count() | |
session = FuturesSession(max_workers=num_workers) | |
while urls: | |
futures = [] | |
for i in range(num_workers): | |
if not urls: | |
break |
This file contains 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 Joi = require('joi'); | |
const schema = Joi.object().keys({ | |
birthyear: Joi.number().integer().min(1900).max(2013), | |
test: Joi.string(), | |
}).without('birthyear', 'test'); | |
let result = Joi.validate({ birthyear: 2013 }, schema); | |
// No error | |
result.error ? console.log(result.error) : console.log('schema valid\n'); |
This file contains 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 tinydb import TinyDB, Query | |
db = TinyDB('./test.db') | |
query = Query() | |
usersObj = [ | |
{ | |
'name':'jim', | |
'age': 24 | |
}, | |
{ |
This file contains 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
# Requires appropriate semi-colons | |
FILE_PATH=$(pwd); for i in $(ls $FILE_PATH/*.js); do sed -i 's|//.*||g; /\/\*/,/*\//d; /^\s*$/d;' $i && sed -i ':a;N;$!ba;s/\n/ /g; s/ //g' $i; done | |
# Before | |
# const os = require('os'); | |
# function num(num){ | |
# return 5 + num | |
# } | |
# // Sample Comment |
This file contains 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 _ = require('underscore'); | |
arr = [ | |
{ | |
car: "toyota", | |
color: "blue", | |
year: 2010, | |
trans: "auto", | |
warrantyEnd: "2013" | |
}, | |
{ |
This file contains 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 arr = [1, 2, 3, 4, 5]; | |
const newArr = []; | |
for(i = arr.length; i >=arr[0]; i--) { | |
newArr.push(i); | |
} | |
console.log(newArr); // [ 5, 4, 3, 2, 1 ] | |
/* with helper method (recommended) |
This file contains 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 { expect } = require('chai'); | |
const soapRequest = require('../index'); | |
const url = 'https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php'; | |
const urlFail = 'https://graphical.weather.gov:80/xml/SOAP_server/ndfdXMLserver.php'; | |
const headers = { | |
'user-agent': 'easy-soap-request-test', | |
'Content-Type': 'text/xml;charset=UTF-8', | |
SOAPAction: 'https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode', |
This file contains 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 soapRequest = require('easy-soap-request'); | |
const fs = require('fs'); | |
// example data | |
const url = 'https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php'; | |
const sampleHeaders = { | |
'user-agent': 'sampleTest', | |
'Content-Type': 'text/xml;charset=UTF-8', | |
'soapAction': 'https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode', | |
}; |
This file contains 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 axios = require('axios-https-proxy-fix'); | |
/** | |
* @author Caleb Lemoine | |
* @param {object} opts easy-soap-request options | |
* @param {string} opts.url endpoint URL | |
* @param {object} opts.headers HTTP headers, can be string or object | |
* @param {string} opts.xml SOAP envelope, can be read from file or passed as string | |
* @param {int} opts.timeout Milliseconds before timing out request | |
* @param {object} opts.proxy Object with proxy configuration |
This file contains 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
curl -H "soapAction: \"https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListCityNames\"" -H "Content-Type: text/xml;charset=UTF-8" --data @test.xml https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php |