Skip to content

Instantly share code, notes, and snippets.

View Juhlinus's full-sized avatar
🐝
Happy.

Linus Juhlin Juhlinus

🐝
Happy.
View GitHub Profile
# 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 July 7, 2020 09:40
A more elegant way to handle validation in Inertia.js
<?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 July 1, 2020 19:53
app/Http/Controllers/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 June 30, 2020 18:12
Organizations/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 April 17, 2020 07:49
Using config helper for testing

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 February 13, 2020 09:46
Infinite Scroll in InertiaJS + 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>

Hello

Test

(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('.', '');
@Juhlinus
Juhlinus / Class usage without \
Created September 11, 2019 11:37
Class usage without \
(\s(?!\\)([A-Z\\a-z]+::))|(new(\s(?!\\))[A-Z\\a-z]+)
(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) => {