Skip to content

Instantly share code, notes, and snippets.

View 0x48piraj's full-sized avatar

Piyush Raj 0x48piraj

View GitHub Profile
@0x48piraj
0x48piraj / server.py
Last active April 8, 2024 13:13
Basic key-value store over HTTP using sockets in Python3
import sys
import json
import os
from socket import (
socket,
AF_INET,
SOCK_STREAM,
SO_REUSEADDR,
SOL_SOCKET
)
@0x48piraj
0x48piraj / find-forks-of-deleted-github-repo.md
Created January 3, 2024 22:33
Finding forks of a deleted GitHub repository
@0x48piraj
0x48piraj / python-utils.py
Last active December 14, 2023 05:36
Random scripts and procedures in a nice little package.
def citup(lst):
"""
chunk-it-up: break a list into n-sized chunks
"""
return [lst[i:i+n] for i in range(0, len(lst), n)]
mixedlol = [["a", 500, datetime.datetime], ["b", 1000, datetime.datetime], ["C", 1500, datetime.datetime]] # list of lists
def hoelol(mixedlol):
@0x48piraj
0x48piraj / lfs-bandwidth-circumnavigation.md
Created December 11, 2023 20:26
Circumnavigation for fetching/cloning/downloading remote repository with LFS files

Error message

This repository is over its data quota.
Account responsible for LFS bandwidth should purchase more data packs to restore access.

Solution

  1. Fork the target repository.
@0x48piraj
0x48piraj / fix-bootloader.ps1
Created September 30, 2023 17:47
Removing GNU GRUB on UEFI Systems After Deleting Ubuntu Partition (without using any removable device techniques)
mountvol S: /S
S:
cd .\EFI\
dir
rd /S Ubuntu
@0x48piraj
0x48piraj / tiani.js
Created October 27, 2022 11:34
A small function for creating beautiful ASCII based animations on your website's title.
/*
usage: ASCIIAnimation(param1, param2, param3)
param1 - array of animation 'frames' (strings)
param2 - speed of animation in ms
usage:
var anim = new ASCIIAnimation([":)",":|",":("], 100);
*/
@0x48piraj
0x48piraj / CLOC.sh
Created September 25, 2021 09:37
CLOC: Count the lines of code of any project recursively grouped by file extensions
find ./ -not -path "./.git/*" -type f -exec wc -l {} + |
awk '{print tolower($0)}' |
sed -e '$ d' |
sed -e "s#/.*/##g" |
sed -e "s/\./ \./g" |
awk '
{ if ( NF <= 2 ) { count["none"] += $1 } else { count[$NF] += $1 } }
{ next }
END { for (group in count) printf("%d%s%s\n", count[group], OFS, group) }
' |
@0x48piraj
0x48piraj / caesar.sh
Created September 24, 2020 12:56
Bash one-liner for breaking caesar cipher.
#!/bin/bash
tr 'A-Z' 'a-z' < $2 | tr 'a-z' $( echo {a..z} | sed -r 's/ //g' | sed -r "s/(.{$1})(.*)/\2\1/" )
@0x48piraj
0x48piraj / stream.py
Created April 6, 2020 00:42
Video Streaming Raspberry Pi Camera Via Python Sockets & VLC Media Player
import socket
import subprocess
# Start a socket listening for connections on 0.0.0.0:8000 (0.0.0.0 means all interfaces)
server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 8000))
server_socket.listen(0)
# Accept a single connection and make a file-like object out of it
connection = server_socket.accept()[0].makefile('rb')
@0x48piraj
0x48piraj / receive-image.py
Created April 6, 2020 00:40
Receiving Images From a Raspberry Pi via Python Sockets
import io
import socket
import struct
from PIL import Image
# Start a socket listening for connections on 0.0.0.0:8000 (0.0.0.0 means all interfaces)
server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 8000))
server_socket.listen(0)