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
@bradtraversy
bradtraversy / flutter_setup.md
Last active March 19, 2024 04:59
Flutter dev setup & notes
@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;
@zolotyx
zolotyx / auth.js
Last active March 6, 2023 06:06
Nuxt Auth Redirect Fix
export const isSameURL = (a, b) => a.split('?')[0] === b.split('?')[0]
export const isRelativeURL = u =>
u && u.length && /^\/[a-zA-Z0-9@\-%_~][/a-zA-Z0-9@\-%_~]*[?]?([^#]*)#?([^#]*)$/.test(u)
export default function ({ app }) {
const redirect = function (name, noRouter = false) {
if (!this.options.redirect) {
return
}
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");
@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'],
@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;
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@jasondavis
jasondavis / php_array_table.php
Created June 30, 2016 07:15
PHP Array to HTML Table
<?php
function html_table($data = array())
{
$rows = array();
foreach ($data as $row) {
$cells = array();
foreach ($row as $cell) {
$cells[] = "<td>{$cell}</td>";
}
@mirkonasato
mirkonasato / angular2-starter.md
Last active April 12, 2017 19:08
Angular 2 with Webpack Project Setup - Code Snippets