Skip to content

Instantly share code, notes, and snippets.

View sebastiaanluca's full-sized avatar
👋

Sebastiaan Luca sebastiaanluca

👋
View GitHub Profile
@lepikhinb
lepikhinb / vite-watcher-runner.ts
Last active December 26, 2022 21:27
Vite plugin to run custom commands on file changes
// the plugin requires a `minimatch` dependency installed
// npm i -D minimatch
import { PluginOption } from "vite"
import { exec } from "child_process"
import minimatch from "minimatch"
import path from "path"
import chalk from "chalk"
export default function watch(config: {
@sebastiaanluca
sebastiaanluca / CarbonImmutableCaster.php
Last active March 24, 2024 14:39
Lazy Laravel Harvest API service
<?php
declare(strict_types=1);
namespace App\DataTransferObjects;
use Carbon\CarbonImmutable;
use Spatie\DataTransferObject\Caster;
class CarbonImmutableCaster implements Caster
@ryangjchandler
ryangjchandler / README.md
Last active September 25, 2023 23:56
Tailwind Palette to CSS Variables

Tailwind Shades to CSS Variables

This script can be used to generate a set of CSS variables from a Tailwind shades object.

Overview

Let's say you have the following JavaScript object. You might have generated such an object on a site such as Tailwind Shades.

{
@barryvdh
barryvdh / HttpClientEventsMiddleware.php
Created September 7, 2021 12:52
Middleware to log Guzzle requests with Telescope
<?php
namespace App\Http\Client;
use GuzzleHttp\Promise;
use Illuminate\Http\Client\Events\ConnectionFailed;
use Illuminate\Http\Client\Events\RequestSending;
use Illuminate\Http\Client\Events\ResponseReceived;
use Illuminate\Http\Client\Request;
use Illuminate\Http\Client\Response;
@IanColdwater
IanColdwater / twittermute.txt
Last active April 3, 2024 19:43
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@akoepcke
akoepcke / .bash_profile
Created August 31, 2018 08:11
composer-link()
// Require local folder as Composer dependency
// whereas _package_ is a unique package ID to keep composer from overwriting existing config
//
// from within the project folder, run the following:
// composer-link /path/to/package package
// Then run composer require as usual.
composer-link() {
composer config repositories."$2" '{"type": "path", "url": "'$1'"}' --file composer.json
}
@ninjaparade
ninjaparade / .postcssrc.js
Created August 30, 2018 18:31
Purge CSS in vue cli app
const tailwindcss = require('tailwindcss')
const purgecss = require('@fullhuman/postcss-purgecss')
const autoprefixer = require('autoprefixer')
const postcssImport = require('postcss-import')
module.exports = {
plugins: [
postcssImport,
tailwindcss('./tailwind.js'),
purgecss({
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@HerrBertling
HerrBertling / cssnext-preset-env.md
Last active January 23, 2022 17:35
CSSNext to postcss-preset-env

My team found it rather hard to determine which stage to use – or whether it would be easier to stay with a certain stage and enable some features specifically.

So I ended up with a table of postcss-cssnext features, their postcss-preset-env counterparts (where I knew the option name) and the stage for each feature.

Here you go:

@vernalkick
vernalkick / ember_exporter.rb
Last active September 30, 2021 20:20
Ember Exporter
#!/usr/bin/env ruby
# Input arguments
source_path = ARGV[0]
destinationPath = ARGV[1] || '~/Desktop/ember_backup'
# Creade destination directory if it doesn't exist
`mkdir -p #{destinationPath}`
# Find the embersnaps in the directory and count them