Skip to content

Instantly share code, notes, and snippets.

View bengitiger's full-sized avatar
🐶
I may be slow to respond.

Bengi bengitiger

🐶
I may be slow to respond.
View GitHub Profile
@mirkonasato
mirkonasato / angular2-starter.md
Last active April 12, 2017 19:08
Angular 2 with Webpack Project Setup - Code Snippets
@elraghifary
elraghifary / cart.sql
Last active October 6, 2017 15:26
cart database for Codecourse
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: May 28, 2016 at 08:16 AM
-- Server version: 10.1.9-MariaDB
-- PHP Version: 5.6.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@bayareawebpro
bayareawebpro / intervention-image-placeholder.php
Last active November 24, 2018 14:17
FontAwesome SVG, Custom Fonts and Shapes.
<?php
//Intervention Image Package:
//http://image.intervention.io
Route::get('generate', function(){
$text = 'image/jpg';
$width = 1600;
$height = 1000;
$centerH = $width/2;
Validator::extend('youtube', function ($attribute, $value, $parameters, $validator) {
return preg_match("/(youtube.com|youtu.be)\/(watch)?(\?v=)?(\S+)?/", $value);
}, "Sorry, this doesn't look like a valid youtube URL");
// Make sure to put this at the top of your AppServiceProvider: use Illuminate\Support\Facades\Validator;
Validator::extend('youtube', function ($attribute, $value, $parameters, $validator) {
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $value, $matches);
return count($matches) > 0;
}, "Sorry, this doesn't look like a valid youtube URL");
@pranildasika
pranildasika / gist:2964211
Created June 21, 2012 06:26
Virtual fields using getter and setter methods in sequelize
var Sequelize = require('sequelize')
var sequelize = new Sequelize('sequelize_test', 'root')
//Note that the model definition does not have "fullName"
var User = sequelize.define('User', {
email: Sequelize.STRING,
firstName: Sequelize.STRING,
lastName: Sequelize.STRING,
},
{
@psychonetic
psychonetic / CustomVeeValidator
Last active April 4, 2020 07:02
Vue-Dropzone and Vee-Validate
// Custom Validator to add errors into vuex store and also handle laravel form errors.
import { mapGetters } from 'vuex';
import { CLEAR_FORM_ERRORS, ERROR } from '../vuex/types';
import Vue from 'vue';
export default {
data() {
return {
errors: [],
keepServerErrors: ['unique', 'boolean', 'exists', 'regular_chars', 'identifier', 'date'],
@kijin
kijin / ezpdo.php
Last active March 23, 2021 18:28
Easy PDO wrapper class
<?php
/**
* Easy PDO for PHP 5.x
* Version 1.2
*
* Copyright (c) 2009-2014 Kijin Sung <kijin@kijinsung.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@cballou
cballou / laravel-global-exception-handler.php
Last active September 12, 2021 10:45
Global handling of Laravel exceptions to better support AJAX requests.
<?php namespace App\Exceptions;
use Log;
use Mail;
use Config;
use Exception;
use Illuminate\Auth\Access\UnauthorizedException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
@n5i
n5i / encoding.php
Created November 12, 2012 11:51
Encoding detection class
<?php
class Encoding {
protected static $win1252ToUtf8 = array(
128 => "\xe2\x82\xac",
130 => "\xe2\x80\x9a",
131 => "\xc6\x92",
132 => "\xe2\x80\x9e",