Skip to content

Instantly share code, notes, and snippets.

@pwFoo
pwFoo / Caddyfile
Created December 12, 2016 21:32 — forked from talbergs/Caddyfile
Docker[ Caddy php7 ]
0.0.0.0:80
fastcgi / phpfmp:9000 php
@pwFoo
pwFoo / disable_vim_auto_visual_on_mouse.txt
Created July 2, 2017 15:28 — forked from u0d7i/disable_vim_auto_visual_on_mouse.txt
Disable vim automatic visual mode on mouse select
Disable vim automatic visual mode on mouse select
issue: :set mouse-=a
add to ~/.vimrc: set mouse-=a
@pwFoo
pwFoo / generate-dropbear-key
Created April 26, 2018 09:37 — forked from hongkongkiwi/generate-dropbear-key
Generate SSH Key in Dropbear
#!/bin/bash
KEY_DIR="/mnt/sda1/.ssh"
# Make directories
mkdir -p "$KEY_DIR"
# Generate an RSA key using dropbear
dropbearkey -t rsa -f "${KEY_DIR}/id_rsa"
@pwFoo
pwFoo / two-way-binding.js
Created November 24, 2018 15:01 — forked from straker/two-way-binding.js
Simple and small two-way data binding between DOM and data
/**
* @param {object} scope - Object that all bound data will be attached to.
*/
function twoWayBind(scope) {
// a list of all bindings used in the DOM
// @example
// { 'person.name': [<input type="text" data-bind="person.name"/>] }
var bindings = {};
// each bindings old value to be compared for changes
#!/usr/bin/env bash
set -eo pipefail
# from moby project - w/o go dependency (nailing amd64) and w/o jq dep (using
# python)
# hello-world latest ef872312fe1b 3 months ago 910 B
# hello-world latest ef872312fe1bbc5e05aae626791a47ee9b032efa8f3bda39cc0be7b56bfe59b9 3 months ago 910 B
# debian latest f6fab3b798be 10 weeks ago 85.1 MB
# debian latest f6fab3b798be3174f45aa1eb731f8182705555f89c9026d8c1ef230cbf8301dd 10 weeks ago 85.1 MB
@pwFoo
pwFoo / README.md
Created June 21, 2019 04:58 — forked from ibuildthecloud/README.md
k3s on WSL2
@pwFoo
pwFoo / ofilter.php
Created January 4, 2020 20:49 — forked from amnuts/ofilter.php
Filter an array of objects based on property, or multiple property values
<?php
/**
* Filter an array of objects.
*
* You can pass in one or more properties on which to filter.
*
* If the key of an array is an array, then it will filtered down to that
* level of node.
*
@pwFoo
pwFoo / get_latest_release.sh
Created February 1, 2020 21:08 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@pwFoo
pwFoo / AuthService.php
Created March 31, 2020 19:09 — forked from apiraino/AuthService.php
Simple static token authentication with Directus API
<?php
declare(strict_types=1);
use Directus\Services\AuthService as DirectusAuthService;
use Directus\Authentication\Exception\UserNotFoundException;
class AuthService
{
private function getToken($req)
@pwFoo
pwFoo / Encryption.js
Created May 9, 2020 13:04 — forked from ve3/Encryption.js
Encrypt and decrypt between programming languages (PHP & JavaScript).
/**
* Encryption class for encrypt/decrypt that works between programming languages.
*
* @author Vee Winch.
* @link https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs Reference.
* @link https://github.com/brix/crypto-js/releases crypto-js.js can be download from here.
*/
class Encryption {