Skip to content

Instantly share code, notes, and snippets.

View hericah's full-sized avatar
🎯
Focusing

Heri hericah

🎯
Focusing
View GitHub Profile
@hericah
hericah / docker-shell.sh
Created June 7, 2022 03:16 — forked from Hypnosphi/docker-shell.sh
Run docker container, mount current working directory and get interactive shell
docker run -ti -v $(pwd):/tmp -w /tmp DOCKER_IMAGE /bin/bash
@Kludex
Kludex / main.py
Last active March 29, 2024 12:31
Run Gunicorn with Uvicorn workers in code
""" Snippet that demonstrates how to use Gunicorn with Uvicorn workers in code.
Feel free to run:
- `python main.py` - to use uvicorn.
- `ENV=prod python main.py` - to use gunicorn with uvicorn workers.
Reference: https://docs.gunicorn.org/en/stable/custom.html
"""

Github to Discord Webhook Tutorial

In this tutorial I'll show you how to create a Github webhook that will post updates from your Github account to a channel in Discord. The steps are simple so follow along!

Create a Webhook in a Discord Channel

First you need to create a webhook in a text channel. We're assuming you have both Manage Channel and Manage Webhooks permissions!

  • Go in a channel properties (Alternatively, Server Settings, Webhooks works too)
@timhughes
timhughes / fastapi_websocket_redis_pubsub.py
Last active April 29, 2024 08:00
FastAPI Websocket Bidirectional Redis PubSub
"""
Usage:
Make sure that redis is running on localhost (or adjust the url)
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html
pip install -u uvicorn
Install dependencies
@Hypnosphi
Hypnosphi / docker-shell.sh
Created November 29, 2019 17:53 — forked from falvarez/docker-shell.sh
Run docker container, mount current working directory and get interactive shell
docker run -ti -v $(pwd):/tmp -w /tmp DOCKER_IMAGE /bin/bash
@sdymj84
sdymj84 / serverless.yml
Created April 2, 2019 19:22
Serverless framework global secondary index example
service: apt-api
# Use the serverless-webpack plugin to transpile ES6
plugins:
- serverless-webpack
- serverless-offline
custom:
# Our stage is based on what is passed in when running serverless
# commands. Or fallsback to what we have set in the provider section.
@ivanbrennan
ivanbrennan / postgres-in-minikube.sh
Last active May 19, 2024 03:11
PostgreSQL in minikube
# create/update resources
kubectl --context=minikube apply -f ./postgres.yaml
# In order for the service to reach the statefulset, the following should
# be true:
# statefulset.spec.selector.matchLabels.app == service.spec.selector.app
# statefulset.spec.selector.matchLabels.role == service.spec.selector.role
# give the server some time to start up
# ...
@parrotmac
parrotmac / dbus-send-modem-command.sh
Created November 15, 2018 08:14
Send serial command to modem using ModemManager via DBus
#!/bin/sh
# Sends command 'ATI' to modem #3
# Get a list of modems by running `mmcli -L`
# Timeout is (probably) 2 seconds
# Also see https://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-method-org-freedesktop-ModemManager1-Modem.Command
dbus-send --system --dest=org.freedesktop.ModemManager1 --print-reply /org/freedesktop/ModemManager1/Modem/3 org.freedesktop.ModemManager1.Modem.Command string:'ATI' uint32:2000
@aursu
aursu / modem.py
Last active June 27, 2022 03:16
ModemManager interface via Python 3 (Dbus, Modems, SMS)
#!/usr/bin/python3
# script created for reading SMS messages from 3G modem connected to PC
# 1) it looks for modem
# 2) reads all SMS messages from modem
# 3) prints all found SMS messages to stdout only if total messages count
# greater than SMS_STORE_COUNT (default is 3)
# 4) save all but SMS_STORE_COUNT messages to txt files and
# delete them from modem
@bashtoni
bashtoni / gist:995c0683bb18fd19eaefdc296a9401d8
Created July 4, 2018 10:48
Find ARN for ACM certificate for a given domain name
aws acm us-east-1 list-certificates --query CertificateSummaryList[].[CertificateArn,DomainName] \
--output text | grep example.com | cut -f1