Skip to content

Instantly share code, notes, and snippets.

View mardukbp's full-sized avatar

Marduk Bolaños mardukbp

View GitHub Profile
@mardukbp
mardukbp / example-hof.md
Created January 3, 2024 15:40 — forked from CliffordAnderson/example-hof.md
Simple examples of higher-order functions and partial function application in XQuery

##Examples of Higher-Order Functions in XQuery

Here are a few examples of higher-order functions in XQuery. For more examples, see the very nice discussion of higher-order functions in XQuery 3.0 at the BaseX website.

N.B. In some implementations, these functions may not be implemented or may have different names/function signatures. The first four functions have been tested using Saxon PE and the second four using Zorba.

An introduction to recursion in XQuery

  • Created: Nov 28, 2017
  • Updated: Nov 29, 2017: Now covers transformation of XML documents

Recursion is a powerful programming technique, but the idea is simple: instead of performing a single operation, a function calls itself repeatedly to whittle through a larger task. In XQuery, recursion can be used to accomplish complex tasks on data that a plain FLWOR expression (which iterates through a sequence) cannot, such as transforming an entire XML document from one format into another, like TEI or DocBook into HTML, EPUB, LaTeX, or XSL-FO. Transforming a document is well-suited to recursion because each of the document's nodes may need to be examined and manipulated based on the node's type, name, and location in the document; and once a node has been processed, the transformation must continue processing the nodes' children and descendants until the deepest leaf node has been processed. But learning the technique of recursion is often hard for a beginning program

@mardukbp
mardukbp / type_vs_data_constructors.md
Created November 4, 2023 18:31 — forked from adomokos/type_vs_data_constructors.md
Type vs Data Constructors in Haskell

Type vs Data Constructors

In a data declaration, a type constructor is the thing on the left hand side of the equals sign. The data constructor(s) are the things on the right hand side of the equals sign. You use type constructors where a type is expected, and you use data constructors where a value is expected.

Data constructors

To make things simple, we can start with an example of a type that represents a colour.

data Colour = Red | Green | Blue
@mardukbp
mardukbp / tg2p.st
Created August 5, 2023 14:11 — forked from jdevoo/tg2p.st
Not so Terse Guide to Pharo
"**************************************************************************
* Allowable characters: *
* - a-z *
* - A-Z *
* - 0-9 *
* - .+/\*~<>@%|&? *
* - blank, tab, cr, ff, lf *
* *
* Variables: *
* - variables must be declared before use *
@mardukbp
mardukbp / README.md
Created November 29, 2022 07:43 — forked from bollwyvl/README.md
RevealJS SVG fragment presenter

SVG fragment builds for reveal.js

Basic use case

  • make an SVG (maybe in inkscape)
    • save it someplace reveal.js can find it (maybe next to your presentation)
    • figure out how to identify them (maybe use named layers)
  • in reveal.js/index.html
    • add reveal-svg-fragment.js as a dependency
    • in a <section> of reveal.js markup
  • add data-svg-fragment="" to something, e.g.
@mardukbp
mardukbp / big-o.md
Created October 16, 2022 19:38 — forked from PJUllrich/big-o.md
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@mardukbp
mardukbp / README.md
Created October 9, 2022 15:01 — forked from gampleman/README.md
Algorithm to find a short unique CSS selector from an arbitrary node

This algorithm when passed a DOM node will find a very short selector for that element.

@mardukbp
mardukbp / 2serv.py
Created August 3, 2022 14:42 — forked from phrawzty/2serv.py
simple python http server to dump request headers
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@mardukbp
mardukbp / groupBy.js
Created May 4, 2022 14:26 — forked from robmathers/groupBy.js
A more readable and annotated version of the Javascript groupBy from Ceasar Bautista (https://stackoverflow.com/a/34890276/1376063)
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by
// reduce runs this anonymous function on each element of `data` (the `item` parameter,
// returning the `storage` parameter at the end
return data.reduce(function(storage, item) {
// get the first instance of the key by which we're grouping
var group = item[key];
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it
storage[group] = storage[group] || [];
@mardukbp
mardukbp / README.md
Created February 11, 2022 13:44 — forked from Tset-Noitamotua/README.md
HOW-TO enable MarkDown support in RobotFramework

HOW-TO enable MarkDown support in RobotFramework

You want to execute robot test which are inside fenced code blocks of a markdown file (.md) like any normal robot test? Follow the steps below then you can run your tests as simple as robot your_test_suite.md with all robot command line execution options.

This will add support for .md files to RF

  1. Clone [RobotFramework][4] repository
  2. Save the code below as 'mdreader.py' in parsing folder of your local clone. It's based on [restreader.py][1]
  3. Add this from .mdreader import MarkDownReader [here][2] to your local clone.