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
use image::{DynamicImage, GrayImage}; | |
use std::path::Path; | |
struct ASCIIArtGeneratorRust { | |
ascii_chars: Vec<char>, | |
} | |
impl ASCIIArtGeneratorRust { | |
/// Constructs a new ASCIIArtGenerator with a given set of ASCII characters. | |
fn new(ascii_chars: &str) -> Self { |
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 PIL import Image | |
class ASCIIArtGenerator: | |
def __init__(self, ascii_chars="@%#*+=-:. "): | |
""" | |
Initialize the generator with a string of ASCII characters. | |
The characters should range from darkest to lightest to visually represent different shades. | |
""" | |
# Initialize the ascii_chars attribute with the provided string of characters. |
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
orders = [ | |
{ | |
"_id": {"$oid": "5bd761dcae323e45a93cd0b5"}, | |
"customer": { | |
"gender": "M", | |
"age": 40, | |
"email": "[email protected]", | |
"satisfaction": 4 | |
}, | |
"items": [ |
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
orders = [ | |
{ | |
"_id": {"$oid": "5bd761dcae323e45a93cd0b5"}, | |
"customer": { | |
"gender": "M", | |
"age": 40, | |
"email": "[email protected]", | |
"satisfaction": 4 | |
}, | |
"items": [ |
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
# encoding=utf-8 | |
# What does this package do? Episode 2: collections.defaultdict | |
from collections import defaultdict | |
from pprint import pprint | |
events = [ | |
'mouse-click', | |
'mouse-hover', | |
'mouse-hover', |
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
swagger: "2.0" | |
info: | |
version: "1.0.0" | |
title: "Newsletter API" | |
license: | |
name: "Copyright Suitsupply BV" | |
host: "0.0.0.0:5000" | |
basePath: "/v1" | |
tags: | |
- name: "subscription" |
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 graphene # 1 | |
class Query(graphene.ObjectType): # 2 | |
hello = graphene.String(description='A typical hello world') # 3 | |
def resolve_hello(self, args, context, info): # 4 | |
return 'World' | |
schema = graphene.Schema(query=Query) # 5 |
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 heapq | |
class PriorityQueue(object): | |
def __init__(self): | |
self._queue = [] | |
self._index = 0 | |
def push(self, item, priority): | |
heapq.heappush(self._queue, (-priority, self._index, item)) |
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
# encoding=utf-8 | |
__author__ = "Quazi Nafiul Islam" | |
from bisect import * | |
from array import array | |
def find_le(a, x): | |
"""Find rightmost value less than or equal to x""" | |
i = bisect_right(a, x) |
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
# encoding=utf-8 | |
__author__ = "Quazi Nafiul Islam" | |
from pony import orm | |
# orm.sql_debug(True) | |
db = orm.Database() | |
db.bind('sqlite', 'todo_api.db', create_db=True) | |
NewerOlder