Skip to content

Instantly share code, notes, and snippets.

View jarun's full-sized avatar

Arun jarun

View GitHub Profile
@jarun
jarun / apps.md
Last active September 5, 2018 16:01
New interesting apps for Ubuntu
@jarun
jarun / timer.c
Created July 5, 2017 18:39
microsec timer in C for profiling
#include <iostream>
#include <sys/time.h>
int main()
{
struct timeval t1, t2;
double elapsedTime;
// start timer
gettimeofday(&t1, NULL);
@jarun
jarun / cupcakes.md
Last active April 23, 2023 17:14
Random collection of useful commands

A collection of awesome commands, functions, aliases to save your time

Play random music from your media storage:
# BASH shell

boom()                                                                           
{                                                                                
 find $@ -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.webm" -o -iname "*.wma" \) | sort -R | head -n 100 | xargs -d "\n" smplayer &gt; /dev/null 2&gt;&amp;1 &amp;
@jarun
jarun / gmail_cmdline.md
Last active September 2, 2017 18:44
How to send emails (with Gmail as SMTP server) from the cmdline when 2-Step Verification is ON

Generate an App password for your Google account. Select the custom option from the drop-down menu. The password will work with any of the utilities below.

Compose, 'sendemail' with attachment

  1. Install sendemail and dependencies

    sudo apt install libio-socket-ssl-perl libnet-ssleay-perl libterm-readkey-perl sendemail
    
  2. Apply patch1 to simplify the mailing experience

sudo patch /usr/bin/sendEmail < sendEmail-1.56-5.patch

@jarun
jarun / elinks.md
Last active September 3, 2017 18:10
Tips to improve elinks experience
@jarun
jarun / remexe.py
Created October 4, 2017 20:55
Remove executable permission for media files recursively
#!/usr/bin/env python3
import os
import stat
extns = ['.aac', '.avi', '.flac', '.m3u', '.m4a', '.mkv', '.mp3', '.mp4', '.smi', '.srt', '.sub', '.webm', '.wma']
for root, dirs, files in os.walk('.'):
for entry in files:
fname, ext = os.path.splitext(entry)
@jarun
jarun / Goa tips.md
Last active July 17, 2021 19:51
Notes from Goa, India trip (22 Oct 2017)

Sunset at Benaulim

  1. Use Google Maps, save Goa offline for quick access. Jio works everywhere.
  2. Buy hats. Goa is hot and humid (between Feb to Dec).
  3. If you reach Madgaon by train and want to go to North Goa, take an auto to the Madgaon Bus stand (around Rs. 120). Book a ticket for the non-stop express bus to the Panjim Bus stand. At Panjim Bus stand, take a KTC prepaid taxi to North Goa.
  4. A nice place to homestay is Joe and Marietta's guesthouse, Calangute Goa. They have all amenities like AC, fridge, hot water, wifi... It's very near to KFC. They will provide numbers to cab and bike services too. But do NOT buy petrol from them even if the lady insists. They charged Rs. 80/ltr when the petrol price in Goa was Rs. 52/ltr on the day. There are petrol pumps everywhere. One can stay in North Goa and visit Old Goa + Panjim by bike.
  5. Autos and cabs will cost you dearly. Hire a bike for a few days (~Rs. 300/day for Honda Activa). No Uber or Ola, thanks to govt
@jarun
jarun / memusage.sh
Last active August 8, 2020 21:20
Log memory usage by process name or PID with custom delay
#!/usr/bin/env bash
## Function to show error and exit
errexit()
{
echo "process not found.";
exit 1;
}
## Check number of arguments passed
@jarun
jarun / fish_noti.md
Last active August 2, 2023 17:36
notification on command completion (fish shell)

Instead of waiting for long commands to finish one can easily get notifications when they are complete. The following procdure shows how to set his in fish shell.

Requirements: fish shell, notify-send, xdotool

  • Add a new file vi ~/.config/fish/functions/noti.fish with the content below:
function fish_right_prompt
    if test $CMD_DURATION
 # Check if terminal window is hidden
@jarun
jarun / disassemble.md
Last active April 26, 2024 14:18
Guide to disassemble

prerequisites

  • Compile the program in gcc with debug symbols enabled (-g)
  • Do NOT strip the binary
  • To generate assembly code using gcc use the -S option: gcc -S hello.c

utilities

objdump