Skip to content

Instantly share code, notes, and snippets.

@gagomes
gagomes / ceo
Last active August 29, 2015 14:27
A fellow had just been hired as the new CEO of a large high tech
corporation. The CEO who was stepping down met with him privately and
presented him with three numbered envelopes. "Open these if you run up
against a problem you don't think you can solve," he said.
Well, things went along pretty smoothly, but six months later, sales
took a downturn and he was really catching a lot of heat. About at his
wit's end, he remembered the envelopes. He went to his drawer and took
out the first envelope. The message read, "Blame your predecessor."
PLAY RECAP ********************************************************************
build | start compilation -------------------------------------------- 2660.69s
build | Install the build output ------------------------------------- 1302.41s
createxenvm | wait for the apache to be available --------------------- 184.23s
setupbuildroot | install dependencies ---------------------------------- 48.59s
build | configure ------------------------------------------------------ 10.72s
setupbuildroot | install epel-release ----------------------------------- 8.45s
setupbuildroot | clone buildroot ---------------------------------------- 6.90s
fixup | Wait until buildroot VM is effectively halted ------------------- 6.10s
createxenvm | start VM -------------------------------------------------- 2.43s
In [13]: s.xenapi.VDI.get_all_records_where('field "name__label" = "win7.iso"')
Out[13]:
{'OpaqueRef:d10ac97a-137d-3258-dcbf-23d292f96eb7': {'SR': 'OpaqueRef:fca40ee2-08df-0a57-139e-6cce980f621a',
'VBDs': [],
'allow_caching': False,
'allowed_operations': ['copy', 'snapshot'],
'crash_dumps': [],
'current_operations': {},
'is_a_snapshot': False,
'location': 'win7.iso',
@gagomes
gagomes / vimjustify.md
Last active August 22, 2016 17:57
Nano text justify in VIM

(Close approximation)

Install par, e.g: apt-get install par or brew install par

And add the following to your ~/.vimrc

set formatprg=par\ -w80
map  gqip 
@gagomes
gagomes / tag_all_the_repos.md
Last active October 31, 2016 16:13
cron script to create a tags file for all git repositories
for dir in $(find $HOME -type d -name .git); do cd $dir/..; ctags -R . ; done
@gagomes
gagomes / blog_in-memory-patching.md
Last active October 31, 2016 16:04
In memory live patching

tags: linux debugging elf internals

{{ post_title }}

A friend approached me asking how he could go about changing the flow of execution of his program during runtime using a debugger. This sounded interesting because I knew in theory what to do, but had not applied this knowledge since the early to mid 2000s, when problems like these were my playground as a C programmer yearning to learn about system internals. After I gave him a rundown and demo, he asked, What if the binary is stripped? Well, that is slightly different and it is far more complex to put together, but let's give it a go.

@gagomes
gagomes / blog_test-post.md
Created October 31, 2016 16:15
this is a test

test post!

@gagomes
gagomes / gemcat
Last active November 18, 2016 14:49
a util to display the contents of a ruby gemfile
#!/bin/bash
set -u
GEM=$1
if ! echo $GEM | egrep -qi '\.gem$'; then
echo $1 does not end in .gem
exit 1
fi
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <asm-generic/errno-base.h>
#include <errno.h>
@gagomes
gagomes / single-docker-instance.sh
Created January 9, 2017 00:20
single docker instance
#!/bin/bash
NAME=rpmfs
CONTAINER=$(docker ps -q -a --filter name=$NAME)
if test -z "$CONTAINER"; then
docker run --name=$NAME \
-v ${PWD}/../centos/:/data/centos \
-v ${PWD}/../linux:/data/linux \
-v images:/data/images \