Skip to content

Instantly share code, notes, and snippets.

View woswos's full-sized avatar
🐢

Barkin Simsek woswos

🐢
View GitHub Profile
@mencargo
mencargo / postgresql.md
Last active July 19, 2024 20:11
PostgreSQL Queries

Useful PostgreSQL Queries & Commands

All sizes in MB, change /1024/1024 to /1024/1024/1024 for GB.

Databases sizes

Without system databases

select
datname as database,
(pg_database_size(datname)/1024/1024) as size
@danilogr
danilogr / nasa_perseverance_apritags.ipynb
Created February 22, 2021 20:33
Finding AprilTag markers in Mars! NASA's rover Perseverance uses AprilTags!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuasha420
kuasha420 / steam-apfs-case-sensitive.md
Last active January 28, 2024 17:51
Update `brew` command

Steam Client on APFS Case Sensitive Mac OS Drive

If you are using APFS Case Sensitive File system and trying to use Steam, it will flicker & silently fail or show the following error message:

steam requires that '~/library/application support/steam/steam.appbundle/steam/contents/macos' be on a case-insensitive filesystem.

To fix the issue, follow the instruction here.

Run from your user account, NOT ROOT!

@wybiral
wybiral / noscript-tracking.go
Last active August 21, 2024 04:56
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@supix
supix / postgres_recovery.md
Last active June 6, 2024 18:46
Postgres error: Missing chunk 0 for toast value in pg_toast

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.

@jesugmz
jesugmz / Python-docstring-restructuredtext-style.rst
Last active June 23, 2024 16:33
Python docstring reStructuredText style

Python docstring reStructuredText style

Python Signatures

Signatures of functions, methods and class constructors can be given like they would be written in Python.

@khornberg
khornberg / encode_decode_dictionary.py
Created August 25, 2017 12:39
python 3 base64 encode dict
"""
Given a dictionary, transform it to a string. Then byte encode that string. Then base64 encode it and since this will go
on a url, use the urlsafe version. Then decode the byte string so that it can be else where.
"""
data = base64.urlsafe_b64encode(json.dumps({'a': 123}).encode()).decode()
# And the decode is just as simple...
data = json.loads(base64.urlsafe_b64decode(query_param.encode()).decode())
# Byte encode the string, base64 decode that, then byte decode, finally transform it to a dictionary
@BBBSnowball
BBBSnowball / espminiterm.py
Last active June 10, 2021 11:21
serial monitor for ESP8266, run "pio run -t upload" on ctrl-t ctrl-u, decode stacktraces, paths are hardcoded for platformio with nodemcuv2 board
import serial
from serial.tools import miniterm
import subprocess, sys, re, os
class ESPMiniterm(miniterm.Miniterm):
def handle_menu_key(self, c):
if c == '\x15': # ctrl-u
self.upload_file()
else:
super(ESPMiniterm, self).handle_menu_key(c)
@srli
srli / image_steganography.py
Created March 5, 2017 20:37
Hide text in images using steganography!
"""A program that encodes and decodes hidden messages in images through LSB steganography"""
from PIL import Image, ImageFont, ImageDraw
import textwrap
def decode_image(file_location="images/encoded_sample.png"):
"""Decodes the hidden message in an image
file_location: the location of the image file to decode. By default is the provided encoded image in the images folder
"""
encoded_image = Image.open(file_location)