Skip to content

Instantly share code, notes, and snippets.

View tralves's full-sized avatar

Tiago Alves tralves

View GitHub Profile
@tralves
tralves / OverrideModuleConfiguration.php
Last active October 31, 2018 17:50
Laravel 5 middleware that overrides pingpong-labs/modules configurations over the app's Config.
<?php
namespace App\Http\Middleware;
/**
* When using pingpong-labs/modules, you may want to override app config when the request is made
* in the context of a module.
*
* This middleware will do that. For example, if the module/MyModule/Config/config.php has the code:
*
@tralves
tralves / ProfileApiTest.php
Last active June 26, 2023 02:32
Override the Authentication when using dingo/api, when testing the Api with PhpUnit.
<?php
use App\Entities\User;
class ProfileApiTest extends TestCase
{
/**
* @test
*
* Get user profile.
@tralves
tralves / TestCase.php
Created July 7, 2016 22:10
Laravel Storage mock test helper
<?php
use Illuminate\Support\Facades\Config;
class TestCase extends Laravel\Lumen\Testing\TestCase
{
/**
* Create a mock of a Storage disk.
*
* Usage:
@tralves
tralves / get_indexdb_sizes.js
Last active March 9, 2024 13:34
Calculate sizes of all IndexDB database and tables
var getTableSize = function(db, dbName){
return new Promise((resolve,reject) => {
if (db == null) {
return reject();
}
var size = 0;
db = event.target.result;
var transaction = db.transaction([dbName])
.objectStore(dbName)
.openCursor();
[
{
"id": 1,
"name": {
"first": "Alfreda",
"last": "Ferreira"
},
"location": {
"street": "4127 Rua Mato Grosso ",
"city": "Bagé",
[
{
"title": "Special Tagliatele al Pomodoro",
"likes": 8093,
"duration": "1:15",
"liked": true
},
{
"title": "Special Ravioli Nero di Sepia al Pomodoro",
"likes": 10435,
{
"windowTitle": "IRC.com - TEST",
"startupOptions.server": "irc.com"
}
<a href="irccom://com.irc.ircclient/register/confirm?a=tiagotest3&c=eEQ78B765">TEST LINK</a>
@tralves
tralves / pretty-scrollbars.css
Created May 28, 2024 15:27
Pretty native scrollbars (webkit and mozilla)
/* Pretty scrollbars */
@-moz-document url-prefix() {
.pretty-scrollbar {
scrollbar-width: thin;
scrollbar-color: rgba(0, 0, 0, 0.5) transparent;
}
}
.pretty-scrollbar {
-ms-overflow-style: none;
}