Skip to content

Instantly share code, notes, and snippets.

@olavocneto
olavocneto / zf2 create module
Created September 25, 2012 14:31
command to create the folder structure of a module in zf2
cd project
cd module
mkdir -pv NameOfModule/{config,src/NameOfModule/{Controller,Form,Model},view/nameOfModule}
or
mkdir -pv NameOfModule/{config,src/NameOfModule/{Controller,Form,Entity,Mapper,Service},view/nameOfModule}
@olavocneto
olavocneto / isset function.php
Created November 10, 2012 01:47
In expression (expr1) ? (expr2) : (expr3), if not set expre2 and expr1 is true then print 1 when echo usage.
<?php
$var = "string";
echo isset($var) ? : 'ooh'; // 1
//echo isset($var) ? : ; // Parse error: syntax error, unexpected ';'
var_dump(isset($var) ? : 'ooh'); // boolean true
@olavocneto
olavocneto / swap.py
Created December 11, 2012 12:32
Esse swap do python é muito louco!
#!/usr/bin/env python
S[i], S[j] = S[j], S[i] # swap
sudo phpbrew install 5.3.3 +default +dbs +intl +openssl +mcrypt +intl -- --with-curl
sudo phpbrew install 5.4.45 +default +dbs +apxs2 +intl +openssl +mcrypt -- --with-curl
sudo phpbrew install 5.5.38 +default+dbs+apxs2+intl+openssl+mcrypt+iconv+zip+zlib -- --with-curl --enable-opcache --enable-soap
sudo phpbrew install 5.6.36 +default+dbs+apxs2=/usr/bin/apxs2+intl+openssl+mcrypt+iconv+zip+zlib+gd -- --with-gd --with-curl --with-gettext --enable-opcache --enable-soap
sudo phpbrew install 7.0.13 +default+dbs+apxs2+intl+openssl+mcrypt+iconv+zip+zlib+fpm+gd -- --with-gd --with-curl --enable-soap --enable-fpm --enable-zip
mkdir -pv nameOfModule/src/NameOfModule/{Controller,Model,Provider,Service,views}
mkdir -pv src/Financial/module/nameOfModule/src/nameOfModule/{Application,Business,Command,Controller,Definition,Entity,EventListener,Form,Mapper,Provider,Report,Service,Validator}

git

# Deletar várias branches de uma vez só
git branch -d `git branch | grep hotfix*`

# Deletar todas branches que já foram mescladas
git branch --merged | egrep -v "(^\*|master|dev|wip)" | xargs git branch -d

# to remove all branches which are no longer on remote
@olavocneto
olavocneto / regex.txt
Last active June 2, 2017 20:36
regex.txt
Como substituir atributo com valor sendo uma string com aspas simples com qualquer texto dentro.
attibuteName: '(.*)',
exemplo: defaultFocus: 'username',
Recursos
- https://github.com/dmikalova/sublime-cheat-sheets/blob/master/cheat-sheets/Regular%20Expressions.cheatsheet
@olavocneto
olavocneto / sencha_cmd.txt
Last active August 29, 2015 14:06
Install Sencha CMD
Da série: Como eu instalei ...
Dependências
* sudo apt-get install unzip
* Install Java: https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
wget http://cdn.sencha.com/cmd/5.0.1.231/SenchaCmd-5.0.1.231-linux-x64.run.zip
unzip SenchaCmd-5.0.1.231-linux-x64.run.zip
@olavocneto
olavocneto / mongo.sh
Last active August 29, 2015 14:06
mongo help
# Connect meteor server mongo database
mongo 127.0.0.1:3001/meteor
# Connect local mongo database
mongo 127.0.0.1:27017/meteor
mongodump -h 127.0.0.1:3001 -d meteor -o dump/meteor/
mongorestore -u client -h production-db-b1.meteor.io:27017 -d db_meteor_com -p 'xyz' dump/meteor/

Objetivo?

Atualizar dashboard. Quando houver modificação em duas tabelas, foo e bar, então fazer front end requisitar novamente api.

Possível solução: index.html: Abro um socket.

  var conn = new WebSocket('ws://localhost:8080/push-dashboard');
 conn.onopen = function(e) {