Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
<?php
/** @see https://twitter.com/AshAllenDesign/status/1786037324775633109 */
test('strict types are used everywhere')
->expect('App')
->toUseStrictTypes();
test('globals')
->expect(['dd', 'ddd', 'die', 'dump', 'ray', 'sleep'])
@james2doyle
james2doyle / example.ionapi
Created May 1, 2024 18:46
An example on how to get an oAuth2 token from the Mingle ION API for Infor Cloudsuite
{
"ti": "AAAABBBBCCCCDDDD_ZZZ",
"cn": "Example ION File",
"dt": "11",
"ci": "AAAABBBBCCCCDDDD_ZZZ~fioUStyk923dTK4y7iXdBwVjTBYEunBtd9GpEigvBf9",
"cs": "gkBdyWByfHiOwteD-vQn9jb7pudublgsI9kW4fiPhzsOi2lFKIttCzy5ofiiyMQqgSjpuS3GRDtMHbLbj_fexq",
"iu": "https://mingle-ionapi.inforcloudsuite.com",
"pu": "https://mingle-sso.inforcloudsuite.com:443/AAAABBBBCCCCDDDD_ZZZ/as/",
"oa": "authorization.oauth2",
"ot": "token.oauth2",
@james2doyle
james2doyle / composer.json
Last active April 29, 2024 18:44
A composer.json skeleton for Laravel that includes some handy scripts
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"repositories": [],
"require": {
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
@james2doyle
james2doyle / getops.sh
Last active April 16, 2024 18:19
An example of a bash script that has required arguments
#!/usr/bin/env bash
# e (errexit): Abort script at first error
# u: Treat unset variables as an error
# f: Disable filename expansion (globbing) upon seeing *, ?, etc..
# pipefail: Causes a pipeline to return exit code for last command in pipe
set -euf -o pipefail
# run this if the script exits with a non-zero exit code
handle_error() {
@james2doyle
james2doyle / Default (OSX).sublime-keymap
Created April 12, 2024 17:38
The default Sublime Text keymap
/*
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings,
and don't need to be repeated here. Anything listed here will take precedence, however.
*/
[
{ "keys": ["super+shift+n"], "command": "new_window" },
{ "keys": ["super+shift+w"], "command": "close_window" },
{ "keys": ["super+alt+shift+n"], "command": "new_os_tab" },
{ "keys": ["ctrl+alt+tab"], "command": "next_os_tab" },
{ "keys": ["ctrl+alt+shift+tab"], "command": "prev_os_tab" },
@james2doyle
james2doyle / dd.php
Last active April 12, 2024 12:35
A implementation of "dump and die" (dd) for WordPress
<?php
if (!function_exists('dd')) {
function dd($data)
{
ini_set("highlight.comment", "#969896; font-style: italic");
ini_set("highlight.default", "#FFFFFF");
ini_set("highlight.html", "#D16568");
ini_set("highlight.keyword", "#7FA3BC; font-weight: bold");
ini_set("highlight.string", "#F2C47E");
@james2doyle
james2doyle / laravel.sublime-project
Last active April 11, 2024 17:49
Sublime project file for Laravel applications. Use this in order to have Sublime better understand the folders and files in the project.
{
"folders": [
{
"path": ".",
"folder_exclude_patterns": [
".vemto",
"vendor",
"node_modules",
"storage",
"bootstrap/cache",
@james2doyle
james2doyle / render-php-file.php
Last active April 4, 2024 15:33
A function to render a php file with data. Allows templating and then sending an array of data into the view.
<?php
function renderPhpFile($filename, $vars = null) {
if (is_array($vars) && !empty($vars)) {
extract($vars);
}
ob_start();
include $filename;
return ob_get_clean();
}
@james2doyle
james2doyle / parallel-runtime.php
Created April 1, 2024 16:25
An example of parallel which is a parallel concurrency extension for PHP
<?php
/** @see https://www.php.net/manual/en/intro.parallel.php */
$runtime = new \parallel\Runtime();
$channel = new \parallel\Channel();
// Run a task in parallel, passing a channel for communication
$future = $runtime->run(function () use ($channel) {
// Do some work here
$channel->send('Result');
@james2doyle
james2doyle / getXML.go
Last active March 29, 2024 07:08
Use HTTP to GET and parse XML in golang
// tweaked from: https://stackoverflow.com/a/42718113/1170664
func getXML(url string) ([]byte, error) {
resp, err := http.Get(url)
if err != nil {
return []byte{}, fmt.Errorf("GET error: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return []byte{}, fmt.Errorf("Status error: %v", resp.StatusCode)