Skip to content

Instantly share code, notes, and snippets.

View Exadra37's full-sized avatar

Paulo Renato Exadra37

View GitHub Profile
@Exadra37
Exadra37 / laravel-tips.md
Last active December 5, 2017 19:23
Laravel Tips

LARAVEL TIPS

4. Bulk Insert On Duplicate Key Update

<?php
    /**
     * When we want to perform a bulk insert we will not found support for this action in Eloquent or Query Builder
     * To avoid performance issues i have to drop my preference to be database agnostic in my Apps
     * To be used like:
     *     $table   = 'table_name';
@Exadra37
Exadra37 / synchronize-prestashop-fork.sh
Created March 18, 2015 22:46
Maintain your Prestashop fork synchronized / updated with the original repository.
#!/bin/bash
# @author Exadra37 <exadra37ingmailpointcom>
# @since 2015/03/18
# @link exadra37.com
# @see Heavily inspired in http://stackoverflow.com/a/7244456
#
#
# I use this script to update my Prestashop fork when i want to make a contribution
#
@Exadra37
Exadra37 / UserAgentDetector.php
Last active August 17, 2016 05:42
Class to detect the user agent from the global var $_SERVER. Detects if is a bot, spider, crawler based on the HTTP_USER_AGENT and a list of web sniffers names or types.
<?php
/**
* UserAgentDetector
*
* @author Exadra37
* @license Free to use at your own risk. Provided as it is, without any warranty that will work for you.
* @link http://presta-hosting.com
* @version 1.0.1
* @since v.1.0.0 - 09/03/2014
@Exadra37
Exadra37 / command-line-prompt
Created June 7, 2016 13:22
Watch Mysql queries in real time
$> tail -f -n 100 /var/lib/mysql/devint1.log
...
8941 Prepare select * from `stepFeed` where `productId` = ? limit 1
8941 Execute select * from `stepFeed` where `productId` = '764773' limit 1
@Exadra37
Exadra37 / mysql_querys.sql
Created January 28, 2014 20:18
Examples of some raw mysql querys: Insert Into.. On Duplicate Key Update
/**
*
* @author Paulo Silva(Exadra37) exadra37 in gmail point com
* @package Exadra37/Mysql-Examples
* @version 0.0.1
* @since 28/01/2014 - v.0.0.1
*
*/
INSERT INTO stores (storeName, address, phone)
@Exadra37
Exadra37 / getAllColumnsNamesFromMysqlTable.php
Last active January 4, 2016 09:49
This is a function easily convertible into a method to use inside of a class that as the name says, get columns names from mysql table, will return all the columns names from a given table in the provided database. The mysql connection used is the native PHP driver PDO. The difference to other one that i also have here in Gist is that this one u…
<?php
/**
* getAllColumnsNamesFromMysqlTable.php
*
* @author Paulo Silva(Exadra37) exadra37 in gmail point com
* @package exadra37/PDO
* @version 0.0.2
* @since 24/01/2014 - v.0.0.1
* 25/01/2014 - v.0.0.2
@Exadra37
Exadra37 / getColumnsNamesFromMysqlTable.php
Created January 24, 2014 17:21
This is a function easily convertible into a method to use inside of a class that as the name says, get columns names from mysql table, will return all the columns names from a given table in the provided database. The mysql connection used is the native PHP driver PDO.
<?php
/**
*
* @author Paulo Silva(Exadra37) exadra37 in gmail point com
* @package exadra37/PDO
* @version 0.0.1
* @since 24/01/2014
*
*/
@Exadra37
Exadra37 / .vimrc
Last active September 18, 2015 19:43
My personnal Vim Configuration
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set statusline="%f%m%r%h%w [%Y] [0x%02.2B]%< %F%=%4v,%4l %3p%% of %L"
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
set nu
@Exadra37
Exadra37 / Tools.php
Last active September 11, 2015 16:04
Usefull Tools class
<?php
/**
*
* @author Exadra37
* @package exadra37/tools
* @version 1.0.0
* @since 1.0.3 - 19/09/2014
* 1.0.2 - 15/09/2014
* 1.0.1 - 15/09/2014
@Exadra37
Exadra37 / BasicTestCase.php
Created June 4, 2015 14:11
More robust testing for the methods we are testing
<?php
/**
* @author Paulo Silva(Exadra37) <exadra37ingmaildotcom>
* @since 2015/06/04
*/
abstract class BasicTestCase extends PHPUnit_Framework_TestCase // Orchestra\Testbench\TestCase for Laravel
{
/**