Skip to content

Instantly share code, notes, and snippets.

View angeorg's full-sized avatar

Anton Georgiev angeorg

View GitHub Profile
0x518BC8e39Fb0288Bf84c699579ce1D0cF7bEaa7D
0x3BF0C38e8cfA6ba2463BeEeEb6605c15BC918425
<!DOCTYPE html>
<html>
<head>
<title>NodeJS - Task 2</title>
<meta charset="UTF-8">
<style>
body { margin: 0px; }
#tripio { background-color: #f1f1f1; }
</style>
</head>
function beerAndFries(items)
{
var beers = [], fries = [], score = 0;
for (var x in items)
{
if (items[x].type === 'beer')
beers.push(items[x].score);
else
fries.push(items[x].score);
}
@angeorg
angeorg / gist:5543384
Created May 8, 2013 20:26
Mark PHP Cipher
<?php
/**
* This file contains PHP classes that can be used to crypt/decrypt strings.
* The encryption/decryption method is based on the Caesar cihper.
*
* (C) 2013 Anton Georgiev (http://github.com/angeorg/). All rights reserved.
* This work is licensed under a Creative Commons Attribution 3.0 Unported License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/
*/
interface MarcActions
@angeorg
angeorg / gist:5427655
Last active December 16, 2015 11:29
Gearman small queries processor
<?php
class QueryWorker extends Worker
{
public $numbers;
public $numbers_per_query = 10;
public function write_action($job)
{
$this->numbers[] = $job->workload();
@angeorg
angeorg / gist:5427624
Created April 20, 2013 22:10
Gearman basic worker structure
<?php
class Worker
{
public function __construct($host, $port)
{
$this->worker = new GearmanWorker();
$this->worker->addServer($host, $port);
echo 'Waiting for work...' . PHP_EOL;
}
@angeorg
angeorg / gist:5296720
Last active December 15, 2015 17:29
Sort big files with less memory usage using Bash
#!/bin/bash
big_file="big.txt"
# Create folders if they don't exist
mkdir -p parts/ sorted/
# Split the file into pieces, 5 MB each
@angeorg
angeorg / gist:5191585
Last active December 15, 2015 02:59
// Write functions for working with shapes in standard Planar coordinate system // Points are represented by coordinates P(X, Y) // Lines are represented by two points, marking their beginning and ending // L(P1(X1,Y1),P2(X2,Y2)) // Calculate the distance between two points // Check if three segment lines can form a triangle
galileo = new Object();
galileo.points = new Array();
galileo.lines = new Array();
galileo.add_point = function(x, y)
{
this.points.push({'x': x, 'y': y});
}