Skip to content

Instantly share code, notes, and snippets.

View arnabdas's full-sized avatar

Arnab Das arnabdas

View GitHub Profile
@arnabdas
arnabdas / conf.json
Last active May 23, 2017 17:14
Install shadowsocks-libev on Ubuntu
{
"server":"xx.xx.xx.xx",
"server_port": 1234,
"local_port": 1234,
"password":"long-non-guessable-password",
"timeout": 600,
"method":"chacha20-ietf-poly1305"
}
@arnabdas
arnabdas / http-post.js
Created May 15, 2017 12:09
Example of 'POST' with 'http' module of NodeJs
var http = require('http');
var postOptions = {
hostname: 'localhost',
port: '8090',
method: 'POST',
path: '/api'
headers: {
'Content-Type': 'application/json'
}
@arnabdas
arnabdas / split-zip-files.sh
Last active May 20, 2017 05:28
Split all the files into intended sizes inside a folder with 7zip
#! /bin/bash
# a - add to archive
# -mx0 - copy only
# -v250m - makes split of 250 MB of each files
#7z a <new_name>.7z -mx0 -v250m <intermediate_name>.7z
# set the minimum size in bytes (here: 100mb)
minimumSize=100000000
for i in *.7z; do
@arnabdas
arnabdas / .gitconfig
Last active April 14, 2017 14:22
Random commit messages from http://whatthecommit.com
[alias]
random = !"git commit -am \"$(echo $(curl -s http://whatthecommit.com/index.txt))\"; git pull --rebase; git push"
@arnabdas
arnabdas / .vimrc
Created April 14, 2017 13:33
Insert spaces for tab's in VIM editor
" http://stackoverflow.com/questions/234564/tab-key-4-spaces-and-auto-indent-after-curly-braces-in-vim
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
@arnabdas
arnabdas / fedora-chrome-no-sound.sh
Created February 25, 2017 10:11
In Fedora, if anything played in Chrome, sometimes the sound does not come. To fix that, a simple hack.
#!/bin/bash
pacmd list-sinks
#will show all of the available audio outputs
pacmd list-sink-inputs
#will list all programs that are currently playing music and
@arnabdas
arnabdas / deploy.sh
Created February 24, 2017 18:17
Deploy with rsync
#!/bin/bash
# Run with the command: `./deploy.sh live go`
$SERVER_IP="xx.xx.xx.xx"
$ERRORSTRING="Error. Please make sure you've indicated correct parameters"
cd ./public
if [ $# -eq 0 ]
then
echo $ERRORSTRING;
elif [ $1 == "live" ]
@arnabdas
arnabdas / extract.sh
Created February 18, 2017 11:44
Shell (BASH/ZSH) function for extracting an archive
# dnf install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
# dnf install unrar cabextract p7zip-plugins ncompress xz-lzma-compat
extract() {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
return 1
else
@arnabdas
arnabdas / rungo.sh
Created February 18, 2017 10:34
A simple function to add to bashrc or zshrc to compile, link, run a Go source code file and delete the intermediate files with one command
rungo() {
gccgo -c $1
file="${1%%.*}"
gccgo -o $file ($file).o
./$file
rm -f $file
rm -f ($file).o
}
@arnabdas
arnabdas / .zshrc
Created February 14, 2017 16:13
PS1 variable for ZSH
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
PS1=$'\n$(git_prompt_info)%{$fg[cyan]%}%/\n${ret_status}%{$reset_color%}'