Skip to content

Instantly share code, notes, and snippets.

View fahadsiddiqui's full-sized avatar

Fahad Siddiqui fahadsiddiqui

View GitHub Profile
@fahadsiddiqui
fahadsiddiqui / find_string_in_certain_files.sh
Created February 20, 2024 14:44
Find/grep all occurrences of certain string in all the files ending with certain extension.
find . -type f -name "*.env" | xargs grep "HTTP_PORT"
@fahadsiddiqui
fahadsiddiqui / generate_gitignore_go.sh
Created November 27, 2023 05:36
Generate .gitignore file for a Golang based basic project.
#!/usr/bin/env bash
wget https://www.toptal.com/developers/gitignore/api/go -O .gitignore
@fahadsiddiqui
fahadsiddiqui / keybase.md
Created August 11, 2023 16:03
Keybase public identity.

Keybase proof

I hereby claim:

  • I am fahadsiddiqui on github.
  • I am fsdqui (https://keybase.io/fsdqui) on keybase.
  • I have a public key ASCL3APHaktYii4s1q9LPl5zfZmD2hhyGkTG2QevG2GatAo

To claim this, I am signing this object:

#!/usr/bin/env bash
set -ex
PWD=$(pwd)
mkfifo /tmp/servicelogs.pipe || echo "pipe already exists"
runningPIDs=()
exitfn () {
@fahadsiddiqui
fahadsiddiqui / install-hadoop-mac-apple-silicon.md
Last active June 27, 2023 21:00
Install Hadoop on Mac (M1, M2) with Apple Silicon
  • Install brew (Homebrew)
  • Install hadoop
    brew install hadoop
  • cd into hadoop configuration files
    cd /opt/homebrew/Cellar/hadoop/3.3.4/libexec/etc/hadoop
    

Error

Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Solution

sudo usermod -a -G docker $USER
@fahadsiddiqui
fahadsiddiqui / flatten_df.scala
Last active May 22, 2023 19:42
Flatten a nested JSON Spark DataFrame using Scala, Spark 2.2.+ — a custom solution.
def flattenDataFrame(df: DataFrame): DataFrame = {
val fields = df.schema.fields
val fieldNames = fields.map(x => x.name)
for (i <- fields.indices) {
val field = fields(i)
val fieldType = field.dataType
val fieldName = field.name
fieldType match {
case _: ArrayType =>
@fahadsiddiqui
fahadsiddiqui / docker_ps_pretty_print.md
Last active September 1, 2021 18:33
Program details docker handy commands.

Format out of Json using docker inspect

docker ps -q | xargs docker inspect --format '{{ .Id }} - {{ .Name }} - {{ .NetworkSettings.IPAddress }}'

Format docker ps

docker ps --format="{{.Names}}\t{{.ID}}\t{{.Ports}}"

First run the one below to be able to install pg_config

brew install postgresql

Install openssl

brew link openssl
@fahadsiddiqui
fahadsiddiqui / md_tree.sh
Last active October 20, 2020 10:46
Markdown-safe tree creation using bash command `tree`. Just go to the project root, and run it.
tree . -aF --dirsfirst -I '.git|node_modules|.idea' | sed -e 's/│/|/g' -e 's/└/+/g' -e 's/├/+/g' -e 's/──/--/g'