Skip to content

Instantly share code, notes, and snippets.

View akingdom's full-sized avatar

Andrew Kingdom akingdom

  • Australia
View GitHub Profile
<?php
// An example of receiving file(s) POSTed by an HTML web form (PHP language)
//
// Please add any necessary path and file handling, security, etc. that you require.
//
// By Andrew Kingdom
// MIT license
//
// Returns the minimum download limit specified in the current php.ini file.
//
// By Andrew Kingdom
// MIT license
function max_upload_size() {
$max_size = PHP_INT_MAX;
$post_overhead = 2048; // Reserve 2k for non-file data in the POST.
$tmp = shorthand_bytes(ini_get('upload_max_filesize'));
@akingdom
akingdom / swift-enums
Last active March 25, 2022 14:25
enum tricks in Swift
// Means to provide an alias to a value
// in a similar manner to Objective-C
// since Swift does not permit duplicate raw values
//
// By Andrew Kingdom
// MIT license
enum SomeOption : Int
{
case First = 0
//application/javascript
//
// Demonstrates callback from a class method
// By Andrew Kingdom
// MIT license
// Define a class
let MyClass1 = class {
constructor(initialValue) {
this.prop = initialValue; // store the parameter value in a property
//application/javascript
//
// A simple sequential calculator.
// By Andrew Kingdom
// MIT license
//
// Operator order/precedence is ignored.
// The calculation string is expected to have numbers and operators separated by spaces.
//
function operate(x,oper,y) {