Skip to content

Instantly share code, notes, and snippets.

View delijati's full-sized avatar

Josip Delić delijati

  • Potsdam (Berlin)
View GitHub Profile

Moved to repo: /quenhus/uBlock-Origin-dev-filter

In order to keep filters up to date, please use this repo.

@lukicdarkoo
lukicdarkoo / arraycuckoo.c
Created November 24, 2020 09:39
Python Buffer Protocol Example
#include <Python.h>
typedef struct {
PyObject_HEAD char *arr;
int len;
} ArrayCuckoo;
static int ArrayCuckoo_init(ArrayCuckoo *self, PyObject *args, PyObject *kwds) {
self->len = 2;
self->arr = (char *)malloc(self->len * sizeof(char));
#!/bin/bash
source /home/project/myenv/bin/activate
cd /home/project/server
PID=$(ps aux | grep 'uvicorn myapp:app' | grep -v grep | awk {'print $2'} | xargs)
if [ "$PID" != "" ]
then
kill -9 $PID
sleep 2
echo "" > nohup.out
echo "Restarting FastAPI server"

Links to scrape data with pre filters

https://www.amazon.in/s?k=books&s=price-asc-rank	# low to high
https://www.amazon.in/s?k=books&s=price-desc-rank	# high to low
https://www.amazon.in/s?k=books&s=relevanceblender	# featured
https://www.amazon.in/s?k=books&s=review-rank		# Average customer review
https://www.amazon.in/s?k=books&s=date-desc-rank	# Newest Arrival

Version 2

@mauler
mauler / structlog_render_level_in_uppercase.py
Created January 20, 2020 15:47
Renders log entry level in uppercase when using structlog library
def _add_log_level_upper(logger, method_name, event_dict):
if method_name == "warn":
method_name = "warning"
event_dict["level"] = method_name.upper()
return event_dict
level_styles = structlog.dev.ConsoleRenderer.get_default_level_styles()
for k, v in list(level_styles.items()):
level_styles[k.upper()] = v
@dmontagu
dmontagu / fastapi_cbv.py
Last active March 25, 2024 11:00
FastAPI CBV
import inspect
from typing import Any, Callable, List, Type, TypeVar, Union, get_type_hints
from fastapi import APIRouter, Depends
from pydantic.typing import is_classvar
from starlette.routing import Route, WebSocketRoute
T = TypeVar("T")
CBV_CLASS_KEY = "__cbv_class__"
@bgdnlp
bgdnlp / cognito-test.py
Last active June 30, 2023 20:37
Sign up and log in to Cognito, check tokens, then call an API. Details: https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
#!/usr/bin/env python3
# Demonstrates the use of Python to work with Cognito.
# Create a new a user, log in, check tokens and call an API.
# The purpose was to learn about Cognito. Security has been
# circumvented in the interest of keeping it simple.
# Notably, the authentication procedure uses the most insecure
# method. This code is not intended for use in production.
#
# https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
@mypy-play
mypy-play / main.py
Created March 25, 2019 09:52
Shared via mypy Playground
from typing import Iterator
def fib(n: int) -> Iterator[int]:
a, b = 0, 1
while a < n:
yield a
a, b = b, a + b
@0xpizza
0xpizza / async_tcp_scan.py
Last active November 20, 2021 15:25
TCP Network scanner using asyncio for Python 3.7
#!/usr/bin/python3.7
import asyncio
import ipaddress
import re
import sys
MAX_NUMBER_WORKERS = 200
@mivade
mivade / aiowatch.py
Created October 26, 2018 17:00
Using watchdog with asyncio
import asyncio
from pathlib import Path
from typing import Optional
from watchdog.events import FileSystemEvent, FileSystemEventHandler
from watchdog.observers import Observer
class _EventHandler(FileSystemEventHandler):
def __init__(self, queue: asyncio.Queue, loop: asyncio.BaseEventLoop,