Skip to content

Instantly share code, notes, and snippets.

@nelsonsar
nelsonsar / commenting.md
Last active December 22, 2015 18:49
Commenting a lot of code with Vim

This is how I comment a lot of code in Vim

    $convenio = formata_numero($dadosboleto["convenio"],6,0,"convenio");
    
    if ($dadosboleto["formatacao_nosso_numero"] == "1") {
        $nossonumero = formata_numero($dadosboleto["nosso_numero"],5,0);
        $dv = modulo_11("$codigobanco$nummoeda$fator_vencimento$valor$convenio$nossonumero$agencia$conta$carteira");
 $linha = "$codigobanco$nummoeda$dv$fator_vencimento$valor$convenio$nossonumero$agencia$conta$carteira";
@nelsonsar
nelsonsar / git_bash_completion.md
Last active December 24, 2015 01:29
Adding git bash completion to OSX
@nelsonsar
nelsonsar / mudancas_vagrantfile.md
Created October 2, 2013 04:10
Mudanças no Vagrantfile na versão 2

Essa é a versão 1 do Vagrantfile:

Vagrant::Config.run do |config|

  config.vm.box = "precise64"
  config.vm.host_name = "cecap"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
  config.vm.share_folder("cecap", "/var/www/cecap", "..", :extra => 'dmode=777,fmode=777')
  config.vm.forward_port 80, 8099
@nelsonsar
nelsonsar / class_explorer.md
Created October 24, 2013 14:51
Open all methods from a class in vim

:vimgrep /on .*(/ % :cw

@nelsonsar
nelsonsar / config.php
Created November 5, 2013 20:52
Sismo simple config
<?php
$projects = array();
$subjectFormat = 'Commit %sha% made %name% became %status%';
$messageFormat = '%author% made commit %sha% and the build status is: %status%';
$notifier = new Sismo\Notifier\MailNotifier('nelson@localhost.com', $subjectFormat, $messageFormat)
@nelsonsar
nelsonsar / chora.php
Created November 6, 2013 18:21
Chora Rubão!
function porra($caralho)
{
foreach ($caralho as $k => $v) {
if ($k == 'article') {
if (isset($v['id']) && $v['id'] == '1002') {
echo 'caralho' . PHP_EOL;
return;
}
}
if (is_array($v)) {
@nelsonsar
nelsonsar / find_key_in_array.php
Last active December 29, 2015 02:49
Rubão, tá aí!
<?php
$where = array(
"productcategory" => array(
"id" => 410,
"productcategorytranslation" => array(
0 => array(
"translation" => "Fahrräder (Profakt)",
"id" => 952106
)
@nelsonsar
nelsonsar / snowflakes.rb
Created December 6, 2013 16:30
Ruby snowflakes. This is not mine... I just found it on http://climagic.org/coolstuff/let-it-snow.html. In Artem Baguinski comment.
ruby -e 'C=`stty size`.scan(/\d+/)[1].to_i;S=["2743".to_i(16)].pack("U*");a={};puts "\033[2J";loop{a[rand(C)]=0;a.each{|x,o|;a[x]+=1;print "\033[#{o};#{x}H \033[#{a[x]};#{x}H#{S} \033[0;0H"};$stdout.flush;sleep 0.1}'
@nelsonsar
nelsonsar / consumer.php
Last active August 29, 2015 13:56
Producer e consumer esperados como resultado no "hands on" da Dafiti Tech Conference 2014
<?php
$connection = new \AMQPConnection(
array(
'host' => '69.195.223.58',
'port' => 5672,
'vhost' => "/",
'login' => "dafitconf",
'password' => "dafiti",
)