Skip to content

Instantly share code, notes, and snippets.

View yradunchev's full-sized avatar

Yordan Radunchev yradunchev

View GitHub Profile
@yradunchev
yradunchev / distance.c
Created November 22, 2012 08:58
Calculating distance between two GPS coordinates. Result in meters.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define ER (6371007.2)
#define RAD(degrees) (degrees * (M_PI / 180))
main(int argc, char **argv)
{
double dLa1, dLo1, dLa2, dLo2;
@yradunchev
yradunchev / isgd.sh
Created December 8, 2012 18:10
is.gd on the command line - shorten url directly to the clipboard ready to paste.
#!/bin/bash
baseurl="http://is.gd/create.php?format=simple"
for URL in "$@"; do
curl -s --data-urlencode "url=$URL" "$baseurl" | xclip -selection c
done
exit $?
@yradunchev
yradunchev / sanitize_usb_drive.sh
Created December 20, 2012 14:17
'Sanitize' USB flash drve..
find . -regex ".*\.\(inf\|exe\|bat\)" -exec sh -c 'mv "$0" "${0%}.SUSPICIOUS"' {} \;
@yradunchev
yradunchev / caption.sh
Created December 27, 2012 05:14
add caption to picture...
#!/bin/bash
[[ "$#" -eq 2 ]] || { echo "Usage: ${0} pict.ure \"caption text\"" >&2; exit 1; }
convert \
-size $(identify -format %w ${1})x40 \
-background transparent \
-gravity center \
-font Helvetica-Bold \
-fill yellow \
@yradunchev
yradunchev / every_other_day.sh
Last active December 10, 2015 11:29
I need a way to remember to take my vitamin D supplement every other day and my vitamin E supplement every day... so... :)
alias supplements='[ $[ $((10#`date +%j`)) % 2 ] -eq 0 ] && echo "Take E" || echo "Take E & D3"'
@yradunchev
yradunchev / clis
Last active December 12, 2015 01:18
various command lines for various tasks...
# take snapshot with ffmpeg
ffmpeg -ss 00:01:22 -t 1 -i <inputfile> -f mjpeg <outputfile>
# read configs
sed '/ *#/d; /^ *$/d' apache2
# distance and time from my rundiary, last seven day - http://yordan.radunchev.com/running/rundiary
curl -s http://yordan.radunchev.com/running/rundiary | \
awk -F"," 'NR>2&&$NR<10{km+=$2; split($3, t, ":"); sum+=60*60*t[1]+60*t[2]+t[3]}END{print km/1000, strftime("%T",sum,1)}'
@yradunchev
yradunchev / fix_curl_60_sles
Created February 24, 2013 17:02
Workaround for curl error "60" when activating SLES over YaST2 control center... "Execute curl command failed with '60': curl: (60) SSL certificate problem, verify that the CA cert is OK"
# mv /usr/bin/curl /usr/bin/curl.bin
# cat > /usr/bin/curl
#!/bin/bash
curl.bin -k $*
[CTRL+D]
# chmod 755 /usr/bin/curl
Fire YaST2, activate SLES, then:
@yradunchev
yradunchev / pdf2jpg.sh
Last active December 17, 2015 14:59
Convert multi-page pdf to jpeg 1. Save this to file.sh and 'chmod +x file.sh' 2. Run as ./file.sh ./path/to/your.pdf
#!/bin/bash
PDF=$1
convert ${PDF} pages.png
convert pages-* -append ${PDF}.jpg
rm pages-*
@yradunchev
yradunchev / onchange.sh
Last active December 24, 2015 13:28 — forked from senko/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@yradunchev
yradunchev / drinkup!
Created December 31, 2013 08:14
Party Russian roulette for geeks and nerds: 1. Run. 2. Hit any key. 3. Drink Up! what is on screen. 4. Hit any key to continue... 5. Go to 2.
10:11:19 yradunchev:~ $ while :;do clear;echo -e 'beer\nwine\nwhiskey\nvinegar' | sort -R | head -1 | figlet -tc; read -t .01 -n 1 && read -n 1; done