Skip to content

Instantly share code, notes, and snippets.

View janyksteenbeek's full-sized avatar

Janyk Steenbeek janyksteenbeek

View GitHub Profile
@janyksteenbeek
janyksteenbeek / HasUnids.php
Created November 23, 2023 21:33
App\Traits\HasUnids (Unique Name Identifier) trait for Laravel: create an ID based on first names.
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Str;
trait HasUnids
@janyksteenbeek
janyksteenbeek / cloudflare-shortener.js
Created August 3, 2023 14:41
Cloudflare Worker function for shortener
const redirects = [
{ path: 'privacy', redirect: 'https://cdn-static.storewire.net/legal/privacybeleid.pdf' },
{ path: 'tos', redirect: 'https://cdn-static.storewire.net/legal/leveringsvoorwaarden.pdf' },
{ path: 'ig', redirect: 'https://instagram.com/storewire' },
{ path: 'fb', redirect: 'https://facebook.com/storewire' },
{ path: 'gh', redirect: 'https://github.com/storewire' },
{ path: 'tw', redirect: 'https://twitter.com/storewirenl' },
{ path: 'li', redirect: 'https://linkedin.com/company/storewire' },
{ path: 'integration-bolcom-video', redirect: 'https://youtu.be/MTTp5x06bJI?t=30' }
];
@janyksteenbeek
janyksteenbeek / werkcentrumgroep-calculator-embed.html
Created June 27, 2023 18:19
WerkCentrum Groep Uitzendbureau calculator: Dit is de code waarmee je een calculator embed
<div class="wm-calculator" data-calculator-id="1764"></div>
<script src="https://www.werkcentrumgroep.nl/calculator.js">
</script>
<?php
return [
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
@janyksteenbeek
janyksteenbeek / laravel_cram_migration.php
Last active November 11, 2022 11:42
Laravel Cram Migration utility: This utility is used to cram a newly created Laravel migration file in between two migrations for correct order
<?php
/**
* Cram Migration utility
* ----------------------
*
* This utility is used to cram a newly created Laravel migration file in between two migrations for correct order.
* It is useful when you have a lot of migrations and you want to insert a new one in between.
*
* Make sure your new migration file is named correctly, starting with 9999, e.g. 9999_create_users_table.php
*
@janyksteenbeek
janyksteenbeek / tests.yaml
Last active November 11, 2022 11:44
GitHub Actions yaml file for running PHP tests (.github/workflows/tests.yaml)
# .github/workflows/tests.yml
name: Run Tests
on: [push, pull_request]
jobs:
Tests:
runs-on: ubuntu-18.04
strategy:
matrix:
php-versions: ['8.0', '8.1']
steps:
@janyksteenbeek
janyksteenbeek / laravel-pint.yml
Last active December 23, 2022 15:20
Run Laravel Pint on PRs towards `main` with GitHub Actions and auto-commit changes (.github/workflows/laravel-pint.yml)
# .github/workflows/laravel-pint.yml
# -- Be sure to add `laravel/pint` to your require-dev in your composer.json
name: Format Code using Laravel Pint
on:
pull_request:
branches:
- main
jobs:
@janyksteenbeek
janyksteenbeek / ciscodna_webhook_slack.php
Last active October 8, 2021 13:07
Report Cisco DNA web hook alerts to Slack
<?php
// Setting up Slack Webhook URI
$slackUrl = 'https://hooks.slack.com/services/HIER_JE_WEBHOOK_URL';
$ciscoDnaUrl = 'https://DNA_IP/'; // Always add trailing slash
$ciscoRequest = json_decode(file_get_contents('php://input'));
// Checking wheter or not is a valid Cisco DNS webhook
@janyksteenbeek
janyksteenbeek / keybase.md
Created September 12, 2019 11:49
Keybase proof @janyksteenbeek 2019-09-12

Keybase proof

I hereby claim:

  • I am janyksteenbeek on github.
  • I am janyksteenbeek (https://keybase.io/janyksteenbeek) on keybase.
  • I have a public key ASAF93-ggdtzy-EiSxROZRiFoXEAN0IuVt-HDFOU_lVfcQo

To claim this, I am signing this object:

@janyksteenbeek
janyksteenbeek / formatcopyrighttakedown.php
Created January 2, 2017 20:35
Auto-format a free-form YT copyright infringement notice
<?php
/**
* Stolen video title matcher
* @author Janyk Steenbeek <janyk.steenbeek@alveum.net>
* @license All rights reserved
* @url https://www.alveum.net
*/
$stolenPlaylistId = 'UUPu7aiZRcOSgKso6cNjZSag';
$key = 'YOUTUBE_API_KEY';