Skip to content

Instantly share code, notes, and snippets.

View danielpereirabp's full-sized avatar

Daniel Pereira danielpereirabp

View GitHub Profile
@danielpereirabp
danielpereirabp / AppCoreExtension.php
Last active June 16, 2016 14:47
Symfony2 Custom Configuration
<?php
/**
* application/src/App/CoreBundle/DependencyInjection/AppCoreExtension.php
*
*/
namespace App\CoreBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_PROXY, 'http://user:[email protected]:3128');
cd /home/forge/default
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
composer update fzaninotto/faker --no-interaction --dev --prefer-dist
php artisan migrate:reset
php artisan migrate --force
php artisan db:seed
npm cache clean
npm install
@danielpereirabp
danielpereirabp / swap
Last active March 16, 2016 01:50
Create a Swap File
sudo dpkg-reconfigure tzdata
sudo apt-get update
sudo apt-get install ntp
free
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
@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);
var elixir = require('laravel-elixir'),
clean = require('rimraf'),
gulp = require('gulp');
var config = {
bower_path: './bower_components',
assets_path: './assets',
build_path: './public/build'
};
<?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);
@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
# One liner to stop / remove all of Docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@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).