Skip to content

Instantly share code, notes, and snippets.

View craigrodway's full-sized avatar

Craig A Rodway craigrodway

View GitHub Profile
@somatonic
somatonic / form-process.php
Last active May 24, 2023 18:26
ProcessWire example front-end form with file upload and fields
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
@somatonic
somatonic / form_with_fields_in_table.php
Last active August 29, 2016 13:52
form with fields rendered in a table example
<?php
/**
* Example form using PW API
*
* A workaround to get fields display in a table
* Those fields are marked with a property added to the fields $field->tablerow
*
* Approach is to grab those fields after form is put together and maybe processed,
* loop each row and render out the fields along with possible errors and add it to a string variable $table
* while we remove the field from the form at the same time.
@somatonic
somatonic / RandomImages.module
Last active December 17, 2015 06:49
get random images across pages optimized
<?php
/**
* Example use:
*
* $helper = $modules->get("RandomImages");
* $image = $helper->getRandomImages(1,"images");
* echo "<img src='{$image->size(150,0)->url}'>";
*/
@somatonic
somatonic / ImageCreateThumbs.module
Last active January 31, 2017 13:08
create thumbs when uploading image
<?php
class ImageCreateThumbs extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'ImageCreateThumbs',
'version' => 100,
'summary' => '',
@djekl
djekl / .gitignore
Created July 12, 2013 10:03
Default .gitignore used to start projects
########################################
### SOME SENSIBLE DEFAULTS BELOW ###
# https://github.com/github/gitignore #
########################################
@yckart
yckart / Log.module
Last active January 31, 2016 06:38
Log.module - A lightweight logging wrapper around ProcessWire's session message/error
<?php
class Log extends WireData implements Module {
/**
* getModuleInfo is a module required by all modules to tell ProcessWire about them
*
* @return array
@Da-Fecto
Da-Fecto / FieldtypeFolder.module
Last active January 1, 2016 09:49
ProcessWire files in folder Fieldtype & Inputfield.
<?php
/**
* ProcessWire files in folder Fieldtype
*
* ©2013 Martijn Geerts
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 20, 2025 13:11
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active September 24, 2024 14:47
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
@jeremeamia
jeremeamia / aws-csv-streamwrapper.php
Created June 6, 2014 18:23
Shows how to read a CSV stored in S3 using the AWS SDK for PHP's S3 Stream Wrapper.
<?php
require __DIR__ . '/vendor/autoload.php';
$s3 = Aws\S3\S3Client::factory($config);
$s3->registerStreamWrapper();
$url = 's3://{$bucket}/{$key}';
// Read CSV with fopen