Skip to content

Instantly share code, notes, and snippets.

View bbrodriges's full-sized avatar

bbrodriges bbrodriges

View GitHub Profile
@bbrodriges
bbrodriges / gearman_monitor.sh
Created April 10, 2014 09:31
Oneliner to continuously monitor Gearman queue
while(true) do ((echo "status"; sleep 0.1) | nc gearman.local 4730); printf "\033[4A"; sleep 3; done

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@bbrodriges
bbrodriges / sentences.php
Last active June 27, 2018 10:29
Simple PHP function to split text by given number of sentences with given length each.
/**
* Simple PHP function to split text by given number of sentences with given length each.
*
* @param string $long_string String of text
* @param int $max_length Maximum length of each sentence. Default: 150
* @param int $max_sentences Maximum number of sentences to return. Default: 10
* @param string $encoding Encoding of input string. Default: 'UTF-8'
*
* @return array
*/
@bbrodriges
bbrodriges / autopu.sh
Created December 30, 2013 05:44
Автоматическая генерация отчетов покрытия кода тестами по номеру задачи в коммитах.
# шаблон конфига phpunit.xml
XMLDUMMY="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<phpunit bootstrap=\"work/tests/TestHelper.php\"
backupGlobals=\"false\"
backupStaticAttributes=\"false\"
colors=\"true\"
processIsolation=\"true\"
verbose=\"true\">
@bbrodriges
bbrodriges / gist:7416842
Created November 11, 2013 17:20
Custom 404 on tumbl.com
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
/* Custom 404 */
$(document).ready(function() {
var page_404 = $("section.post h2 a:contains(Not Found)").length;
if (page_404) {
// you can do magic...
}
});
</script>
@bbrodriges
bbrodriges / gist:5583113
Last active December 17, 2015 08:49
Useful git shortcut
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
function gitacpp() { git add -A; git commit -m "$1" $2; git pull origin $branch_name; git push origin $branch_name; }

Don't Buy the Snake Oil of Beamr Video

You might have heard of Beamr Video, and their impressive claims about reducing video bitrates by "up to 4x, without losing quality". Sounds too good to be true? Well, as a matter of fact, it is.

The Example Videos

The four example videos that Beamr has on their site use very high bitrates - 40-50 Mbps for 1080p video. These are the kind of bitrates you find on Blu-ray discs, whereas with something like Netflix's "SuperHD" you'd only get around ~5.6 Mbps (5800 kbps) 1080p video, and with 720p Netflix video the bitrate is only around ~3.5 Mbps (3600 kbps). If you have watched online streams like these, you'll probably know that they look quite decent. Now, if you look at the Beamr Video examples, you'll notice that even for their "reduced" clips, the bitrates are still around 9 Mbps minimum, and average as high as ~30 Mbps.

At this point, you can probably see the trick that Beamr is trying to pull

@bbrodriges
bbrodriges / gist:4369042
Created December 24, 2012 12:08
Convert UNIX timestamp into human readable time delta. E.g.: 1356354501 -> "10 minutes ago"
def unix_to_delta(self, timestamp):
"""
@type timestamp int
@return str
Converts UNIX timestamp into human readable time delta.
E.g.: "10 minutes ago"
"""
@bbrodriges
bbrodriges / sort1mb.cpp
Created December 2, 2012 10:08 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@bbrodriges
bbrodriges / attrdict.py
Created November 14, 2012 06:43
Dictionary with key/values as attributes
class AttrDict(dict):
""" A dict that allows for object-like property access syntax. """
def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError(name)