Skip to content

Instantly share code, notes, and snippets.

View KMurphs's full-sized avatar

Stephan K. KMurphs

  • Pretoria, South Africa
View GitHub Profile
@KMurphs
KMurphs / scrappe.js
Last active February 16, 2023 16:00
Save JS Object as file from DevTools
/**
* Given some Javascript object, the function will have the browser download it as a
* json file (exactly like if it was downloaded from some server).
* The content of the file downloaded by the browser would be the "data" object input.
* One could also pass a name for the file to be downloaded to the function.
* References:
* - https://www.freecodecamp.org/news/how-to-use-the-browser-console-to-scrape-and-save-data-in-a-file-with-javascript-b40f4ded87ef/
* - https://github.com/edubey/browser-console-crawl/blob/master/single-story.js
* @date 2021-06-18
* @param {object} data
@KMurphs
KMurphs / excel-merge-cells.md
Last active April 26, 2021 22:33
Excel Macros to merge cells by merging cell contents. Default excel behavior is to keep only the upper left cell content during the merge. These Macros will concatenate the cell content using new lines

Excel Merge Cells Macros

Sub MergeCells()
'
' MergeCells Macro
'
    Dim var As String
    
    rg = Selection.Address    ' Current selected range e.g. "F2:F5"
@KMurphs
KMurphs / dockerfile-best-practices.md
Last active March 11, 2021 10:28
Dockerfile Best Practices

On Dockerfile

...


# Create user and set ownership and permissions as required
RUN adduser -D myuser && chown -R myuser /myapp-data

@KMurphs
KMurphs / contextmenu.markdown
Created February 21, 2021 08:18
ContextMenu
@KMurphs
KMurphs / js-array-methods.md
Last active January 20, 2021 16:34
Reduce under the hood

The Imperative Way

So let's start with a sum:

const arr = [1,2,3,4,5,6,7,8,9,10];

let sum = 0;
for(let i = 0 ; i < arr.length ; i++){
  sum = sum + arr[i];
}
@KMurphs
KMurphs / jira-jql-filter-referencing-user.md
Last active January 6, 2021 08:41
Jira JQL Filter to get all issues referencing some user
@KMurphs
KMurphs / fp-js-stack-queue.rb
Created December 11, 2020 16:26
Interesting Implementation of Stack and Queue using Functional Programming in Javascript
// https://stackoverflow.com/a/42242601/9034699
// From original answer: Stack
const stackPush = (x, xs) => f => f(x,xs)
const stackPop = s => s((x,xs) => [x,xs])
// From a looooong effort on my side.
// It is not efficient, or usable. But the goal was a proof of concept: To figure out a way to do this using similar method.
const countQ = Q => Q((prevEl, prevQ) => 1 + (prevQ ? countQ(prevQ) : 0))
const enQ = (el, Q) => f => f(el, Q, Q ? countQ(Q): 0)
/* Simple function that calculates tax for a certain amount */
const calculateTax = function(amount, taxRate){
return amount * taxRate;
}
/*
Straightforward Higher Order Function that prepends a currency symbol to