Skip to content

Instantly share code, notes, and snippets.

View jazlopez's full-sized avatar
🏠

Jaziel Lopez jazlopez

🏠
  • Thermo Fisher Scientific
  • Tijuana, MX
View GitHub Profile
@jazlopez
jazlopez / HOWTO-php7.md
Last active December 24, 2015 20:58
Step by Step for updagrading PHP 7 from previous version.

HOW TO upgrade to PHP 7 from PHP 5.x

Please notice

  • Take into consideration this may break old legacy applications.
  • Syntax changes may be required for old legacy applications.
  • Therefore do not run this in production environment.
  • Instead you need to consider creating a test enviroment using the below instructions.
  • Ubuntu 14.x does not include PHP7 by default. There is not a fixed date on when Ubuntu will include PHP 7 in the official repository.
  • My webserver of choice is nginx over apache. No problem so far using nginx.
  • If you run into problems please read the output from error.
@jazlopez
jazlopez / BackOfficeBaseController.php
Created February 21, 2016 06:35
Abstract BackOffice Base Controller
<?php namespace BackOfficeBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* Class BackOfficeBaseController
* @author Jaziel Lopez <juan.jaziel@gmail.com>
* @package BackOfficeBundle\Controller
*/
abstract class BackOfficeBaseController extends Controller
@jazlopez
jazlopez / serve.sh
Last active February 28, 2016 03:29
Custom amends for PHP 7 FPM | Fix PHP-FPM service path | Fix PHP-FPM socket path
#!/usr/bin/env bash
mkdir /etc/nginx/ssl 2>/dev/null
openssl genrsa -out "/etc/nginx/ssl/$1.key" 1024 2>/dev/null
openssl req -new -key /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.csr -subj "/CN=$1/O=Vagrant/C=UK" 2>/dev/null
openssl x509 -req -days 365 -in /etc/nginx/ssl/$1.csr -signkey /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.crt 2>/dev/null
block="server {
listen ${3:-80};
server_name $1;
@jazlopez
jazlopez / dashboard_layout.html.twig.js
Created March 2, 2016 20:34
Backoffice | handle archive update bulk mode | Add form submit filters
/**
*
* Utility Backoffice Object
*/
window.backoffice = Object.create({
/**
* Getter URL parameters
* @param name
* @returns {string|null}
*/
@jazlopez
jazlopez / upgrade.md
Last active March 5, 2016 02:37
Upgrade node version | OSX

HOWTO: Upgrade local node enviroment version

Manual upgrade

Clean up environment

$sudo npm cache clean -f 

Install node helper identifed by n

@jazlopez
jazlopez / Sanitize.php
Created March 18, 2016 06:57
Simple trim and replace multiple whitespaces from string
/**
*
* Trim and replace multiple whitespaces
* @param $value
*
* @return mixed
*/
public function sanitize($value){
return preg_replace('/\s+/', ' ', trim($value));
@jazlopez
jazlopez / Validations.php
Last active March 19, 2016 03:41
Easy validation with symfony asserts
/** Use contraints **/
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Component\Validator\Constraints\Url;
/** Snapshot of a controller class **/
public function postAction(Request $request)
{
$nameContainsErrors = $this->validator->validate($this->request->get('vendor_name'), new Regex(['pattern' => '/^[a-zA-Za0-9_-\s]+$/']));
$urlContainsErrors = $this->validator->validate($this->request->get('vendor_url'), new Url());
@jazlopez
jazlopez / csv_duplicated_id.sql
Created March 20, 2016 20:42
MYSQL | Comma separated list of ids from duplicated values in a field name
SELECT GROUP_CONCAT(id), EMAIL, COUNT(*) as COUNT
FROM customer
GROUP BY email
HAVING COUNT(*) >= 2;
@jazlopez
jazlopez / scrapy.installation.md
Last active March 27, 2016 08:05
Quick HOWTO installation | [Python's scrapy package](http://scrapy.org) | OSX 10.10.5 | Homebrew

Quick HOWTO installation | Python's scrapy package | OSX 10.10.5 | Homebrew


  • Using homebrew make sure you have all dependencies for python's resolved to prevent any issue from breaking packages.
$brew install python

  • If the previous step was satisfactory then create a generic directory for python's projects
@jazlopez
jazlopez / theme.js
Created March 29, 2016 01:37
theme updates
$(document).ready(function(){
/**
* Proxy
* @type {string}
*/
var proxy = '/wp-content/themes/samples.theme/proxy.php?url=';
/**
* Growl errors