Skip to content

Instantly share code, notes, and snippets.

View danielpereirabp's full-sized avatar

Daniel Pereira danielpereirabp

View GitHub Profile
git tag 0.1.0 (criando tag localmente)
git tag -l (listando tags localmente)
git push origin master --tags (adicionando tags no repositório remoto)
git tag -d 0.1.0 (removendo tag localmente)
git push origin :refs/tags/0.1.0 (removendo tag no repositório remoto)
# Mostra o espaço utilizado pela pasta
du -sh /var/www/vhosts
# Mostra as 20 maiores pastas
du -m /usr/share/elasticsearch/ | sort -nr | head -n 20
# Cria um novo usuário sudo
adduser demo
gpasswd -a demo sudo
@danielpereirabp
danielpereirabp / gist:adf93e3af1cf50183787
Created September 2, 2015 14:04
Ubuntu Socks Proxy
ssh -L 8035:localhost:8035 [email protected]
export http_proxy=http://localhost:8035/ https_proxy=http://localhost:8035/
ssh -D 8080 [email protected]
export http_proxy=socks5://127.0.0.1:8080 https_proxy=socks5://127.0.0.1:8080
@danielpereirabp
danielpereirabp / valid_pass.php
Last active October 5, 2015 12:16
PHP PCRE - How to validate complex passwords using regular expressions
<?php
/*
* PHP PCRE - How to validate complex passwords using regular expressions
*/
function valid_pass($candidate) {
if (!preg_match_all('$\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])(?=\S*[\W])\S*$', $candidate))
return FALSE;
return TRUE;
@danielpereirabp
danielpereirabp / README.txt
Last active September 18, 2015 17:20 — forked from mattweber/README.txt
ElasticSearch Multi-Select Faceting Example
This is an example how to perform multi-select faceting in ElasticSearch.
Selecting multiple values from the same facet will result in an OR filter between each of the values:
(facet1.value1 OR facet1.value2)
Faceting on more than one facet will result in an AND filter between each facet:
(facet1.value1 OR facet1.value2) AND (facet2.value1)
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (filter0.sh).
# One liner to stop / remove all of Docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@danielpereirabp
danielpereirabp / vim
Created November 5, 2015 16:50
Comentar e Descomentar no VIM
No caso de comentários de uma unica linha uso o seguinte método
Colocar simbolo de comentario no Inicio da linha
tecla 0 leva-o para o inicio da linha (opcional)
teclas ctrl+v (fica em visual block)
com as teclas direcionais seleciona as linhas a comentar
Shift+i (I maiúsculo)
Um cursor de escrita vai aparecer na primeira linha selecionada- escrever o simbolo de comentario, i.e. '#' ou '//'
selecionar ESC e as linhas vão ficar todas comentadas
<?php
use Mockery as m;
class ProjectRepositoryTest extends TestCase
{
public function testShouldCheckIfIsOwner()
{
$mock = m::mock('CodeProject\Repositories\ProjectRepository[findWhere]');
$mock->shouldReceive('findWhere')->once()->andReturn(true);
var elixir = require('laravel-elixir'),
clean = require('rimraf'),
gulp = require('gulp');
var config = {
bower_path: './bower_components',
assets_path: './assets',
build_path: './public/build'
};
@danielpereirabp
danielpereirabp / busy.interceptor.js
Created February 19, 2016 16:21 — forked from jonaszuberbuehler/busy.interceptor.js
http interceptor using angular-busy to show loading indicator
(function () {
'use strict';
angular
.module('app')
.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push('busyInterceptor');
}])
.factory('busyInterceptor', busyInterceptor);