Skip to content

Instantly share code, notes, and snippets.

View xavery's full-sized avatar

Daniel Kamil Kozar xavery

  • Poland
View GitHub Profile
@xavery
xavery / tracklisting.awk
Created January 25, 2014 21:23
an awk script for parsing the output of ffprobe and generating a tracklisting
#!/bin/awk -f
/TITLE/ {
FS=": ";
$0=$0;
Title=$2;
}
/Duration/ {
FS=" ";
$0=$0;
@xavery
xavery / televote.pl
Created May 11, 2014 11:30
a script to aggregate the televote scores from ESC 2014
#!/usr/bin/perl
# run the following script to get all the needed html files for processing :
# for i in AL AM AT AZ BY BE DK EE MK FI FR GE DE GR HU IS IE IL IT LV LT MT MD \
# ME NO PL PT RO RU SM SI ES SE CH NL UA GB;
# do wget -O "$i.html" "http://www.eurovision.tv/page/results?event=1893&voter=$i";
# done
# and put them in the working directory of this script.
use strict;
static int sadd(int a, int b)
{
asm (
"addl %1, %0\n\t"
"jo 1f\n\t"
"jmp 4f\n\t"
"1: js 2f\n\t"
"jmp 3f\n\t"
"2: movl $0x7fffffff, %0\n\t"
"jmp 4f\n\t"
@xavery
xavery / music-years.pl
Created July 25, 2015 10:01
Script to generate a histogram showing the dominating years in your music collection
#!/usr/bin/perl
use warnings;
use strict;
use Audio::TagLib;
use File::Find;
use Statistics::Histogram;
die "Usage : $0 <dir>" unless $ARGV[0] && -d $ARGV[0];
@xavery
xavery / remove-duplicate-files.pl
Created July 25, 2015 12:31
A script that removes duplicate files in its working directory
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
use Digest::file qw(digest_file_hex);
use Cwd;
my %sums;
@xavery
xavery / check-a20.asm
Created July 25, 2015 23:59
A bootloader for x86 demonstrating how to detect if the A20 line is enabled
bits 16
cpu 8086
org 0x7c00
init:
xor ax, ax
mov ss, ax
mov sp, 0x7c00
mov ds, ax
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdexcept>
#include <random>
#include <chrono>
static void usage(const char *progname)
{
std::cerr << "Bogosort : A program implementing the bogosort algorithm.\n";
bits 64
global bubblesort
; void bubblesort(int *data [rdi], size_t size [rsi])
bubblesort:
sub rsi, 1 ; make sure we don't overrun (element+1 is accessed inside the loop)
.loop1:
xor ecx, ecx ; index for .loop2
xor eax, eax ; are we done yet?
.loop2:
bits 64
global factorial
; uint64_t factorial(uint n [edi],bool *valid [rsi])
factorial:
mov [rsi], dword 1 ; assume no overflow until proven otherwise
cmp edi, 1
jbe .ret1
cmp edi, 21
jae .overflow ; result will not fit in a uint64
@xavery
xavery / .gitignore
Last active January 16, 2016 17:27
A DOS program to read binary values and convert them to decimal
*.com
*.lst