Skip to content

Instantly share code, notes, and snippets.

View ndabAP's full-sized avatar
🔭

Julian Claus ndabAP

🔭
View GitHub Profile
@ndabAP
ndabAP / main.go
Created November 19, 2022 12:00
Dependency-free .env resolver in Go. Variables are exposed as environmental variables
// cmd/main.go
package main
import (
"bufio"
"errors"
"os"
"path/filepath"
"runtime"
"strings"
@ndabAP
ndabAP / request_limit_exceeded.xml
Created January 26, 2021 16:37
Salesforce "REQUEST_LIMIT_EXCEEDED: ConcurrentRequests (Concurrent API Requests) Limit exceeded."
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:REQUEST_LIMIT_EXCEEDED</faultcode>
<faultstring>REQUEST_LIMIT_EXCEEDED: ConcurrentRequests (Concurrent API Requests) Limit exceeded.</faultstring>
<detail>
<sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
<sf:exceptionCode>REQUEST_LIMIT_EXCEEDED</sf:exceptionCode>
<sf:exceptionMessage>ConcurrentRequests (Concurrent API Requests) Limit exceeded.</sf:exceptionMessage>
@ndabAP
ndabAP / index.js
Last active January 18, 2020 10:47
Convert seconds into format HH:MM:SS in JavaScript. Works for negative values as well
function nSecToTime(s) {
let seconds = s
s = Math.abs(s)
let t = [0, 0, 0]
let r = s % 3600
t[0] = Math.floor(s / 3600)
t[1] = Math.floor(r / 60)
r = r % 60
@ndabAP
ndabAP / typed.js
Last active November 4, 2018 07:51
Untyped vs. typed JavaScript Arrays
const { performance } = require('perf_hooks')
const start = performance.now()
const buffer = new ArrayBuffer(393216)
let uInt32View = new Uint32Array(buffer)
const length = uInt32View.length
for (let i = 0; i < length; i++) {
uInt32View[i] = i
@ndabAP
ndabAP / crypto.service.js
Created September 9, 2018 06:58
En-/Decryption with Node.js
import crypto from 'crypto'
const HASH = crypto.createHash('md5').update('password', 'utf-8').digest('hex')
export const encrypt = decrypted => {
let iv = new Buffer.alloc(16)
let cipher = crypto.createCipheriv('aes-256-cbc', HASH, iv)
return cipher.update(decrypted, 'utf8', 'hex') + cipher.final('hex')
}
@ndabAP
ndabAP / vue.sh
Created August 27, 2018 08:11
Install Vue.js project with npx
npx @vue/cli create
@ndabAP
ndabAP / functions.js
Last active June 5, 2018 12:45
Vue.js case
// It might be that you need components loaded dynamically. You can use the following function
const getComponentName = (identifier, method = 'post') => {
return `${identifier.replace(/([A-Z])/g, '-$1').toLowerCase().replace(/^-(.*)$/, '$1')}-${method}`
}
// Example: getComponentName('PriceTable', 'get') yields 'price-table-get'
@ndabAP
ndabAP / getRelativeDays.js
Last active June 10, 2018 05:47
Return days relative to first day
import moment from 'moment'
import flow from 'lodash/flow'
import map from 'lodash/fp/map'
/**
* Returns days relative to first one, e. g.: 0, 2, 9, 10, 11
*
* @params {array} dates
* @returns {array}
*/
@ndabAP
ndabAP / App.vue
Last active November 22, 2021 00:42
Vue.js pluralize filter
<template>
<div>
<p>I got {{ amount }} {{ 'cookie' | pluralize(amount) }}</p>
<button @click="decrement">Decrement</button>
</div>
</template>
<script>
export default {
data: () => ({
@ndabAP
ndabAP / index.js
Last active January 14, 2018 08:50
How to use Lodash's functional programs functions within a regular pattern
/**
* This way, you can import the functional program function and use in two ways. You don't have to fear any name collisions.
*/
let element = [{key: 1, value: a}, {key: 2, value: b}]
// Functional program usage
flow([
map(element => omit(['key']))
])(elements)