Skip to content

Instantly share code, notes, and snippets.

View mardukbp's full-sized avatar

Marduk Bolaños mardukbp

View GitHub Profile
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@mardukbp
mardukbp / tls-client.go
Created February 8, 2021 09:11 — forked from michaljemala/tls-client.go
SSL Client Authentication Golang sample
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@mardukbp
mardukbp / run-gui-apps-from-a-different-user.md
Created March 18, 2021 10:57 — forked from kasunbg/run-gui-apps-from-a-different-user.md
How to run a GUI application as a different user?

How to run a GUI application as a different user:

Suppose you are logged into your Linux box as user1 using some X window system already (with GNOME/Unity/..). Now you want to run some gui app as another user, user2.

Run:

  1. xhost + - Run as the user1. This enables access to user1's X window system from other users. You should see following output: 'access control disabled, clients can connect from any host'
  2. sudo su - user2 - Using your favorite terminal, log-in to second user.
  3. export DISPLAY=:0.0 - optional for some apps.
@mardukbp
mardukbp / comment.md
Created April 14, 2021 17:03 — forked from staltz/comment.md
Nested Pick<T, K> in TypeScript 2.2

TypeScript supports Pick to allow you to get a "subset" object type of a given type, but there is no built-in Pick for deeper nested fields.

If you have a function that takes a large object as argument, but you don't use all of its fields, you can use Pick, Pick2, Pick3, etc to narrow down the input type to be only just what you need. This will make it easier to test your function, because when mocking the input object, you don't need to pass all fields of the "large" object.

@mardukbp
mardukbp / base94.c
Created December 6, 2021 19:51 — forked from iso2022jp/base94.c
base94 encoder/decoder
#include "base94.h"
void base94_encode(const unsigned char *plain, unsigned char *code) {
// high * 2^64 | low
unsigned long long value
= ((unsigned long long)plain[1] << 56) | ((unsigned long long)plain[2] << 48)
| ((unsigned long long)plain[3] << 40) | ((unsigned long long)plain[4] << 32)
@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.
@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 / 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 / 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 / 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