Skip to content

Instantly share code, notes, and snippets.

View salman-pathan's full-sized avatar
💭
I think in dreams and I dream in thoughts.

Salman Khan salman-pathan

💭
I think in dreams and I dream in thoughts.
View GitHub Profile
@salman-pathan
salman-pathan / foobar.go
Created May 1, 2023 12:07
Golang example to show concurrent print of 'foo' and 'bar' with Go's concurrency primitives
package main
import (
"fmt"
"sync"
"time"
)
// Foo prints 'foo' for 'limit' number of times. The 'fooChan' halts the execution
// on a separate goroutine and waits for a initial signal from the main. Once it
@salman-pathan
salman-pathan / multi-thread-go.md
Created February 7, 2023 03:22
Explanation of multi-thread processing in Go

Multi-thread processing in Go

Threads

A thread is the smallest unit of processing that an OS can perform. The default size of a thread in a Linux/x86-32 machine is 2MB

Threads can be :

  1. Concurrent - Two or more threads can start, run and complete in overlapping periods.
  2. Parallel - The same task can be executed multiple times at once.
@salman-pathan
salman-pathan / dektop-file-linux.md
Created January 3, 2023 06:47
Create dektop file in Linux

Create desktop file/ shortcut for Application

  1. Create a file in ~/.local/share/application with .desktop extension, i.e. myapp.desktop
  2. Add the following content to that file
[Desktop Entry]
Name=Application Name
Comment=Description about application
Exec=<PATH TO APP>
Icon=<PATH TO APP's image>
Terminal=false // Whether the program runs in a terminal window. 
@salman-pathan
salman-pathan / GitlabRelease.md
Created November 25, 2022 12:40
Gitlab release binary upload

Upload binary to gitlab

curl --request POST --header "PRIVATE-TOKEN: <token>" \
     --form "file=@<filename>" "https://gitlab.com/api/v4/projects/<username>%2F<project-name>/uploads"

Extract audio from mp3 file

ffmpeg -i test.mp3 -ss 00:00:00 -to 00:00:30 -c copy -y temp.mp3

Convert mp3 file to wav

ffmpeg -i song.mp3 -acodec pcm_u8 -ar 22050 song.wav

@salman-pathan
salman-pathan / init.vim
Last active March 18, 2022 09:40
My configuration file for NeoVim
" _____ _ __
" / ___| | / / Salman Khan
" \ `--.| |/ / https://github.com/salman-pathan
" `--. \ \
" /\__/ / |\ \
" \____/\_| \_/
"
" Configuration inspired by DT (Derek Taylor)
" A customized init.vim for neovim (https://neovim.io/)
" NVIM v0.6.1
@salman-pathan
salman-pathan / docker.md
Last active January 22, 2022 12:01
Docker Help

Get Container IP

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}'

@salman-pathan
salman-pathan / git.md
Created December 17, 2021 14:01
Helpful commands for git

Keys

Create new Key

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

SSH Agent

Add Key to SSH Agent

eval "$(ssh-agent -s)" ssh-add <your-key>

List Keys in Agent

@salman-pathan
salman-pathan / Consul EC2 Config.md
Created October 22, 2021 14:36
Consul Server & Client Configuration on Amazon EC2

Consul Configuration on EC2

Installing Consul

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
@salman-pathan
salman-pathan / .vimrc
Created March 16, 2021 09:40
My .vimrc file
syntax on
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nu
set nowrap
set smartcase