Skip to content

Instantly share code, notes, and snippets.

View rubemz's full-sized avatar
🏠
Working from home

Rubem Nakamura rubemz

🏠
Working from home
View GitHub Profile
wc -l *.[ch] | grep -v total | sort -rn > /tmp/loc.txt
3696 cluster.c
3560 sentinel.c
3166 redis.c
2219 t_zset.c
1826 replication.c
1819 config.c
1633 redis-cli.c
1557 networking.c
ruby_version="1.9.3-p392"
gem_version="1.8.25"
if [ ! -f /tmp/ruby/bin/ruby ]; then
cd /tmp
rm -f ruby-${ruby_version}.tar.gz
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-${ruby_version}.tar.gz
tar zxvf ruby-${ruby_version}.tar.gz
cd ruby-${ruby_version}
(./configure --prefix=/tmp/ruby && make -j4 && make install) || (echo "Ruby shat the bed" && exit 1)
This tool is used to compare microbenchmarks across two versions of code. It's
paranoid about nulling out timing error, so the numbers should be meaningful.
It runs the benchmarks many times, scaling the iterations up if the benchmark
is extremely short, and it nulls out its own timing overhead while doing so. It
reports results graphically with a text interface in the terminal.
You first run it with --record, which generates a JSON dotfile with runtimes
for each of your benchmarks. Then you change the code and run again with
--compare, which re-runs and generates comparison plots between your recorded
and current times. In the example output, I did a --record on the master
@everaldo
everaldo / municipios.yml
Created April 22, 2014 13:48
Lista de UFs e Municípios, segundo IBGE 2013 (5570 municípios)
---
- :cod_uf: '52'
:uf: Goiás
:city_id: '00050'
:city: Abadia de Goiás
:sigla_uf: GO
:city_code: '5200050'
- :cod_uf: '31'
:uf: Minas Gerais
:city_id: '00104'
@weidenfreak
weidenfreak / gist:3987288
Created October 31, 2012 14:21
Timecop and milliseconds
#
# freezing DateTime.now
#
# in Rails
$ rails c
Loading development environment (Rails 3.2.8)
# DateTime and Time have milliseconds before freezing time
>> DateTime.now.iso8601 9
@jmazzi
jmazzi / import-cache.php
Created March 31, 2016 18:27 — forked from danielbachhuber/import-cache.php
During `wp import`, cache remote files locally for subsequent imports
<?php
/**
* Run with `wp --require=import-cache.php import ...
*/
WP_CLI::add_hook( 'after_wp_load', function(){
// Only intercept HTTP requests when the importer is running
if ( ! defined( 'WP_IMPORTING') || ! WP_IMPORTING ) {
return;
@treble37
treble37 / step1-testing-elasticsearch.rb
Created February 3, 2015 05:46
Step 1 - Testing ElasticSearch - spec_helper.rb
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
@chrismccord
chrismccord / drain_stop.ex
Created May 27, 2016 15:26 — forked from aaronjensen/drain_stop.ex
Phoenix Drain Stop
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.
DrainStop should be installed in your supervision tree *after* the
EndPoint it is going to drain stop.
@paulnicholson
paulnicholson / powssl
Last active November 24, 2021 16:40
ssl with pow using stud

Instructions

  • Install stud $ brew install https://raw.github.com/paulnicholson/homebrew/master/Library/Formula/stud.rb
  • Download and install the powssl script $ curl https://gist.githubusercontent.com/paulnicholson/2050941/raw/7e4d2178e3733bed18fdfe737277c3cb72241d39/powssl > ~/bin/powssl $ chmod +x ~/bin/powssl
  • Run powssl to create development certificate and configure stud.
  • $ powssl
@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)