Skip to content

Instantly share code, notes, and snippets.

View dorukgezici's full-sized avatar

Doruk Gezici dorukgezici

View GitHub Profile
@dorukgezici
dorukgezici / middleware.py
Last active August 4, 2023 13:20
ASGI middleware for Slack signature verification on FastAPI - Starlette
import os
from asyncer import asyncify
from fastapi import HTTPException, Request
from slack_sdk.signature import SignatureVerifier
from starlette.status import HTTP_403_FORBIDDEN
from starlette.types import ASGIApp, Receive, Scope, Send
signature_verifier = SignatureVerifier(signing_secret=os.environ["SLACK_SIGNING_SECRET"]
@dorukgezici
dorukgezici / SensorsTX.cpp
Created September 12, 2017 23:27
Sending sensor data to RX output using Software Serial.
#include <arduino.h>
#include <SoftwareSerial.h>
#define TEMP_PIN A0
float temp;
SoftwareSerial mySerial(D6, D7); // RX, TX
void setup() {
Serial.begin(115200); // tty.wchusbserial14130
mySerial.begin(4800); // tty.wchusbserial14110
@dorukgezici
dorukgezici / macsudo.sh
Created July 14, 2017 05:46
MacSudo, gksudo equivalent for macOS using AppleScript in bash.
#!/bin/sh
# MacSudo, gksudo equivalent for macOS using AppleScript in bash.
osascript -e 'do shell script "'"$*"'" with administrator privileges'
@dorukgezici
dorukgezici / .bash_profile
Created July 13, 2017 08:55
Ubuntu's colorful .bashrc file for macOS.
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@dorukgezici
dorukgezici / macsudo-applescript.scpt
Last active July 14, 2017 05:45
Linux's gksudo equivalent for macOS Sierra, written with AppleScript.
#!/usr/bin/osascript
on run argv
set |command| to ""
repeat with parameter in argv
set |command| to |command| & " " & parameter
end repeat
do shell script |command| with administrator privileges
end run
@dorukgezici
dorukgezici / instagramify.py
Created May 30, 2017 18:03
A Pythonista Share Extension script that makes your photo square (instagramifies your photo) by adding black background to the narrower side and saves it to your photo library.
import appex, photos, sys
from PIL import Image
img = appex.get_image()
box = img.getbbox() # left upper right lower
width = box[2] - box[0]
height = box[3] - box[1]
if width > height:
size = (width, width)