Skip to content

Instantly share code, notes, and snippets.

View petar-dambovaliev's full-sized avatar
👶

Petar Dambovaliev petar-dambovaliev

👶
  • Somewhere over the rainbow
View GitHub Profile
matchit::foo:
push rbp
mov rbp, rsp
push r15
push r14
push r13
push r12
push rbx
sub rsp, 360
mov rax, qword, ptr, [rip, +, L___unnamed_27]
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $
@petar-dambovaliev
petar-dambovaliev / skew-algorithm.md
Created December 29, 2018 18:33 — forked from markormesher/skew-algorithm.md
The Skew (Linear Time) Algorithm for Suffix Array Construction

The Skew (Linear Time) Algorithm for Suffix Array Construction

I'll use x = "processing" as an example. Throughout the example * represents the null character, which sorts before any other character (i.e. * < a < b < c < ...).

We start by creating three groups of suffixes - S0, S1 and S2 - so that each suffix in the group Sk starts at the index 3q + k for some value of q. In plain English:

  • S0 suffixes start at positions 0, 3, 6, etc.
  • S1 suffixes start at positions 1, 4, 7, etc.
  • S2 suffixes start at positions 2, 5, 8, etc.
@petar-dambovaliev
petar-dambovaliev / grace.go
Created December 7, 2018 10:16 — forked from rcrowley/grace.go
Graceful stop in Go
package main
import (
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"
/*
You will be given a 2D array of the maze and an array of directions.
Your task is to follow the directions given.
If you reach the end point before all your moves have gone, you should return Finish.
If you hit any walls or go outside the maze border, you should return Dead.
If you find yourself still in the maze after using all the moves, you should return Lost.
maze = [[1,1,1,1,1,1,1],
[1,0,0,0,0,0,3],
[1,0,1,0,1,0,1],
@petar-dambovaliev
petar-dambovaliev / DateHelper.js
Created February 28, 2017 10:03
Calculates correct ago times for cached html pages
(function() {
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT"
// and converts it to a relative time
get_ago_time: function(fromDate) {
var from = new Date();
from.setTime(Date.parse(fromDate));
var to = new Date();
var distance_in_seconds = ((to - from) / 1000);
import java.util.EventListener;
import java.util.EventObject;
import javax.swing.event.EventListenerList;
class MyEvent extends EventObject {
public MyEvent(Object source) {
super(source);
}
}
//To work on the page you need :
//div id=canvas
//lookout for your background because the flakes are grey
window.onload = function()
{
var canvas= document.getElementById("canvas");
var context = canvas.getContext("2d");
var width=window.innerWidth;
var height=window.innerHeight;
@petar-dambovaliev
petar-dambovaliev / codes.php
Created August 25, 2016 10:17
Creates random codes
function unique_id($l = 8) {
return substr(md5(uniqid(mt_rand(), true)), 0, $l);
}
$codes = [];
$amount = 10000;
for ($i=0; count($codes) < $amount; $i++){
$code = unique_id();
$codes[$code] = $code;