Skip to content

Instantly share code, notes, and snippets.

View bityob's full-sized avatar

Yonatan Bitton bityob

View GitHub Profile
@bityob
bityob / keybase.md
Created May 8, 2025 19:26
keybase.md

Keybase proof

I hereby claim:

  • I am bityob on github.
  • I am bityob (https://keybase.io/bityob) on keybase.
  • I have a public key ASC261h_yI8o_3dgCe_huTAifu3D2g0ZCgCbQd5gwFUqwgo

To claim this, I am signing this object:

@bityob
bityob / README.md
Last active February 28, 2024 22:16
Postgres - Aggregate multiple rows to 1 row with removing duplicates, null, empty fields on text, array and 2D array types

What

We want to have 1 row by id, but not just aggregating all values with simple array_agg, but removing null and empty fields, removing duplicates, and doing it for array field and 2D array field too.

Table before agg logic

image

Table after agg logic

@bityob
bityob / torch-multi.ipynb
Created December 25, 2023 23:47
Run torch with multiprocessing on Jupyter Notebook (aka IPython, Jupyter Lab etc.)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bityob
bityob / async-smtp-test-server.py
Last active July 18, 2023 08:42
SMTP Debugging/QA/Testing Server, Simulate easily SMTP errors
from aiosmtpd.controller import Controller
import asyncio
class ExampleHandler:
async def handle_RCPT(self, server, session, envelope, address, rcpt_options):
print(f"handle_RCPT: {address}")
if address.endswith('@error.com'):
user_part = address.split("@")[0]
try:
@bityob
bityob / client.py
Last active November 12, 2022 19:49
TLS Client/Server with Client Certificate Autentication
import socket
import ssl
SERVER_PORT = 60000
HOST = "127.0.0.1"
tls_client_cert = "client.crt"
tls_client_key = "client-private-key.key"
tls_key_password = None
tls_ca_bundle = "ca_bundle.pem"
@bityob
bityob / get_longest_substring_of_two_chars.py
Created April 11, 2022 20:23
get_longest_substring_of_two_chars.py
def get_longest_substring_of_two_chars(string):
max_start = 0
max_end = 0
curr_start = 0
curr_second_char = 0
curr_end = 0
curr_chars = []
for index, ch in enumerate(string):
@bityob
bityob / $requests-latency-test-v2.26-vs-v.2.25.1.md
Last active July 29, 2021 12:25
Requests latency test v2.26 vs v.25.1

Run httpbin locally

docker pull kennethreitz/httpbin
docker run -d -p 8888:80 kennethreitz/httpbin

Clone this gist

git clone https://gist.github.com/02b1a823b478ad74a8440b86f95e13a6.git requests-latency-test
cd requests-latency-test
@bityob
bityob / Restart-Machine.ps1
Created July 11, 2019 09:53
Restart-Machine PS Script
$arguments=$args[0]
$command="Restart-Computer $arguments"
Write-Host "Command: '$command'"
iex $command
Write-Host "Done"
@bityob
bityob / Enable-OpenSSH-Client-Server-On-Windows.md
Last active March 11, 2025 22:23
Enable SSH Client/Server with OpenSSH on Windows

How to enable ssh on Windows?

Tested on Windows Version 10.0.17755.1

  • Run cmd as admin

  • Install OpenSSH.Client - dism /online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0

C:\WINDOWS\system32>dism /online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0
@bityob
bityob / Duplicate_dicts_in_list.ipynb
Last active October 14, 2021 07:10
Remove duplicates dicts from list (Python), #python #ipython. Source for solutions - https://stackoverflow.com/questions/9427163/remove-duplicate-dict-in-list-in-python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.