Skip to content

Instantly share code, notes, and snippets.

View alfredoem's full-sized avatar

Alfredo Espiritu alfredoem

  • Lima/Perú
View GitHub Profile
@alfredoem
alfredoem / laravel-tricks.php
Last active May 17, 2017 16:10
Laravel Framework Tricks
<?php
#Last Query
\DB::enableQueryLog();
// code request
$query = \DB::getQueryLog();
$lastQuery = end($query);
\Log::info(json_encode($lastQuery));
Rename Directory
git rm -rf --cached path/to/your/directories
<!--
BREAKING NEWS: KITTENS FKN LOVE YARN
__ __,
\,`~"~` /
.-=-. / . .\
/ .-. \ { = Y}=
(_/ \ \ \ /
Branch
git checkout -b <branch>
git push -u origin <branch>
Tag
git tag -a <tag> -m "message"
git push origin <tag>
@alfredoem
alfredoem / gulpfile.js
Created June 20, 2016 19:33
Express - Material
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var cssnano = require('gulp-cssnano');
var iconfont = './node_modules/material-design-icons/iconfont';
var roboto = './node_modules/roboto-fontface/fonts';
gulp.task('material-css', function(){
gulp
$(document).on('propertychange input keypress', '.mask-regex', function(e) {
let valueChanged = false;
let self = $(this);
if (e.type=='propertychange') {
valueChanged = e.originalEvent.propertyName=='value';
} else {
valueChanged = true;
}
@alfredoem
alfredoem / helpers.php
Created February 2, 2016 21:59
Helpers
<?php
function uniqueString()// Return a unique string
{
return $customId = strtoupper(uniqid()) . rand(0, 20);
}
@alfredoem
alfredoem / send-email.txt
Created December 9, 2015 21:38
Send email in laravel 5
/*
* Email send function
*/
$nameTo = $request->FirstName . " " . $request->LastName;
$emailTo = $request->email;
$subject = 'Welcome to the jungle!';
try{
\Mail::send("emails.welcome", ['name' => $nameTo, 'email' => $emailTo], function($message) use ($nameTo, $emailTo, $subject){
$message
->to($emailTo, $nameTo)
@alfredoem
alfredoem / input-final-onchange.js
Last active November 19, 2015 15:22
Detecta cada vez que se introduce texto en un input, sea cual sea el medio (copy and paste, drag and drop, etc.)
$(':input').on('propertychange input', function (e) {
var valueChanged = false;
if (e.type=='propertychange') {
valueChanged = e.originalEvent.propertyName=='value';
} else {
valueChanged = true;
}
if (valueChanged) {
/* Code goes here */
@alfredoem
alfredoem / AlohaController.php
Last active November 3, 2015 19:21
Controller for a pdf example
<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class AlohaController extends Controller
{
public function getPdf()