Skip to content

Instantly share code, notes, and snippets.

Rafael Garcia-Suarez rgs

Block or report user

Report or block rgs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rgs /
Created Oct 31, 2019
Shows all conjunct consonants in devanagari
use 5.18.2;
use strict;
use warnings;
use open ':std', ':utf8';
print " | ";
for my $c (0x0915 .. 0x0939) {
print chr($c)." | ";
rgs /
Created Apr 30, 2014
A perl function to get the amount of wasted memory on a memcached server
sub wasted_memory {
my ($host, $port) = @_;
my @slabstats = `echo stats slabs | nc $host $port`;
my %perslab;
my $total_malloced = 0;
my $total_wasted = 0;
for (@slabstats) {
if (/STAT total_malloced ([0-9]+)/) {
$total_malloced = $1;
rgs / gist:7370406
Created Nov 8, 2013
A vim status line item to display git branch name and status of the currently edited file. To be put in the ~/.vimrc.
View gist:7370406
" returns a string <branch/XX> where XX corresponds to the git status
" (for example "<master/ M>")
function CurrentGitStatus()
let gitoutput = split(system('git status --porcelain -b '.shellescape(expand('%')).' 2>/dev/null'),'\n')
if len(gitoutput) > 0
let b:gitstatus = strpart(get(gitoutput,0,''),3) . '/' . strpart(get(gitoutput,1,' '),0,2)
let b:gitstatus = ''

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
rgs /
Created Jul 24, 2012
Happy Birthday, BooK !
package Acme::MetaSyntactic::happybirthdaybook;
use strict;
use utf8;
use Acme::MetaSyntactic::Locale;
our @ISA = qw( Acme::MetaSyntactic::Locale );
our $VERSION = '40.0';
=head1 NAME
rgs /
Created Mar 22, 2012
A script to create word clouds from perl's core documentation
use strict;
use warnings;
use File::Slurp;
use Image::WordCloud;
for my $file (<perl*.pod>) {
my $text = `pod2text $file`;
my $wc = Image::WordCloud->new();
my $gd = $wc->cloud();
$file =~ s/od$/ng/;
You can’t perform that action at this time.