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
echo -n "0000:00:14.0" | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind && echo -n "0000:00:14.0" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind |
- NOTE: I had to reboot after doing this to eliminate display artifacts.
- Also, the dock doesn't appear to support using both of the displayport ports simultaneously :'(
- And MST (https://en.wikipedia.org/wiki/DisplayPort#Multi-Stream_Transport_(MST) ) doesn't seem to work on this dock, so you can't daisy chain monitors.
- download driver from http://www.displaylink.com/downloads/ubuntu
- unpack
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
def binarytree(value): | |
return Node(value) | |
class Node(object): | |
def __init__(self, value): | |
self.__value = value | |
self.__left_node = None | |
self.__right_node = None |
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
def crop_image_borders(image_path): | |
image = Image.open(image_path) | |
image.load() | |
ndarray_image = np.asarray(image) | |
ndarray_image_mask = ndarray_image.max(axis=2) | |
non_empty_columns = np.where(ndarray_image_mask.max(axis=0) > 0)[0] | |
non_empty_rows = np.where(ndarray_image_mask.max(axis=1) > 0)[0] | |
image_bbox = (min(non_empty_rows), max(non_empty_rows), | |
min(non_empty_columns), max(non_empty_columns)) | |
cropped_ndarray_image = ndarray_image[image_bbox[0]:image_bbox[1] + 1, |
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
def merge_sort(ar, start, end): | |
qtd = end - start | |
if qtd > 1: | |
mid = int((start + end) / 2) | |
merge_sort(ar, start, mid) | |
merge_sort(ar, mid, end) | |
intercalate(ar, start, mid, end) | |
return ar | |
def intercalate(ar, start, mid, end): |
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
app = Celery('first_app', broker='redis://redis:6379/2') |
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
validate_user(user) # First validate user, then jump to next line | |
save_db_user(user) # First save_db_user, them jump to next line | |
start_to_send_confirmation_email(user) # We don't want to wait the email be sent to jump to next line, here we should develop some async stuff | |
return user |
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
app = Celery('first_app', broker='redis://localhost/2') | |
# New code below | |
app.conf.task_routes = { | |
'celery_stuff.tasks.serve_a_beer': {'queue': 'beer'}, | |
'celery_stuff.tasks.serve_a_coffee': {'queue': 'coffee'} | |
} |
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 celery_stuff.tasks import serve_a_beer, serve_a_coffee # Importing the task | |
def start_serve_a_beer(): | |
""" Starts the execution of a celery task with the delay method. | |
the delay method doesn't wait the task execution be finished. | |
""" | |
serve_a_beer.apply_async(('weiss', '500ml')) | |
print('This will be executed before the serve_a_beer task be finished') |