Skip to content

Instantly share code, notes, and snippets.

View rodrigopedra's full-sized avatar

Rodrigo Pedra Brum rodrigopedra

  • São Carlos, Brazil
View GitHub Profile
@rodrigopedra
rodrigopedra / AppServiceProvider.php
Last active February 8, 2023 23:16
Laravel 8 Job Rate Limiter that can be used without Redis
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiter;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
<template>
<!-- ... -->
</template>
<script>
export default {
// ...
beforeRouteLeave (vm, options, event) {
// vm will now refer to this component instead of the link
return window.confirm(vm.$trans('ticket.confirm_leave_creation'));
@rodrigopedra
rodrigopedra / firefox-developer-edition.md
Created February 6, 2020 19:43 — forked from mahammad/firefox-developer-edition.md
How To install Firefox Developer Edition and create desktop icon for Ubuntu 14.04 LTS

chose other install way

  1. Open Terminal Ctrl+Alt+T Download Firefox Developer Edition tar file

    wget https://download.mozilla.org/?product=firefox-aurora-latest-ssl&os=linux64&lang=en-US

  2. Copy tar file to opt sudo cp -rp firefox-35.0a2.en-US.linux-x86_64.tar.bz2

  3. Open opt folder (cd /opt/) and untar file sudo tar xjf firefox-35.0a2.en-US.linux-x86_64.tar.bz2

@rodrigopedra
rodrigopedra / MigrateTenant.php
Last active April 29, 2020 21:58
Laravel Tenant Migration commands
<?php
namespace App\Console\Commands;
use App\Models\Tenants\Tenant;
use Illuminate\Support\Facades\DB;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\Console\Migrations\MigrateCommand;
class MigrateTenant extends MigrateCommand
const AssetsManager = {
name : 'AssetsManager',
template : '#assets-manager-template',
components : { ImageForm, LinkForm },
data () {
return {
showImageForm : false,
@rodrigopedra
rodrigopedra / vue-parent-child.blade.php
Last active November 20, 2018 12:52
Render Vue child components with Laravel Blade
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</head>
<body>
<div id="app">
<parent-component inline-template>
<ul>
@rodrigopedra
rodrigopedra / index.html
Last active May 31, 2022 23:51
Rotate and scale image around its center using canvas
<html>
<head>
<style>
body {
background-color: #ccc;
}
</style>
</head>
<body>
<canvas id="box" width="500" height="500"></canvas>
@rodrigopedra
rodrigopedra / BelongsToManyInDifferentConnections.php
Created June 22, 2018 17:29
Laravel BelongsToMany in different connections
<?php
namespace App\Models;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class BelongsToManyInDifferentConnections extends BelongsToMany
@rodrigopedra
rodrigopedra / gist:a64f27f4124d694e85809b68b93acd36
Created October 24, 2017 13:40 — forked from ctrl-freak/gist:2419528
PHP Uploaded File Mimetype Detection
<?
if (check_file_type() && filesize($_FILES['file']['tmp_name']) < 2000000) {
submit();
} else {
display_form('Invalid file type, please upload files in Microsoft Word, OpenOffice or Adobe PDF format and keep them less than 2MB. If you are having trouble, please upload your document as RTF (Rich Text Format)');
}
@rodrigopedra
rodrigopedra / luhn.js
Created October 25, 2016 07:38 — forked from ShirtlessKirk/luhn.js
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,