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
reduce(lambda prev_el, el: ''.join(prev_el) + ' ' + ''.join(el), zip_longest(*[iter(str(a)[::-1])] * 3, fillvalue=''))[::-1] |
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
# Demonstrate Currying of composition of function | |
def change(b, c, d): | |
def a(x): | |
return b(c(d(x))) | |
return a | |
def kilometer2meter(dist): | |
""" Function that converts km to m. """ | |
return dist * 1000 | |
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
def map_many(iterable, *funcs): | |
if funcs: | |
return many_map(map(funcs[0], iterable), funcs[1:]) | |
return iterable |
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
stale_checkouts = filter( | |
lambda cr: not [ | |
pt for pt in payment_transactions | |
if pt['ac_transaction_id'] == cr['transaction_id'] | |
], | |
checkout_transactions, | |
) |
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
Exception happened during processing of request from ('127.0.0.1', 34818) | |
Traceback (most recent call last): | |
File "/usr/lib/python3.6/socketserver.py", line 651, in process_request_thread | |
self.finish_request(request, client_address) | |
File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request | |
self.RequestHandlerClass(request, client_address, self) | |
File "/home/dev/jo/refunite-tasks/venv/lib/python3.6/site-packages/chalice/local.py", line 532, in __init__ | |
self, request, client_address, server) # type: ignore | |
File "/usr/lib/python3.6/socketserver.py", line 721, in __init__ | |
self.handle() |
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
mapped_images: Iterator[Tuple[TaskImage, UserUploadedImage]] = \ | |
map_task_and_user_uploaded_images(task_images, user_uploaded_images) | |
overlayed_map_images: List[Tuple[TaskImage, OverlayedImage]] = [ | |
(task_image, user_uploaded_images.convert_to_overlayed_image(task_image),) | |
for task_image, user_uploaded_images in mapped_images | |
] | |
# -------------------------------------------------------------------------------- | |
# -------------------------------------------------------------------------------- |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
var get_value chan int | |
func send_value(x int) { |
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
import time | |
class CustomException(Exception): | |
pass | |
def retry(max_attempts=1, | |
should_retry=lambda _e: True, | |
retryable_exceptions=tuple(), |
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
package main | |
import ( | |
"fmt" | |
"context" | |
"cloud.google.com/go/bigquery" | |
) | |
type Item struct { |
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
func insertRows(client *bigquery.Client, datasetID, tableID string) error { | |
ctx := context.Background() | |
// [START bigquery_table_insert_rows] | |
u := client.Dataset(datasetID).Table(tableID).Uploader() | |
items := []*Item{ | |
// Item implements the ValueSaver interface. | |
{Name: "Phred Phlyntstone", Age: 32}, | |
{Name: "Wylma Phlyntstone", Age: 29}, | |
} | |
if err := u.Put(ctx, items); err != nil { |
NewerOlder