Skip to content

Instantly share code, notes, and snippets.

Avatar
🐝
Happy.

Linus Juhlin Juhlinus

🐝
Happy.
View GitHub Profile
View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/linusjuhlin/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@Juhlinus
Juhlinus / OrganizationsController.php
Last active Jul 7, 2020
A more elegant way to handle validation in Inertia.js
View OrganizationsController.php
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreOrganization;
use App\Organization;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request;
use Inertia\Inertia;
@Juhlinus
Juhlinus / OrganizationsController.php
Last active Jul 1, 2020
app/Http/Controllers/OrganizationsController.php
View OrganizationsController.php
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreOrganization;
use App\Organization;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request;
use Inertia\Inertia;
@Juhlinus
Juhlinus / Create.vue
Last active Jun 30, 2020
Organizations/Create.vue
View Create.vue
<template>
<div>
<h1 class="mb-8 font-bold text-3xl">
<inertia-link class="text-indigo-400 hover:text-indigo-600" :href="route('organizations')">Organizations</inertia-link>
<span class="text-indigo-400 font-medium">/</span> Create
</h1>
<div class="bg-white rounded shadow overflow-hidden max-w-3xl">
<form @submit.prevent="submit">
<div class="p-8 -mr-6 -mb-8 flex flex-wrap">
<text-input v-model="form.name" :errors="$page.errors.name" class="pr-6 pb-8 w-full lg:w-1/2" label="Name" />
@Juhlinus
Juhlinus / Mocking configs.md
Created Apr 17, 2020
Using config helper for testing
View Mocking configs.md

Did you know that you can "mock" configs in Laravel?

You might've already used this when altering config values during runtime, but it proves to be of great use during testing.

Maybe you want to test your login with a different hashing driver temporarily?

    /** @test */
    public function it_uses_the_argon_hashing_driver_instead()
    {
        config(['hashing.driver' => 'argon']);
 
@Juhlinus
Juhlinus / InfiniteScroll.vue
Created Feb 13, 2020
Infinite Scroll in InertiaJS + Vue
View InfiniteScroll.vue
<template>
<div>
<ul>
<li v-for="product in products_data" class="py-6">
<inertia-link :href="'products/' + product.id">{{ product.name }}</inertia-link>
</li>
</ul>
</div>
</template>
View Group PHP Debug Bar Queries By Duration.js
(function() {
if ($('.sort-queries-by-time').length == 0) {
$('.phpdebugbar-widgets-sqlqueries .phpdebugbar-widgets-status')
.append('<a class="sort-queries-by-time" style="padding: 2px 11px 2px 7px;margin-right: 5px;margin-top: -1px;border-radius: 5px;text-transform: uppercase;font-weight: bold;color: #ffffff;font-size: 11px;background: #f4645f;box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);float: right;line-height: 1.8em;">✌ Duration</a>');
}
function parseToMicroSeconds(time) {
var format = time.replace(/[0-9]/g, '').replace('.', '');
View Class usage without \
(\s(?!\\)([A-Z\\a-z]+::))|(new(\s(?!\\))[A-Z\\a-z]+)
View Group PHP Debug Bar Queries By Duplicates.js
(function() {
if ($('.sort-queries-by-time').length == 0) {
$('.phpdebugbar-widgets-sqlqueries .phpdebugbar-widgets-status')
.append('<a class="sort-queries-by-time" style="padding: 2px 11px 2px 7px;margin-right: 5px;margin-top: -1px;border-radius: 5px;text-transform: uppercase;font-weight: bold;color: #ffffff;font-size: 11px;background: #f4645f;box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);float: right;line-height: 1.8em;">✌ Group</a>');
}
function groupBy(list, keyGetter) {
const map = new Map();
list.forEach((item) => {