Skip to content

Instantly share code, notes, and snippets.

View infostreams's full-sized avatar

Edward Akerboom infostreams

View GitHub Profile
@infostreams
infostreams / php.sh
Created November 8, 2021 10:20
Change PHP version on MacOS
#!/bin/bash
available=$(brew list --formula -1 | egrep '^php@|^php$')
syntax () {
echo "SYNTAX: $0 <version>"
echo ""
echo -n "<version> needs to be one of: "
echo $available
echo ""
#!/usr/bin/env php
<?php
/**
* This script monitors a folder for changes and forces a change in the inode or file-modification time
* if it detects a change or deletion.
*
* Basically it's a PHP re-implementation of https://github.com/sillypog/inotify-proxy
*
* I do this because docker-sync was not copying changes from my MacOS folder to volume that was used by
* my docker container. And docker-sync is the only way to get a FAST filesystem if you're using Docker
@infostreams
infostreams / UserFromBearerToken.php
Last active January 2, 2024 05:47
How to retrieve or authorize a User object from a Laravel Bearer API token
<?php
use \League\OAuth2\Server\ResourceServer;
use \Laravel\Passport\TokenRepository;
use \Laravel\Passport\Guards\TokenGuard;
use \Laravel\Passport\ClientRepository;
use \Illuminate\Support\Facades\Auth;
use \Illuminate\Http\Request;
function getUser($bearerToken) {
$tokenguard = new TokenGuard(
@infostreams
infostreams / CachedImageMultiSource.js
Created January 8, 2018 15:29
Use "react-native-img-cache" with multiple source images
import React from "react"
import PropTypes from "prop-types"
import {CachedImage} from "react-native-img-cache"
class CachedImageMultiSource extends React.Component {
static propTypes = {
...CachedImage.propTypes,
source: PropTypes.arrayOf(PropTypes.object),
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
@infostreams
infostreams / record.sh
Created November 8, 2016 09:21
Collect details about internet / wifi availability (macOS)
#!/bin/sh
SCRIPTPATH=$(cd "$(dirname "$0")"; pwd -P)
while [ true ]
do
${SCRIPTPATH}/status.sh >> ${SCRIPTPATH}/log.txt
sleep 10
done
@infostreams
infostreams / gogs
Created September 22, 2014 07:07
Debian startup (init.d) script for gogs.io
#! /bin/sh
### BEGIN INIT INFO
# Provides: gogs
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Git repository manager Gogs
# Description: Starts and stops the self-hosted git repository manager Gogs
### END INIT INFO
### Keybase proof
I hereby claim:
* I am infostreams on github.
* I am eakerboom (https://keybase.io/eakerboom) on keybase.
* I have a public key whose fingerprint is 292A 017B B43A 39E0 635B 5C77 D999 A61C 8C2B 4D1C
To claim this, I am signing this object:
@infostreams
infostreams / bindFirst
Last active April 5, 2017 07:49
ensures a handler is run before any other registered handlers, independent of the order in which they were bound. Requires jQuery > 1.7
$.fn.bindFirst = function(which, handler) {
// ensures a handler is run before any other registered handlers,
// independent of the order in which they were bound
var $el = $(this);
$el.unbind(which, handler);
$el.bind(which, handler);
var events = $._data($el[0]).events;
var registered = events[which];
registered.unshift(registered.pop());