Skip to content

Instantly share code, notes, and snippets.

View jonathansanchez's full-sized avatar
🏠
Working from home

Jonathan Sánchez jonathansanchez

🏠
Working from home
View GitHub Profile
@jonathansanchez
jonathansanchez / Regiones_Comunas.sql
Created December 26, 2017 19:59
Regiones y Comunas de Chile
CREATE TABLE `region` (
`code` int(11) NOT NULL,
`name` char(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE `comuna` (
`name` char(255) DEFAULT NULL,
`region` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@jonathansanchez
jonathansanchez / mandril.php
Created January 8, 2018 19:35
How to use Handlebars in Mandrill PHP
<?php
//This API https://bitbucket.org/mailchimp/mandrill-api-php
require_once 'mandrill-api-php/src/Mandrill.php';
function send($data) {
try {
$mandrill = new Mandrill('YOUR_API_KEY');
$message['to'][] = array(
@jonathansanchez
jonathansanchez / callbak.php
Created February 19, 2018 20:04
Example: html button to get contacts from Outlook/Live/Hotmail in Graph Outlook
<?php
// initiate cURL resource
$ch = curl_init();
// where you want to post data
$url = "https://login.microsoftonline.com/common/oauth2/v2.0/token";
curl_setopt($ch, CURLOPT_URL,$url);
// tell curl you want to post something
curl_setopt($ch, CURLOPT_POST, true);
@jonathansanchez
jonathansanchez / Validator.php
Created March 6, 2018 16:46
Server side validation ReCaptcha
<?php
namespace App\Exceptions;
/**
* Class Validator to sanitize
* manually fields from Request.
* @package App\Exceptions
*/
class Validator extends \Exception
@jonathansanchez
jonathansanchez / AjaxController.php
Created March 14, 2018 18:14
Send AJAX POST file on Laravel
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ActivationPostPagoController extends Controller
{
.
.
@jonathansanchez
jonathansanchez / examplePredis.php
Created May 25, 2018 13:50
Basic Example Predis
<?php
require "predis/autoload.php";
PredisAutoloader::register();
try {
$redis = new PredisClient();
/**
* Por defecto conecta así, por lo que no es necesario agregar esta info.
*
@jonathansanchez
jonathansanchez / LaravelLogger.php
Last active July 19, 2018 16:12
Passing Request object to Infrastructure Service on Laravel 5.4
<?php namespace App\Infrastructure\Logging\Laravel;
use App\Infrastructure\Logging\Logger;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
final class LaravelLogger implements Logger
{
/** @var Request */
private $request;
<?php
final class Rut {
/**
* Check a valid Rut
* @param string $rut
* @return boolean
*/
public static function validate(string $rut): bool

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@jonathansanchez
jonathansanchez / TestController.php
Last active September 9, 2019 12:26
Receive post json from request on silex
<?php
final class TestController extends SomeBaseController
{
private $someService;
public function __construct(SomeService $someService)
{
parent::__construct($someService);
$this->someService = $someService;