This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A list of useful functions snippets */ | |
/** | |
* Create a GUID | |
* @see https://stackoverflow.com/a/2117523/319711 | |
* | |
* @returns RFC4122 version 4 compliant GUID | |
*/ | |
export const uuid4 = () => { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Remove any YT shorts */ | |
[...document.querySelectorAll('ytd-grid-video-renderer')].filter(e => e.querySelector('[overlay-style="SHORTS"]')).forEach(e => e.remove()) | |
/* Remove any videos under 5 minutes (or whatever the number is changed to.) */ | |
const minimumVideoTimeInMinutes = 5;[...document.querySelectorAll('ytd-grid-video-renderer')].map(el => ({el, time: parseInt(el.querySelector('ytd-thumbnail-overlay-time-status-renderer')?.innerText.trim().split(":")[0], 10)})).filter(({el, time}) => isNaN(time) || time < minimumVideoTimeInMinutes).map(({el}) => el.remove()); | |
/* Remove any channels you may not want to see but remain subbed to. (add to list) */ | |
const badList = ['This Morning'];[...document.querySelectorAll('ytd-grid-video-renderer')].map(el => ({el, name: el.querySelector('ytd-channel-name')?.innerText.trim()})).filter(({name}) => badList.includes(name)).forEach(({el}) => el.remove()); | |
/* Remove any videos based on channel name/length */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use PhpCsFixer\Finder; | |
use PhpCsFixer\Config; | |
$finder = Finder::create() | |
->in([ | |
__DIR__.'/app', | |
__DIR__.'/config', | |
__DIR__.'/database', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { onMounted } from 'vue'; | |
import loadMap from './load-google-map'; | |
// In vite env make sure VITE_GOOGLE_MAPS_API_KEY= is defined. | |
onMounted(() => { | |
// Google maps API is not loaded at all | |
await loadMap(); | |
// Google maps API is ready and loaded | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
read -p 'Project folder: ' PROJECT | |
npm init vue@latest -- --router --typescript --pinia --eslint-with-prettier $PROJECT | |
cd $PROJECT | |
npm install -D tailwindcss postcss autoprefixer | |
npx tailwindcss init -p | |
cat << EOF > tailwind.config.js | |
/** @type {import('tailwindcss').Config} */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ] | |
then | |
echo "Please provide installation directory as first parameter e.g. $BASH_SOURCE <dir>" | |
exit 1 | |
fi | |
if [ -d $1 ]; then | |
echo 'Insallation (folder) already exists!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file will initialise and empty .vue files with a basic name and structure. | |
const fs = require("fs"); | |
const { exec } = require("child_process"); | |
exec('find src -type f -iname "*.vue"', (error, stdout, stderr) => { | |
if (error) { | |
console.error(`exec error: ${error}`); | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numbers = [...new Array(59)].map((v,i) => i+1); | |
let picks = [...new Array(6)].map(() => numbers.splice(Math.floor(Math.random() * numbers.length), 1)).sort((a,b) => a-b).join(", ") | |
console.log(picks); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
class AlwaysReturnJson | |
{ | |
/** | |
* Handle an incoming request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$entities = glob("app/Entities/**/*.php"); | |
foreach ($entities as $entity) { | |
$className = str_replace('/', '\\', ucfirst(substr($entity, 0, -4))); | |
$class = new $className; | |
dump($class->getTable()); | |
$columns = collect(DB::select("SHOW COLUMNS FROM `{$class->getTable()}`"))->filter(function ($column) { | |
return !in_array($column->Field, ['id', 'created_at', 'updated_at', 'deleted_at']); |