Skip to content

Instantly share code, notes, and snippets.

View martijngastkemper's full-sized avatar

Martijn Gastkemper martijngastkemper

View GitHub Profile
@murdercode
murdercode / nova4-auth0.md
Last active December 4, 2023 08:29
Laravel Nova 4 + Auth0

Nova 4 + Auth0 = ❤️

Hi folks! After a day of *#!$", DispatchCode and I have realized a working installation of Nova4 with Auth0 support. Here's our conclusions, if you want to try it :)

2. Create the Custom Auth

Create a file in \app\Auth\CustomUserRepository.php and add the following code:

@sergeiwaigant
sergeiwaigant / url_encode_string_with_linux_tools.md
Last active May 1, 2024 19:16
Simply URL encode string with Linux/Bash/Shell tools

Reference https://stackoverflow.com/a/34407620/13287790

$ printf %s 'encode this'|jq -sRr @uri
encode%20this
$ jq -rn --arg x 'encode this' '$x|@uri'
encode%20this
-r (--raw-output) outputs the raw contents of strings instead of JSON string literals. -n (--null-input) doesn't read input from STDIN.

-R (--raw-input) treats input lines as strings instead of parsing them as JSON, and -sR (--slurp --raw-input) reads the input into a single string. You can replace -sRr with -Rr if your input only contains a single line, or if you don't want to replace linefeeds with %0A:
@harmenjanssen
harmenjanssen / example1.php
Last active May 10, 2019 09:40
Quick example of how Maybe could work in PHP.
<?php
$record = $model->fetchById(42); // return Maybe(Record)
$related = $record->map(function ($record) {
// If this function is executed, record is definitely available, no need to check.
return $otherModel->fetchWhere('foreign_key', $record->id);
});
// It's still a Maybe after mapping, so you can continue mapping on the value.
// If the first fetchById call got you a Nothing, this is still the same
// Nothing, but your code doesn't need to know, it can be written
@lyrixx
lyrixx / HardCoreDebugLogger.php
Last active April 27, 2024 14:09
Hardcore Debug Logger
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
@bwinant
bwinant / lifecycle-plugin.js
Created May 7, 2018 09:04
Serverless Plugin Lifecycle Events
'use strict';
// This plugin will bind to all available lifecycle events and print them out as they are invoked
class LifecyclePrinter {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.provider = this.serverless.getProvider('aws');

Given a subscribed calendar with a url like

https://example.com/example.ics

To force Google Calendar to refresh and reload the contents right now, unsubscribe from the calendar and subscribe to a new calendar with a URL like

https://example.com/example.ics#1

Adding the anchor tag will force Google Calendar to think of it as a new calendar

@marcus-at-localhost
marcus-at-localhost / index.php
Last active December 13, 2021 11:15
[Replace tags with HTML Purifier] http://htmlpurifier.org/ #dom
<?php
// include HTMLPurifier.php
$config = HTMLPurifier_Config::createDefault();
$config->set('AutoFormat.RemoveEmpty', true);
$config->set('AutoFormat.AutoParagraph', true);
$config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$config->set('CSS.AllowedProperties', array());
$config->set('HTML.ForbiddenAttributes', array('*@class'));
@BerkeleyTrue
BerkeleyTrue / fetch-git-pr.bash
Created October 9, 2015 07:58 — forked from vojtajina/fetch-git-pr.bash
Bash script for fetching a pull request from github...
# fetching a single pull request from github
# put it into ~/.profile or ~/.bashrc
function fetch_pr() {
PR=$1
BRANCH=$2
if [ -z $PR ]; then
echo "Missing pull request number"
return 1
fi
@StephanHoyer
StephanHoyer / github.js
Last active February 13, 2024 14:19
Commiting multiple files to github over API
'use strict';
var Octokat = require('octokat');
var extend = require('lodash/object/assign');
var defaults = {
branchName: 'master',
token: '',
username: '',
reponame: ''
<?
require("redis.php");
require("json.php");
$term = $_GET['term'];
$r = new Redis("127.0.0.1","6379");
$r->connect();
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10"));