Skip to content

Instantly share code, notes, and snippets.

View valchonedelchev's full-sized avatar

Valcho Nedelchev valchonedelchev

View GitHub Profile
@valchonedelchev
valchonedelchev / bubble sort.go
Created July 18, 2020 12:43
Bubble sort implementation in Go using optimised algorithm from https://en.wikipedia.org/wiki/Bubble_sort
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
@valchonedelchev
valchonedelchev / orvibo-get-key.sh
Created February 1, 2018 10:46
Extract Orbivo key
#!/bin/bash
TMP_KEPLER_APK=$(mktemp)
echo Downloading the Kepler APK from orvibo.com into $TMP_KEPLER_APK ...
wget http://www.orvibo.com/software/android/kepler.apk -qO $TMP_KEPLER_APK
echo Download complete. Extracting and searching for the key. The key should be displayed below.
echo
ORVIBO_KEY=$(unzip -p $TMP_KEPLER_APK classes.dex | strings | grep -e '^[A-Za-n1-9]\{16\}$')
if [[ ! -z "$ORVIBO_KEY" ]]
then
@valchonedelchev
valchonedelchev / image-orientation.pl
Created November 12, 2016 22:23
Get image orientation in Perl using Image::Magick
use Image::Magick;
sub get_image_orientation {
my $file = shift;
my $image = Image::Magick->new;
$image->Read($file);
my $w = $image->Get('width');
my $h = $image->Get('height');
@valchonedelchev
valchonedelchev / image-orientation
Created November 11, 2016 12:27
Detect image orientation based on image size and prints it out
#!/bin/bash
# File: /usr/bin/local/image-orientation
test=$(convert $1 -format "%[fx:(w/h>1)?1:0]" info:)
if [ $test -eq 1 ]; then
echo horizontal
else
echo vertical
fi
@valchonedelchev
valchonedelchev / jpgtopdf
Created September 9, 2016 08:57
JPG to PDF automation
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use Path::Tiny;
use File::Basename;
foreach my $jpg (path(".")->children(qr/\.jpg$/)) {
@valchonedelchev
valchonedelchev / gist:35d66c0bbb5ab508d17c
Last active August 29, 2015 14:01
Dodgson doublets puzzle
#!/usr/bin/env ruby
#
# ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
# PriorityQueue (0.1.2)
#
# Author: Valcho Nedelchev
#
require 'priority_queue'
#!/usr/bin/env ruby
require 'net/http'
require 'json'
def http_get(url)
puts "http_get: #{url}"
return Net::HTTP.get(URI(url))
end
def handle_http(response, url)