Skip to content

Instantly share code, notes, and snippets.

View innocenzi's full-sized avatar
🦋

Enzo Innocenzi innocenzi

🦋
View GitHub Profile
@innocenzi
innocenzi / test.ts
Last active April 15, 2021 13:58
TypeScript or JavaScript?
// If this code is transpiled by the TypeScript compiler, it will echo "You are using TypeScript"
// If this code is ran as-is, it will echo "You are using JavaScript"
console.log(new Set<String>('1') ? 'You are using TypeScript' : 'You are using JavaScript')
// This is actually valid JavaScript code: properly formatted, it looks like that:
// (new Set) < (String) > ('1')
// In TypeScript, the angle brackets after Set are interpreted as generic types, which is why the result is different.
@innocenzi
innocenzi / sort.js
Created November 4, 2020 19:05
Sort Google search result per domain
const priority = ['mozilla.org'];
const blocklist = ['w3schools'];
const resultNode = document.getElementById('rso');
// Sort results
const sorted = [...resultNode.children]
.filter((child) => {
const href = child.querySelectorAll('a')?.[0]?.href;
@innocenzi
innocenzi / .php_cs
Created September 23, 2020 08:59
Configurations pour Prettier et CS Fixer
<?php
$finder = PhpCsFixer\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
@innocenzi
innocenzi / upload.sh
Last active September 22, 2020 14:30
Clipboard to Imgur
#!/usr/bin/env bash
errors=false
screenshot_path=/tmp/screenshot.jpeg
default_client_id=c9a6efb3d7932fd
client_id="${IMGUR_CLIENT_ID:=$default_client_id}"
# Save as a file
xclip -se c -t image/jpeg -o > $screenshot_path 2>/dev/null
@innocenzi
innocenzi / Flashes.vue
Created August 20, 2020 14:34
Inertia flashes component
<template>
<section
:class="[
'mb-16 mx-16',
'absolute inset-x-0 bottom-0 z-50',
'flex justify-center',
'transition-opacity duration-1000',
!hasFlashes && 'opacity-0',
]"
>
@innocenzi
innocenzi / custom.css
Last active January 27, 2023 13:14
Visual Studio Code custom CSS
.title.breadcrumbs {
display: none !important;
}
.window-title {
visibility: hidden !important;
}
.monaco-editor .scroll-decoration,
.scroll-decoration {
const { flags } = require('@oclif/parser');
module.exports = {
actions: () => [],
parse: () => ({
flags: {
auth: flags.boolean({ char: 'f' }),
},
args: [
{
function withAlphaVariable({ color, property, variable }) {
if (_.isFunction(color)) {
return {
[property]: color(variable),
}
}
try {
const [r, g, b, a] = toRgba(color)
@innocenzi
innocenzi / box-shadow buttons
Last active March 5, 2020 17:41
box-shadow with same colors as their borders with Tailwind
<div class="mr-4 p-4 rounded-lg border-2 font-bold text-white bg-red-300 border-red-400 shadow-button">border-red-400 shadow-button</div>
<div class="p-4 rounded-lg border-2 font-bold text-white bg-blue-300 border-blue-400 shadow-button">border-blue-400 shadow-button</div>
@innocenzi
innocenzi / output.css
Created October 26, 2019 18:41
Tailwind touch-actions
.touch-none {
touch-action: none;
}
.touch-auto {
touch-action: auto;
}
.touch-pan-x {
touch-action: pan-x;