Skip to content

Instantly share code, notes, and snippets.

View gamesbrainiac's full-sized avatar
💭
Gone Fishing.

Nafiul Islam gamesbrainiac

💭
Gone Fishing.
View GitHub Profile
@gamesbrainiac
gamesbrainiac / fillout_ascii.rs
Last active May 22, 2024 20:09
ASCII Art Generator Rust
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 {
@gamesbrainiac
gamesbrainiac / fillout_ascii.py
Created May 22, 2024 19:49
ASCII Art Generator
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.
@gamesbrainiac
gamesbrainiac / orders.py
Created August 12, 2020 17:37
Has all the orders that is required for the third episode of "What does this package do?"
orders = [
{
"_id": {"$oid": "5bd761dcae323e45a93cd0b5"},
"customer": {
"gender": "M",
"age": 40,
"email": "tel@hasusal.om",
"satisfaction": 4
},
"items": [
@gamesbrainiac
gamesbrainiac / orders.py
Created August 12, 2020 17:37
Has all the orders that is required for the third episode of "What does this package do?"
orders = [
{
"_id": {"$oid": "5bd761dcae323e45a93cd0b5"},
"customer": {
"gender": "M",
"age": 40,
"email": "tel@hasusal.om",
"satisfaction": 4
},
"items": [
@gamesbrainiac
gamesbrainiac / dicts.py
Created July 16, 2020 01:33
What does this package do? Episode 2: Enhanced Dictionaries
# 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',
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"
@gamesbrainiac
gamesbrainiac / graphql_01.py
Last active June 23, 2017 00:40
2017_06_22_graphql-in-the-python-world
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
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))
# 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)
@gamesbrainiac
gamesbrainiac / TestPony.py
Last active August 29, 2015 14:10
How to sort comments in Pony
# 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)