This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
// | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 5.0 + Javascript | |
// How to use 'new <classtype>' in Javascript to instantiate a Swift object (from JavaScriptCore). | |
// | |
// I couldn't find this clearly documented in any one place. | |
// | |
// By Andrew Kingdom | |
// MIT license | |
// | |
@objc | |
public protocol SampleProtocol: JSExport { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Objective C++ | |
// Detects whether this is an initial or subsequent launch of this app. | |
// | |
// By Andrew Kingdom | |
// MIT license | |
// | |
static BOOL _appDidLaunchPreviously; | |
static BOOL _appDidLaunchPreviously_known; | |
static NSString * kAppDidLaunchPreviously = @"priorLaunch"; | |
static NSString * vAppDidLaunchPreviously = @"Y"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Android Java | |
// How to check if the app is a debug build versus a release build. | |
// | |
// By Andrew Kingdom | |
// MIT license | |
// | |
public class MainActivity extends AppCompatActivity { | |
// Returns true if the app is debuggable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Android Java | |
// How to programmatically control whether the screen may or may not turn off. | |
// | |
// By Andrew Kingdom | |
// MIT license | |
// | |
package com.example.sample; | |
import android.os.Bundle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Objective C | |
// Display initial screen before final UIViewController loads (e.g. Login credentials) | |
// | |
// By Andrew Kingdom | |
// MIT license | |
// | |
// Instructions: | |
// | |
// On the main storyboard, create your login screen as, say, a subclass of UIViewController. | |
// Make sure it is the initial scene (check Is Initial View Controller). |
OlderNewer