Skip to content

Instantly share code, notes, and snippets.

View qmacro's full-sized avatar

DJ Adams qmacro

View GitHub Profile
@qmacro
qmacro / recordequality.js
Created February 3, 2015 14:14
Test equality of record structures as maps, in JavaScript, using reduce. Assuming maps have same structure.
var map1 = {name: "DJ", colour: "green"};
var map2 = {name: "DJ", colour: "green"};
Object.keys(map1).reduce(function(bool, prop) {
return bool && map1[prop] === map2[prop];
}, true); // => true
map2.name = "Joseph";
Object.keys(map1).reduce(function(bool, prop) {
@qmacro
qmacro / data.json
Last active August 29, 2015 14:12
Functional JavaScript scratchpad
// Test data only, sourced from a JSON/YAML style data set; this
// is not realistic in production as the data would be normalised
// and the repetitive nature would be avoided, but it's a reality
// when you're setting up test data by hand, so valid. This data
// is referred to later as "d.employees"
[
{
"name":"Employee Zero",
"wbses":[
@qmacro
qmacro / gist:297c350acc770cdc7013
Last active August 29, 2015 14:10
OTT FP in #UI5?
// Get a list of all the aggregated pages in a SplitApp
// ----------------------------------------------------
// oSplitAppControl is a ref to the instantiated SplitApp
// with an XML View in the masterPages aggregation
// and two XML Views in the detailPages aggregation
["getMasterPages", "getDetailPages"]
// Call the relevant functions to get the master & detail page aggregations content
.map(function(fn) {
*&---------------------------------------------------------------------*
*& Report UI5_REPOSITORY_LOAD
*&
*&---------------------------------------------------------------------*
*&
*& This report implements the up- and download of a SAPUI5 application
*& into an UI5 Repository.
*&
*& Furthermore it is possible to delete a UI5 Repository
*&
@qmacro
qmacro / MultiComboBox-without-Keyed-Root.html
Last active August 29, 2015 14:04
Keyed vs Non-Keyed Root JSON Element
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<script id="sap-ui-bootstrap"
type="text/javascript"
src="/sapui5/latest/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
@qmacro
qmacro / 0_reuse_code.js
Created March 9, 2014 18:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@qmacro
qmacro / CheckboxColumnBinding.html
Created February 4, 2014 08:34
Checkbox and Column Visibility binding
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>Checkbox and Column Binding</title>
<script id="sap-ui-bootstrap"
type="text/javascript"
@qmacro
qmacro / calendarinviter.js
Created January 2, 2014 13:50
Calendar Inviter
CALENDAR = "Work";
EVENT_MATCH = /^SAP\s/;
GUEST_LIST = ['you-1@example.com', 'you-2@example.com'];
DATE_FROM = new Date('01 Jan 2014');
DATE_TO = new Date('31 Dec 2014');
FORCE_ADD = false;
function main() {
inviteMe(CALENDAR, DATE_FROM, DATE_TO, EVENT_MATCH, GUEST_LIST, FORCE_ADD);
}
@qmacro
qmacro / index.html
Last active June 26, 2019 13:11
Custom Sorter and Grouper in SAPUI5
<!DOCTYPE html>
<html><head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<title>test</title>
<script id='sap-ui-bootstrap' type='text/javascript'
src='https://sapui5.hana.ondemand.com/sdk/resources/sap-ui-core.js'
data-sap-ui-theme='sap_bluecrystal'
data-sap-ui-libs='sap.m'></script>
itembinding.filter(
new sap.ui.model.Filter([
new sap.ui.model.Filter([
new sap.ui.model.Filter("Category", "EQ", "AC"),
new sap.ui.model.Filter("Category", "EQ", "PR")
], false),
new sap.ui.model.Filter([
new sap.ui.model.Filter("SupplierName", "EQ", "Red Point Stores"),
new sap.ui.model.Filter("SupplierName", "EQ", "Technocom")
], false),