Skip to content

Instantly share code, notes, and snippets.

Avatar

Mischievous Meerkat jarun

View GitHub Profile
@jarun
jarun / Fun bugs.md
Last active Jul 16, 2020
Bugs those fascinated me
View Fun bugs.md

Bugs those fascinated me

Developers fix thousands of defects in their careers. However, there are always a memorable few. I thought of listing down some of the interesting bugs I came across so far.

1. Messages those reach before sent

One from the early years of my career. I was working on SMS/MMS protocols during the time, After sending out a few lakhs of messages from one handled to another kept beside each other it was seen that even before the message is sent completely from mobile A it reaches mobile B and the user gets the notification.

It was late night but a challenge interesting enough to keep you awake. After a few hours of debugging it was found that the implementation was using a linked list to which it was appending each new message information at the end before sending it out to the lower telephony layer which would confirm asynchronously once the message was successfully sent. However, on receiving the confirmation, it does some bookkeeping and it was searching the list from the head f

@jarun
jarun / netplan.md
Last active Jun 6, 2020
Ubuntu Server 20.04 on Raspberry Pi 4: WiFi configuration from terminal with Netplan
View netplan.md

List the network devices.

$ ls /sys/class/net
eth0  lo  wlan0

Edit the config file.

@jarun
jarun / migrate-fish-history-to-zsh.py
Created Jan 15, 2020 — forked from mateuspontes/migrate-fish-history-to-zsh.py
Migrate fish history to zsh shell (python 2.7)
View migrate-fish-history-to-zsh.py
import os
import re
def fish_to_zsh(cmd):
return (cmd.replace('; and ', '&&')
.replace('; or ', '||'))
with open(os.path.expanduser('~/.zsh_history.test'), 'a') as o:
with open(os.path.expanduser('~/.local/share/fish/fish_history')) as f:
for line in f:
@jarun
jarun / vim.md
Created Nov 22, 2019
Useful vim tips
View vim.md
daw - delete a word (under cursor)
caw - delete a word (under cursor) and put in inset mode
@jarun
jarun / lookups.md
Last active Nov 1, 2019
frequent man pages and help lookups for programming
View lookups.md
@jarun
jarun / ratio.sh
Last active Feb 15, 2020
Get the size to duration ratio of a media
View ratio.sh
#!/usr/bin/env sh
# Description: POSIZ compliant script to get the size to duration of a media file
# Requires: mediainfo, bc, ls
#
# For sorted output: ratio.sh | sort -rg
for file in *; do
# get duration in milliseconds->mins
ms=$(mediainfo --Inform="Video;%Duration%" "$file")
@jarun
jarun / split.py
Created May 6, 2019
Split a music track into specified sub-tracks using ffmpeg
View split.py
#!/usr/bin/env python3
'''
Description: split a music track into specified sub-tracks using ffmpeg
target files are saved as variable bit-rate mp3 (lossless)
Usage: split <original_track> <track_list>
'''
import shlex
@jarun
jarun / Termux_from_Ubuntu.md
Last active May 30, 2020
How to connect to Termux from Ubuntu desktop
View Termux_from_Ubuntu.md

In this example, we will setup a SSH server on Termux (for Android) and connect to the server from Ubuntu desktop. However, a similar procedure should work with any SSH server.

  1. Generate your ssh key pair on your desktop

    $ ssh-keygen
    
  2. Check your desktop IP address (say, 192.168.0.100)

  3. Run ssh server on your desktop

  4. Copy the file to Termux over SCP

    $ scp arun@192.168.0.100:~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
    
@jarun
jarun / Highlight.vim
Last active Mar 20, 2019
vimscript to highlight visual selection or string under cursor
View Highlight.vim
" script modified from: https://bitbucket.org/sjl/dotfiles/src/b6d64b1c4cdf53060e3c30b3b87a653a30dc85d0/vim/vimrc?at=default&fileviewer=file-view-default#vimrc-3125
"
" ctermbg color code ref: http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim
" Usage
" -----
" Add the following to your .vimrc:
" :map <silent> <C-a> :normal! gv"zy<CR>
" Use '\1' to '\9' for different color highlighting. '\0' clears all highlighting.
" In general, a visual selection followed by 1. Esc and 2. ^a will be highlighted.
" If there is no visual selection, the word under cursor will be highlighted.
@jarun
jarun / disassemble.md
Last active Sep 22, 2020
Guide to disassemble
View disassemble.md

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

You can’t perform that action at this time.