Skip to content

Instantly share code, notes, and snippets.

View raveensrk's full-sized avatar

Raveen Kumar raveensrk

  • Uhnder Inc.
  • India
View GitHub Profile
@raveensrk
raveensrk / append_a_list_to_list.md
Created August 30, 2023 12:33
In python, How to append one list to another list?

You can append the new_options list to another list using the extend() method or the += operator. Here's how you can do it:

# Your new_options list
new_options = [
    {
        "shortname": "-clean",
        "help": "Cleans run directory",
        "required": True,
 "default": False,
@raveensrk
raveensrk / note.md
Created August 30, 2023 12:30
In python, what is the difference between extend() and append() methods?

Both extend() and append() are methods used to add elements to a list in Python, but they behave differently.

  1. append(): This method is used to add a single element to the end of a list.
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)  # Output: [1, 2, 3, 4]
@raveensrk
raveensrk / How to find path to the module file from which a class is instantiated in system in python.md
Created August 29, 2023 14:09
How to find path to the module file from which a class is instantiated in system in python

In Python, you can find the path to the module file from which a class is instantiated using the inspect module. The inspect module provides functions for introspecting objects, including classes and modules. Here's an example of how you can achieve this:

import inspect
from your_module import YourClass  # Import the class you're interested in

# Get the path of the module containing the class
class_module_path = inspect.getfile(YourClass)
@raveensrk
raveensrk / square_fit_image
Created August 27, 2023 15:09
How to square fit image using Bash and FFMPEG
#!/usr/bin/env bash
name=$(strip_extension "$1")
output_file_name="${name}-square.jpg"
ffmpeg -i "$1" -vf "scale='min(1080,iw)':'min(1080,ih)',pad=1080:1080:(1080-iw)/2:(1080-ih)/2" "$output_file_name"
echo "$output_file_name"
@raveensrk
raveensrk / align_csv
Created August 27, 2023 08:29
How to align a csv file?
#!/bin/bash
columns -t -s "," "$1"
@raveensrk
raveensrk / takeout_yt_subs_to_rss_feed
Created August 26, 2023 15:18
Convert all YouTube subscriptions to rss feed urls. subscriptions.csv from google takeout is the input.
#!/usr/bin/env bash
# This script basically converts input subscriptions.csv file from youtube takeout and converts to rss feed format. You can add this to ~/.newsboat/urls
get () {
url="$1"
rss="${url##*/}"
rss="https://www.youtube.com/feeds/videos.xml?channel_id=${rss}"
echo $rss
}
@raveensrk
raveensrk / strip_extension.bash
Created August 26, 2023 14:48
Strip extension from a filename using bash
#!/bin/bash
name="$(basename "$1")"
name_without_extension="${name%\.*}"
echo "$name_without_extension"
@raveensrk
raveensrk / gist:224c8192f2f857e6285098a6a20f8528
Created August 25, 2023 13:26
How to Redraw the screen in tmux?
<prefix>R
@raveensrk
raveensrk / .tmux.conf
Created August 25, 2023 10:02
You can have named tmux panes. Add this to ~/.tmux.conf.
set -g pane-border-status top
set -g pane-border-format " [ ###P #T ] "
bind-key T command-prompt -p "Enter pane title: " "run-shell 'tmux select-pane -T \"%1\"'"
@raveensrk
raveensrk / settings.json
Created January 25, 2023 10:21
fira code font settings for windows terminal
"font":
{
"face": "Fira Code Retina",
"features": {
"cv01": 1,
"cv02": 1,
"cv03": 1,
"cv09": 1,
"cv12": 1,
"cv14": 1,