Skip to content

Instantly share code, notes, and snippets.

View johananj's full-sized avatar

Johanan Joysingh johananj

View GitHub Profile
@johananj
johananj / tmux_reference.md
Last active March 4, 2024 06:45
[Tmux QuickReference]

Basics

  • Start a tmux session: tmux
  • Prefix: ctrl + b
  • Activate command mode: prefix + :
  • Activate scrolling: prefix + [

Sessions

  • Create a new session: tmux new-session or :new
  • Attach to a tmux session: tmux attach -t 0 or tmux attach -t session-name
  • List sessions: prefix + s
@johananj
johananj / vimrc
Created January 7, 2024 08:50
[Vim RC] My vimrc file
set nocompatible
set showcmd
set autoindent
set noexpandtab
set tabstop=2
set shiftwidth=2
set number
@johananj
johananj / github_cli.md
Created December 8, 2023 05:57
[Github CLI - Quick Reference] A quick reference for the CLI version of Github.

Installation and Configuration

  • Install using the install info from the cli github page.
    • Asks to add repository to apt, and then install via apt.
  • Authenticate the github app using: gh auth login
    • Follow the instruction on screen.
    • Opens the browser for you to login.
    • After login, the github cli app and your github account are connected.
  • Set the default editor using: gh config set editor vim
    • If not already set during the previous step.
    • If it's vscode, use code --wait, so that it waits for the window to close, when executing a series of commands.
@johananj
johananj / jupyter-remote.md
Last active November 30, 2023 06:51
[Jupyter Remote] Setting up Jupyter notebook on a server, and accessing it via the network.

Why

This tutorial can be used to host a jupyter notebook

  • from your server (maybe a powerful desktop at home?), and
  • work on it from a low powered notebook (a chromebook?).

How

  • Have jupyter installed on the remote server, in what ever virtual environment you want to use it in.
  • You could do this afresh by
    • connecting via ssh
  • creating a new environment
@johananj
johananj / bigo.md
Last active November 21, 2023 10:18
[Big O Notation] Some notes on Big O Notation
  • Shows how a piece of code scales with input.
  • For example: Processing a list of 10 items, vs processing a list of 10,000 items.

Linear Time O(n)

  • Takes linear time.
  • For n inputs, it takes n computations to produce outputs.
  • Example: Linear search through a list

Constant O(1), or O(2) ...

  • Takes a constant number of operations to produce the output, no matter the size of the input.
@johananj
johananj / imagemagick.md
Last active February 1, 2024 08:40
[Imagemagick Quick Reference]

Cropping

  • Crop a 800x700 into a 400x350 image with x and y offsets set to 50 and 40

    • convert original.jpg -crop 400x350+50+40 cropped.jpg
  • If you want to do it in-place

    • mogrify -crop 400x350+50+40 original.png
  • To crop all images in-place

    • mogrify -crop 400x350+50+40 *.png
  • To 'chop' 20 rows on the top, bottom, or the sides of the image use:

    • convert image.png -gravity South -chop 0x20 result.png
@johananj
johananj / crontabs.md
Last active October 28, 2023 17:32
[Crontab Quick Reference] Quick reference for adding jobs to the Crontab

Basics

  • Use crontab -l to list existing items in crontab.
  • Use crontab -e to edit the crontab.
    • If you have never added anything before a new file will be created.
    • Pick an editor of your choice to edit the crontab.

Syntax

  • Syntax of crontab entry: * * * * * <username> command(s)
  • Commands can be followed by arguments.
  • Multiple commands can be added with &amp;&amp;.
@johananj
johananj / commands.md
Last active May 29, 2026 10:09
[Rclone Quick Reference] Cheatsheet for rclone commands.
  • To show existing configurations: rclone config show
  • To mount a drive: rclone mount --daemon remote_name: /home/user/mount_folder/
  • To unmount: umount /home/user/mount_folder
  • To copy a folder to drive: rclone copy ~/folder_name remote_name:folder_name
  • To copy a folder if it's a day old, without traversing through all the existing files in the remote: rclone copy --max-age 24h --no-traverse ~/folder_name remote_name:folder_name
  • To sync two folders, one in local and another in remote: rclone sync ~/folder_name remote_name:folder_name
  • In copy or sync
    • To see a dry run use: --dry-run
    • To see progress use: --progress
@johananj
johananj / configuring_googledrive.md
Last active October 28, 2023 05:47
[Configuring Rclone]

Making a Client ID

  • First you will need to create client-id and password, to communicate with google drive freely.
  • You can also use rclone's client id, but that will be slow, since everyone who does not have the expertise would use rclone's id. So, it is better to create one.
  • The tutorial on rclone's website is really detailed, and is good enough to configure it.
  • Essentially what you are saying to google is that you have an app that you want to communicate to google's drive api, and you are creating the means for it to communicate.

Configuring GDrive on RClone

  • This process is straightfoward once you setup the client api.
  • Start the process. rclone config
  • Select 'New Remote'
@johananj
johananj / how-to.md
Last active October 1, 2023 02:16
[Firefox - apt instead of snap] Installing the apt version of Firefox, instead of snap. Involves removing snap version, adding the firefox repository, installing.

Source

  • Add the repository: sudo add-apt-repository ppa:mozillateam/ppa
  • Prioritize apt instead of snap
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001