Skip to content

Instantly share code, notes, and snippets.

View dvdblk's full-sized avatar
😹
delulu

David Alex Bielik dvdblk

😹
delulu
View GitHub Profile
@nkhitrov
nkhitrov / structlog_fastapi.py
Created March 16, 2023 00:04
Structlog FastAPI example
"""
Structlog example configuration with FastAPI.
Features:
- async bound logger
- contextvars to log request-id and other meta data
- custom format for default logging loggers and structlog loggers
"""
import asyncio
import logging
@izxxr
izxxr / README.MD
Last active July 14, 2024 12:59
Discord.py Webhook Guide (Both async and sync).

⚠️ Notice

This guide is for discord.py 1.7 version. In upcoming v2.0, Webhooks were greatly overhauled and in fact simplified a lot. They no longer require adapters. Usage of webhooks is now quite straight forward. As such, this guide is now outdated and should not be followed.

Furthermore, this guide is focused on discord.py. No support for forks are covered in this guide.

Basic Webhooks Example using Discord.py (Rewrite)

Webhooks are a great way to send messages to Discord without having a bot account. You just need a webhook URL and just do a POST request on that URL and the message will be sent to discord.

Webhooks can also be used if your bot has to send messages to a channel a lot. For example, If your bot has event logging so everytime having to fetch channel and sending can be slow so you can use some webhook magic.

@egocarib
egocarib / gist:ea022799cca8a102d14c54a22c45efe0
Created October 22, 2020 01:50
pillow transparent gif creation workaround
# This code adapted from https://github.com/python-pillow/Pillow/issues/4644 to resolve an issue
# described in https://github.com/python-pillow/Pillow/issues/4640
#
# There is a known issue with the Pillow library that messes up GIF transparency by replacing the
# transparent pixels with black pixels (among other issues) when the GIF is saved using PIL.Image.save().
# This code works around the issue and allows us to properly generate transparent GIFs.
from typing import Tuple, List, Union
from collections import defaultdict
from random import randrange
# # # # # # # # # #
# USAGE:
#
# $accelUri = ''
# . '/' . 'internal_google_drive'
# . '/' . $google_drive_file_id
# . '/' . $filename
# . '/' . $google_drive_access_token;
# http_response_code(204);
# header('X-Accel-Redirect: ' . rawurlencode($accelUri));
@dayitv89
dayitv89 / 1_run_on_terminal
Last active June 26, 2024 08:26
SSL Pinning: Get public certificate + public key + public key hash using one script
$ ./get_cer_key_keyhash.sh graph.facebook.com
# it will output three files as
1. graph.facebook.com_keyhash.txt
2. graph.facebook.com.cer
3. graph.facebook.com.key
@Tommyfoxy2
Tommyfoxy2 / Push to Webhooks.md
Last active May 11, 2024 21:51 — forked from jagrosh/Github Webhook Tutorial.md
Simple Zapier Push to Discord webhook(s)

This tutorial is based on a realworld example


1) Initial Setup

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send content to

  2. In the settings for that channel, Click the Webhooks tab and create a new webhook. Webhook

@kirsteins
kirsteins / Array -> UnsafeMutablePointer -> Array
Last active June 16, 2024 09:42
Array -> UnsafeMutablePointer -> Array
var initalArray = [1, 2, 3]
let pointer: UnsafeMutablePointer<Int> = UnsafeMutablePointer(initalArray)
let arrary = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count))
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active September 15, 2024 10:33
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: