Skip to content

Instantly share code, notes, and snippets.

View dchakro's full-sized avatar
👨‍💻

Deepankar Chakroborty dchakro

👨‍💻
View GitHub Profile
@dchakro
dchakro / FixFontSmoothing.sh
Created January 15, 2022 11:17
Fix font smoothing on MacOS onexternal displays without high ppi
#!/usr/bin/bash
# These commands can help you fix font smoothing on MacOS Catalina & Big Sur
# on non-retina external displays i.e. external displays without high ppi.
# Levels 0 (no smoothing), 1 (low) - 3 (strong)
printf '
-------: Menu :--------
@dchakro
dchakro / marketsFT_parse.R
Created December 1, 2021 09:57
R function to parse historical quotes from markets.ft
# R function to parse historical quotes from markets.ft
# 1) Go to URL for your traded instrument e.g. https://markets.ft.com/data/etfs/tearsheet/historical?s=SPPY:FRA:EUR
# 2) Set date range
# 3) Copy the quotes to a text file
# 4) Use marketsFT_parse (pass the text file as argument) to get quotes
marketsFT_parse <- function(FILE=NULL){
dat <- data.table::fread(FILE)
@dchakro
dchakro / remove-git-lfs.md
Last active June 10, 2021 09:10 — forked from everttrollip/remove-git-lfs.md
Removing git lfs from (any) repository

So, it has been an interesting journey, but time to remove git-lfs. Here follows a summary of the approach I used to safely remove git-lfs,

  • git add --update; git commit -m “Commit before lfs removal”; git push
  • git checkout -b “remove-lfs”
  • remove hooks git lfs uninstall
  • remove files enrolled in git-lfs from .gitattributes (open the file, delete the contents) [P.S. don’t delete the file!]
  • list all lfs files, git lfs ls-files
  • run git rm --cached for each file
    • git lfs ls-files | cut -f 3 -d ' ' | xargs git rm --cached
  • Untrack files (individually or pattern)git lfs untrack '*.xz'
@dchakro
dchakro / Automate_System_Sleep_Wake_Debian.md
Last active March 31, 2021 19:44
Automatic system sleep and wake Debian linux dietpi

What is this about?

These gist contains shell scripts to automate system sleep and wake on your machine running Debian linux (in my case DietPi).

until_tomorrow.sh is a bash script using rtcwake from the util-linux package to make your (supported) system sleep "now" and wake-up at a specified time.

How to use

Run the following line:

curl -ssL 'https://gist.github.com/dchakro/571fe4d78219a9b4ff17690481c3afab/raw/add_cronjob.sh' | bash
@dchakro
dchakro / CiscoVPN_splittunneling_CLI.md
Last active October 1, 2024 01:06
CiscoVPN_splittunneling in MacOS without using Cisco Anyconnect

Split tunneling with Cisco Anyconnect VPN in CLI with minimal overhead

Cisco Anyconnect VPN is a popular enterprise VPN and is unfortunately the choice of my current workplace (instead of openVPN) 🤦‍♂️

This gist aims to alleviate these 3 issues I have Cisco's Anconnect Mobility client:

  1. On my Mac machines, it has a significant overhead (as compared to the solution in this gist)

  2. I ditched Anyconnect client wayback when I discovered that it installs and runs in the background as a daemon even if you exit the program. The battery takes a hit and it used to cause wakelocks on my macbook and cause the battery to die overnight, while my laptop was resting on the table with the lid closed.

@dchakro
dchakro / pocket2shiori.sh
Last active May 26, 2022 19:40
script to import pocket entries into shiori with text, images etc. instead of plain bookmarks.
#!/bin/sh
# Extracting URLs from the exported HTML from getpocket.com/export
# In the following line $1 is the exported HTML from pocket
# which will be passed to this script as a CLI parameter
grep -Eoi '<a [^>]+>' $1 | grep -Eo 'href="[^\"]+"' | cut -d'=' -f 2 | tr -d '"' | tac > pocket2shiori.txt
# Reading the URLs one by one and adding to shiori
while IFS= read -r line; do
shiori add $line
@dchakro
dchakro / brew.installations.sh
Last active April 7, 2021 08:55
Make OSX great Again!
## Mac OS is my favorite operating system but some of the bundled CLI tools are either outdated or slow to the new-age counterparts
# With the hardworks of people over at Homebrew, getting alternatives is a breeze.
## Here's how to do it:
# STEP-1 Install brew.sh
# Visit https://brew.sh
# STEP-2 Install brewlog (allow you to keep a log of brew activity, i.e. where the files are installed, what modifications [if any] were done)
@dchakro
dchakro / CompoundCommands.md
Last active August 24, 2020 13:45
Compound Commands installs commands in /usr/local/bin/. that combine a few commands to give a desired result. Geared towards ease of use

The gists here contain bash scripts that install commands in /usr/local/bin, you may need sudo depending on your permissions.

The installed command usually chains together a series of commands to achieve desired results and requires only a few keysctrokes to invoke instead of typing a long string of parameters and pipes everytime.

Includes:

  1. brewlog brewlog = run homebrew's brew commands while saving the stdoutto a log file in your ~/Logs/brew.log
    • Not to be confused with brew log which shows the commit history (similar to git log).
    • I need to find a new name, but for now as I personally don’t use brew log, I had no “merge conflicts” in my brain while assigning brewlog to achive my desired result of logging brew output :) [IMHO brew history might have been a better name for brew log]
@dchakro
dchakro / parallelRDS.R
Last active June 15, 2021 07:27 — forked from retrography/parallelRDS.R
Parallelize RDS compression/decompression to improve serialization performance in R
# Modified from: https://gist.github.com/retrography/359e0cc56d2cf1acd161b5645bc801a8
# The functions below use parallelized version of gzip called pigz
# to improve compression/decompression performance of RDS serialization in R.
# Each function searches for the appropriate program (based on the require
# compression format) and if found, offloads the compression handling to the
# external program and therefore leaves R free to do the data import/export.
# The functions have been only tested on macOS, but probably also work on other *nix systems
@dchakro
dchakro / ConfigGuard.md
Last active August 24, 2020 13:50
ConfigGuard - Safeguard your dotfiles and /etc/ configs with bare git repo

How to use ConfigGuard

  1. Grab ConfigGuard from this Gist.

    # For deploying dotGuard
    curl -OJL 'https://gist.githubusercontent.com/dchakro/2bb714db3712f76610fe4f6ee2a82155/raw/deploy_Cerberus.sh'
    
    # For deploying etcGurad
    curl -OJL 'https://gist.githubusercontent.com/dchakro/2bb714db3712f76610fe4f6ee2a82155/raw/deploy_etcGuard.sh'