Skip to content

Instantly share code, notes, and snippets.

View andreshg112's full-sized avatar
💻
Make it simpler, make it better!

Andrés Herrera García andreshg112

💻
Make it simpler, make it better!
View GitHub Profile
@eduardoromero
eduardoromero / separar_nombres_apellidos.php
Last active December 11, 2023 05:30
Tratando de separar nombres y apellidos de un campo. Se separa el nombre completo por palabras, se procesa cada palabra, si es una palabra que forma parte de un nombre o apellido compuesto se guarda para anexarla hasta el siguiente ciclo. Al final se tiene que tomar una decisión sobre que hacer para separar los nombres si son más de dos. Si son …
<?php
/* separar el nombre completo en espacios */
$tokens = explode(' ', trim($full_name));
/* arreglo donde se guardan las "palabras" del nombre */
$names = array();
/* palabras de apellidos (y nombres) compuetos */
$special_tokens = array('da', 'de', 'del', 'la', 'las', 'los', 'mac', 'mc', 'van', 'von', 'y', 'i', 'san', 'santa');
$prev = "";
@frankdejonge
frankdejonge / Envoy.blade.php
Created August 23, 2014 15:59
Envoy server at a non-standard port
@servers(['web' => 'user@example.com -p 1234'])
@task('deploy', ['on' => 'web'])
ls -la
@endtask
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@chadrien
chadrien / README.md
Last active September 1, 2023 12:43
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@gilbitron
gilbitron / .env.travis
Last active August 12, 2023 08:06
Laravel 5 Travis CI config
APP_ENV=testing
APP_KEY=SomeRandomString
DB_CONNECTION=testing
DB_TEST_USERNAME=root
DB_TEST_PASSWORD=
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync
@gunnarlium
gunnarlium / guzzle-retry.php
Created December 17, 2015 16:23
Example of how to create a retry subscriber for Guzzle 6
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request as Psr7Request;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Psr\Log\LoggerInterface;
const MAX_RETRIES = 2;
@ralph089
ralph089 / .wakeup
Last active February 17, 2024 09:56
Restarts Bluetooth Module on Mac OS X. You can use the script as shortcut to restart Bluetooth on demand or you can use it with "SleepWatcher" to automatically restart Bluetooth on wakeup (See README.md). I created it, because my Logitech Bluetooth Mouse doesn't stay connected after sleep-mode, so i had to manually re-pair my mouse.
#!/bin/bash
#
# Restart Bluetooth Module on Mac OS X
#
# Requires Blueutil to be installed: http://brewformulas.org/blueutil
BT="/usr/local/bin/blueutil"
log() {
echo "$@"
@evanwill
evanwill / dualpythonnotebook.md
Created June 3, 2016 19:16
add more kernels to python 3 jupyter notebooks with anaconda

this assumes you have installed Python 3 via Anaconda distribution.

Make Python 2 kernel available to Jupyter Notebook

  1. open a terminal and create a new python 2 environment: conda create -n py27 python=2.7
  2. activate the environment: linux source activate py27 or windows activate py27
  3. install the kernel in the env: conda install notebook ipykernel
  4. install the kernel for outside the env: ipython kernel install --user
  5. close the env: source deactivate
@vluzrmos
vluzrmos / paginate.php
Created July 20, 2016 14:31
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@shakee93
shakee93 / .htaccess
Created January 31, 2017 17:45
Laravel Apache hide .env and several security settings via .htaccess
# Disable Directory listing
Options -Indexes
# block files which needs to be hidden // in here specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
# in here specify full file name sperator '|'