Skip to content

Instantly share code, notes, and snippets.

View firemanxbr's full-sized avatar

Marcelo Barbosa firemanxbr

View GitHub Profile
import time
from concurrent.futures import ProcessPoolExecutor
from concurrent.futures import ThreadPoolExecutor
def process_nodes1(node):
time.sleep(10)
return f'Primeira... {node["name"]}'
@firemanxbr
firemanxbr / gist:f0feba1353f5f5fcc42eb991c44bd02f
Created April 22, 2019 11:51
mirror words with 2 problems
import string
def reverse(sentence):
punctuation = set(string.punctuation)
words = []
for word in sentence.split():
words.append(word.rstrip(string.punctuation)[::-1])
if word[-1] in punctuation:
words[-1] = words[-1]+word[-1]
return ' '.join(words)
def rev(value):
x = value.split(' ')
rev = []
phrase = ''
for y in x:
#print(y)
size = len(y)
#print(size)
marcelo@MININT-8OQK3F7:/mnt/c/Users/mabarbo/Documents/repositories/infrastructure_utilities_se-ecommerce-playground$ python3 multitask.py
[SERIAL]...
Number: 100109100129100151, Prime: True, Time: 16.975686400000995
Number: 102598800232111471, Prime: True, Time: 14.709741100001338
Number: 113127131137139149, Prime: True, Time: 14.730483299999833
Number: 115578717622022981, Prime: True, Time: 15.281539700001304
Number: 198366630044195153, Prime: False, Time: 0.0361391000005824
[SERIAL] Total Time: 61.73540530000173
[THREADING]...
"""
Mock HTTP Server to use in tests
"""
import http.server
import threading
class HandleHTTPServer(http.server.HTTPServer):
"""
Main HTTPServer Class
"""
Mock HTTP Server to use in tests
"""
import http.server
import threading
class HandleHTTPServer(http.server.HTTPServer):
"""
Main HTTPServer Class
import threading
import http.server
class StoppableHTTPServer(http.server.HTTPServer):
def run(self):
try:
self.serve_forever()
except KeyboardInterrupt:
pass
@firemanxbr
firemanxbr / bot_sample.py
Created November 28, 2018 09:29
bot framework sample
import asyncio
from botbuilder.core import TurnContext, ConversationState, UserState, MemoryStorage
from botbuilder.schema import ActivityTypes
from adapter import ConsoleAdapter
adapter = ConsoleAdapter()
memory = MemoryStorage()
conversation_state = ConversationState(memory)
$ ansible-playbook -i "localhost," playbooks/setup.yml --extra-vars='{"hooks": ["/home/firemanxbr/GitHub/contra-env-setup/a.yml","/home/firemanxbr/GitHub/contra-env-setup/b.yml"
]}' -vvv
ansible-playbook 2.5.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/firemanxbr/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.15 (default, May 2 2018, 14:12:52) [GCC 8.0.1 20180324 (Red Hat 8.0.1-0.20)]Using /etc/ansible/ansible.cfg as config file
Parsed localhost, inventory source with host_list plugin
[firemanxbr@firemanxbr pipeline]$ git branch -a
master
* stage
remotes/origin/HEAD -> origin/master
remotes/origin/cbeer-CVP-11-results-to-datahub
remotes/origin/cbeer-dev-quotas
remotes/origin/cvp-63-jp
remotes/origin/cvp-63-nm
remotes/origin/master
remotes/origin/product_name_test