Skip to content

Instantly share code, notes, and snippets.

View cgraff's full-sized avatar
💻
On the playground

Christian Graff cgraff

💻
On the playground
  • SAP
  • Bernau bei Berlin
View GitHub Profile
@tokland
tokland / promise_map.js
Last active March 1, 2022 00:18 — forked from anvk/promises_reduce.js
Execute promises sequentially (one at at a time) and return array with the results
function promiseMap(inputValues, mapper) {
const reducer = (acc$, inputValue) =>
acc$.then(acc => mapper(inputValue).then(result => acc.push(result) && acc));
return inputValues.reduce(reducer, Promise.resolve([]));
}
/* Example */
const axios = require('axios');
@robypag
robypag / InteractiveNetwork.js
Created December 22, 2016 00:30
SAPUI5 Force Layout control with D3.js
/*eslint no-return-assign: 0, sap-no-dom-insertion: 0*/
sap.ui.define([
"sap/ui/core/Control",
"sap/m/FlexBox",
"sap/ui/thirdparty/d3"
], function(Control, FlexBox, d3) {
"use-strict";
return Control.extend("rpc.onaui.controls.InteractiveNetwork", {
@anvk
anvk / promises_reduce.js
Last active October 11, 2023 09:02
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@DarrenN
DarrenN / get-npm-package-version
Last active April 17, 2024 16:57 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@jasper07
jasper07 / proxy.js
Last active June 2, 2019 12:19
Simple Node reverse proxy for UI5 development
var express = require('express'),
httpProxy = require('http-proxy'),
proxy = new httpProxy.createProxyServer();
var routing = {
'sapui5': {
target: 'http://localhost:8001' //sdk
},
'apps': {
target: 'http://localhost:8002' //applications
@borismus
borismus / gist:1032746
Created June 18, 2011 02:46
Convert a base64 string into a binary Uint8 Array
var BASE64_MARKER = ';base64,';
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(i = 0; i < rawLength; i++) {