Skip to content

Instantly share code, notes, and snippets.

View craigrodway's full-sized avatar

Craig A Rodway craigrodway

View GitHub Profile
@jreviews
jreviews / htmx-loading-states-extension.md
Last active April 1, 2024 22:22
htmx loading states extension

htmx loading states extension

The loading-states extension allows you to easily manage loading states while a request is in flight, including disabling elements, and adding and removing CSS classes.

Using the extension

Add the hx-ext="loading-states" attribute to the body tag or to any parent element containing your htmx attributes.

Add the following class to your stylesheet to make sure elements are hidden by default:

@sjardim
sjardim / processire-sync-s3-images.module.php
Last active August 11, 2023 04:20
'Synchronize all the page images uploaded through ProcessWire to a specified bucket in Amazon S3 and other places using Flysystem library.
<?php namespace ProcessWire;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
class ProcessSync extends WireData implements Module, ConfigurableModule {
public static function getModuleInfo() {
@creationix
creationix / rpc.md
Last active December 30, 2020 03:58
Simple RPC design

I've designed a lot of RPC protocols in my career. One pattern that's worked well basically goes as follows:

// Client calls: print('Hello World\n')
-> [1, "print", "Hello World!\n"]
// Server sends return value (or lack of return vvalue)
<- [-1]

// Client calls: add(1, 2)
-> [2, "add", 1, 2]
@mp035
mp035 / laravel-ajax-form.js
Last active October 5, 2022 22:14
Convert any standard HTML form to ajax by adding a few classes to the components and including this file. (see comments)
// notes on using this file:
// This file is intended to work with a standard html form the same as what you use for server side rendered laravel projects.
// The only changes you need to make to the form are:
// 1. Add the class "ajax-submit" to any form you want to be submitted via ajax.
// 2. If you have a "Cancel" button on your form, mark it with the class "form-cancel"
// 3. Add a bootstrap alert in your form, marked with the class "ajax-error-alert" and "collapse" (to keep it initally hidden). This alert will display any error messages.
// Then call the function "AttachAjaxSubmit()" after the DOM is loaded.
// NOTE: This script requires bootstrap to style the components during the submission process.
@steve-taylor
steve-taylor / theme-colors.html
Last active November 2, 2020 22:59
Theme color chooser
<!doctype html>
<html>
<head>
<style>
html, body {
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Roboto, 'Segoe UI', sans-serif;
}
.color-grid {
display: grid;
@jaredmales
jaredmales / rclone-cron.sh
Last active January 8, 2024 01:56
An rclone backup script for cron
#!/bin/bash
##############################################################################
# An rclone backup script by Jared Males (jaredmales@gmail.com)
#
# Copyright (C) 2018 Jared Males <jaredmales@gmail.com>
#
# This script is licensed under the terms of the MIT license.
# https://opensource.org/licenses/MIT
#
@jeffersonmartin
jeffersonmartin / composer-private-package-github-token.md
Last active April 11, 2024 11:22
Generate a GitHub Personal Access Token for Private Composer Packages

Generate a GitHub Personal Access Token for Private Composer Packages

If you're trying to load a private repository with Composer/Laravel, we'll need to generate a GitHub Personal Access Token (similar to OAuth token) to access the repository during a composer install without entering credentials.

If you have used other Github packages from {my-org} before, you may be able to skip this step.

  1. Visit https://github.com/settings/tokens.

  2. Click Generate new token.

@mattes
mattes / default.conf
Last active June 4, 2022 06:43
redash.io setup
upstream redash {
server redash:5000;
}
server {
listen 80;
location / {
return 301 https://$host$request_uri;
}
@Datawalke
Datawalke / SlimRoutingExtension.php
Last active October 13, 2016 13:15
A basic Slim v3 Routing Extension for KnpMenu
<?php
use Knp\Menu\Factory\ExtensionInterface;
use Slim\Interfaces\RouterInterface;
class SlimRoutingExtension implements ExtensionInterface {
/** @var RouterInterface */
private $router;
@tonyspiro
tonyspiro / gist:490962be30a67af923de
Created March 2, 2015 22:43
Curl Get, Post, Put and Delete in PHP
<?php
class Curl {
public function get($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);