Skip to content

Instantly share code, notes, and snippets.

View devxpy's full-sized avatar

Dev Aggarwal devxpy

View GitHub Profile
@devxpy
devxpy / async_vs_threads.py
Last active July 14, 2020 22:05
Python asyncio vs ThreadPoolExecutor - inconsistent results for a purely I/O based task
"""
Instructions -
pip install httpx ipython
ipython -i async_vs_threads.py
%timeit asyncio.run(test_threads())
%timeit asyncio.run(test_async())
"""
@devxpy
devxpy / gist:eb0ed8c45cdfe61ca2bb99c98d11ab85
Created July 13, 2020 17:15
Poorna swaraj - by openai gpt3
Sentiments of a broken nation
Separated by religions and the hesitation
Vote banks, industries and corporations
Filthy pockets of the rich and famous
At the cost of poverty and desperation
Facing death and struggling daily
Without having a definite solution
Death and problems has no religion
Respect your neighbour from another nation
Fill the hearts with humanity
void main() {
List<int> x = createList();
}
List<int> createList() {
return ["1", "2", "3", "4", "5"];
}
void main() {
List<int> x = createList();
}
createList() {
return ["1", "2", "3", "4", "5"];
}
#
# Adapted from https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html#capture-video-from-camera
#
import numpy as np
import cv2
caps = [cv2.VideoCapture(i) for i in range(2)] # open 2 camera feeds
while(True):
var start = DateTime.now()
var db = await appSync.getCacheDatabase();
var pages = appSync.paginate(
...,
priority: CachePriority.cache, // Try cache first, then network
cache: db,
);
@devxpy
devxpy / djang_async_crud.py
Last active April 26, 2020 11:49
Django Async CRUD - Basic CRUD operations with Django ORM in an async context
import typing
from django.db import models
from channels.db import database_sync_to_async
M = typing.TypeVar("M", bound=models.Model)
class AsyncCrud:
#
# 🙏 to prior art: http://puzzlemusa.com/2018/05/14/learning-rate-finder-using-keras/
#
# Example:
# finder = find_lr(model, 1e-10, 1e-2)
# finder.plot()
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
from bokeh.models import HoverTool
@devxpy
devxpy / main.py
Last active December 24, 2019 08:02
# Generates 4 sets of images
# - original images
# - images with rotation
# - images with horizontal flip
# - images with vertical flip
train_gen = PersonDataGenerator(
train_df,
batch_size=32,
aug_list=[
ImageDataGenerator(rotation_range=45),
[ +29 ms] executing: [/Users/dev/Tools/flutter/] git log -n 1 --pretty=format:%H
[ +48 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[ ] 68587a0916366e9512a78df22c44163d041dd5f3
[ ] executing: [/Users/dev/Tools/flutter/] git describe --match v*.*.* --first-parent --long --tags
[ +12 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[ ] v1.9.1+hotfix.6-0-g68587a091
[ +9 ms] executing: [/Users/dev/Tools/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +14 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [/Users/dev/Tools/flutter/] git ls-remote --get-url origin