Skip to content

Instantly share code, notes, and snippets.

@koohq
koohq / ReadOnlyScalarMap.php
Last active May 13, 2021 11:25
The PHP array wrapper to get scalar.
<?php
/**
* Provides the methods to get scalar from single-dimensional-array.
* This code is designed for the legacy version, such as PHP 5.2.
*
* @copyright 2021 koohq
* @license https://creativecommons.org/publicdomain/zero/1.0/legalcode CC0
*/
class ReadOnlyScalarMap
{
@koohq
koohq / CallFuncExact.php
Last active October 16, 2018 16:36
A function that calls the function with exact parameters' count.
<?php
/**
* CallFuncExact.php
*
* @copyright 2018 koohq
* @license https://creativecommons.org/publicdomain/zero/1.0/legalcode CC0
*/
/**
* @param callable $func
@koohq
koohq / ProperyReadable.php
Created September 24, 2018 13:52
Provides mechanism for read-only property that relieves __get implementation.
<?php
/**
* PropertyReadable.php
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
trait PropertyReadable
{
/** @var array [string => string|callable] */
@koohq
koohq / sp-selectlastpublishedversionitem.cs
Last active January 13, 2018 18:34
Provides a filter to retrieve the last-published list items on SharePoint Lists.
/**
* SP-SelectLastPublishedVersionItem.cs
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
namespace Kooh.Q.Hook
{
using Microsoft.SharePoint;
@koohq
koohq / sp-request.js
Created January 8, 2018 18:53
Provides method for executing SharePoint REST API (based on SP.RequestExecutor.js)
/**
* sp-request.js
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var SPRequest = (function() {
// constructor
function SPRequest(webUrl) {
this.webUrl = webUrl;
@koohq
koohq / sp-formfieldinputdict.js
Created January 8, 2018 18:40
Create dictionary that stores field input control at SharePoint NewForm/EditForm pages (jQuery required)
/**
* sp-formfieldinputdict.js
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var formFieldInputDict = {};
// Promise that indicates assigning ID completed
@koohq
koohq / sp-clientpeoplepickerhelper.js
Last active January 8, 2018 18:30
Provides methods to retrieve SPClientPeoplePicker object asynchronously
/**
* sp-clientpeoplepickerhelper.js
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var SPClientPeoplePickerHelper = (function() {
var requiredScriptName = 'sp.js';
function waitUnitlPeoplePickerReady() {
@koohq
koohq / sp-assignfieldrowid.js
Last active January 8, 2018 18:05
Assign ID for the field row on SharePoint NewForm/EditForm/DispForm pages (jQuery required)
/**
* sp-assignfieldrowid.js
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
// Promise that indicates assigning ID completed
var formFieldRowIdAssigned;
@koohq
koohq / wait.js
Last active January 8, 2018 13:12
Provides waiting method for unfriendly async process (ex. no notify completion)
/**
* wait.js
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var Wait = (function() {
function Wait(timeout, interval) {
this.timeout = timeout;
@koohq
koohq / jq-promise.js
Last active January 8, 2018 12:31
A snippet to provide utility methods for jQuery's Promise (jQuery.Deferred subset).
/**
* jq-promise.js
*
* (c) 2018 koohq. Licensed under CC0.
* https://creativecommons.org/publicdomain/zero/1.0/legalcode
*/
var $Promise = (function($) {
function create(func) {
var deferred = $.Deferred();