Skip to content

Instantly share code, notes, and snippets.

Murilo Pereira mpereira

Block or report user

Report or block mpereira

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
View test_scrubble.rb
require 'test/unit'
require 'test/unit/ui/console/testrunner'
def scrubble(array)
array.dup.inject([]) do |scrubbled, element|
scrubbled << array.reject { |e| e == element }
class ScrubbleTest < Test::Unit::TestCase

If you want to do something like

Then the output should contain "\"bob saget\",1234123412"

This is the step definition you would probably write

Then /^the output should contain "(.*)$" do |text|
  Output.string.should be_include(text)
View madrugao_suplementos_whey_crawler.rb
# encoding: utf-8
# Copyright (C) 2011 by Murilo Pereira <>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
View with_index.rb
battle_cries = [{ king_leonidas: 'This is where we fight! This is where they die!' },
{ he_man: 'By the power of Greyskull... I have the powerrr!' },
{ sindel: 'You are pathetic and weak.' },
{ shang_tsung: 'Your soul is mine!' },
{ klingons: 'Today is a good day to die!' }]
def from_mortal_kombat?(battle_cry)
[:sindel, :shang_tsung].include?(battle_cry.keys.first)

Remove trailing whitespace, convert tabs to spaces and file format to unix (remove ugly ^M carriage returns) from files using a single command:

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' FILES

You could get your FILES using find

vim -es -c 'set et ts=2 | bufdo retab | %s/\s\+$//e | set ff=unix | w' -c 'q' $(find scripts -name '*.sh' -type f)

If in doubt, ask man.

View add_global_gemset_gems_to_load_path.rb
# Add all gems in the global gemset to the $LOAD_PATH so they can be used even
# in bundled ruby projects without declaring them in the Gemfile.
if defined?(::Bundler)
View indicator-foo.c
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>
int main(int argc, char **argv) {
gtk_init(&argc, &argv);
AppIndicator *app_indicator;
app_indicator = app_indicator_new("foo",
mpereira / gist:3072187
Created Jul 8, 2012
A little help to stop unconsciously checking distracting web sites.
View gist:3072187
alias focus="sudo sh -c \"echo ' # aab6de513ab5de9359809f3cdb62d352' >> /etc/hosts\""
alias unfocus='sudo sed -i "" "/aab6de513ab5de9359809f3cdb62d352/d" /etc/hosts'
View glxinfo.txt
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_multisample, GLX_EXT_create_context_es2_profile,
GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info,
GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer,
View Xorg.0.log
[ 7.114]
X.Org X Server 1.13.4
Release Date: 2013-04-17
[ 7.114] X Protocol Version 11, Revision 0
[ 7.114] Build Operating System: Linux 2.6.24-32-xen x86_64 Ubuntu
[ 7.114] Current Operating System: Linux pluto 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:17:05 UTC 2013 x86_64
[ 7.114] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.8.0-27-generic root=UUID=12054a51-399c-4846-a704-1d3fecf982ab ro modprobe.blacklist=xhci_hcd quiet splash vt.handoff=7
[ 7.114] Build Date: 08 May 2013 02:34:03PM
[ 7.114] xorg-server 2:1.13.4~git20130508+server-1.13-branch.10c42f57-0ubuntu0ricotz~raring (For technical support please see
[ 7.114] Current version of pixman: 0.28.2
You can’t perform that action at this time.