Skip to content

Instantly share code, notes, and snippets.

View dusansimic's full-sized avatar
🫠
Working 3.5 jobs at the moment

Dušan Simić dusansimic

🫠
Working 3.5 jobs at the moment
View GitHub Profile
@dusansimic
dusansimic / cli.py
Created August 1, 2016 11:09
Small python script for clearing console window.
import os
import sys
if sys.platform() == "win32":
def clear(): os.system("cls")
elif sys.platform() == "linux2":
def clear(): os.system("clear")
elif sys.platform() == "cygwin":
def clear(): os.system("clear")
elif sys.platform() == "darwin":
@dusansimic
dusansimic / spinner.py
Last active September 12, 2016 00:10
Spinner in python.
import sys
import time
def spinning_cursor():
while True:
for cursor in '|/-\\':
yield cursor
def start():
spinner = spinning_cursor()
@dusansimic
dusansimic / progress-bar.py
Created August 2, 2016 15:46
Simple progress bar in python.
import time
import sys
toolbar_width = 40
current = 0
for i in range(1, 101):
time.sleep(0.1)
@dusansimic
dusansimic / swap.c
Created October 1, 2016 20:06
Swap two numbers with macro code.
#define swap(a, b) do { \
typeof(a) temp = a; \
a = b; \
b = temp; \
} while (0);
@dusansimic
dusansimic / countlines.sh
Created July 12, 2017 01:24
Count lines of all files in the directory
#!/bin/bash
find . -name '<include files>' -not -path '<exclude dir>' | xargs wc -l
@dusansimic
dusansimic / myip.sh
Last active September 20, 2017 13:04
Get your public ip address with one simple script.
#!/bin/bash
printf "Local: %s\n" "$(ifconfig enp3s0 | grep 'inet ' | awk '{ print $2}')"
printf "Global: %s\n" "$(dig +short myip.opendns.com @resolver1.opendns.com)"
@dusansimic
dusansimic / gitlog.sh
Last active December 22, 2018 09:37
Pretty git log.
git config --global alias.lg "log --graph --abbrev --decorate --pretty=format:'%h %C(bold blue)%s%C(reset) %C(yellow)%d%C(reset) %C(dim green)%an %C(dim white)%ar%n' --all"
git config --global alias.lgg "log --graph --abbrev --decorate --pretty=format:'%h %C(bold blue)%s%C(reset) %C(yellow)%d%C(reset) %C(dim green)%an %C(dim white)%ar%n%b%n' --all"
@dusansimic
dusansimic / tmux.md
Last active March 15, 2019 00:46 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@dusansimic
dusansimic / provision.sh
Created April 5, 2019 22:25
Provision for Microsoft SQL Server Vagrant Box
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
apt-get update
apt-get install -y mssql-server
@dusansimic
dusansimic / corona.sh
Last active March 21, 2020 19:39
Corona Virus Victims CLI
#!/bin/sh
curl 'https://corona-stats.online/serbia?source=2' -s |
sed 's/\x1b\[[0-9;]*m//g' | # Remove ANSI color codes
grep 'Serbia' |
sed 's/\s*//g ; s/║//g ; s/│/;/g' |
awk -F';' '{ if ($4 == "") {$4 = 0;} if ($6 == "") {$6 = 0;} print "😷 " $3 " (" $4 ") 💀 " $5 " (" $6 ") 👍 " $7 }'