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 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 _ = 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
# 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
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
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 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
#!/usr/bin/env python3 | |
import docker | |
client = docker.from_env() | |
for container in client.containers.list(): | |
print(container.image.tags[0]) | |
container.kill() | |
client.containers.list() |
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
#!/usr/bin/env python3 | |
import docker | |
client = docker.from_env() | |
kwargs = { | |
"image":'alpine:3.8', | |
"name": 'test', | |
"command": 'tail -f /dev/null', | |
"detach": True, |
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
docker run -d --name ouroboros \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
pyouroboros/ouroboros |