Skip to content

Instantly share code, notes, and snippets.

@JoseHdez2
JoseHdez2 / affirmation
Created July 27, 2018 09:54
MuleSoft Contributor Agreement Acceptance by Jose Hernandez
I, Jose Hernandez, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Fri Jul 27 2018 10:54:46 GMT+0100 (WEST)
@JoseHdez2
JoseHdez2 / best_practices.md
Created August 14, 2018 09:29
Some best practices for software development
@JoseHdez2
JoseHdez2 / eclipse-shortcuts.md
Last active October 23, 2019 11:45
Some Eclipse shortcuts
  • Most important:
    • F3 / Ctrl+click: Go to declaration.
    • Ctrl+Alt+H: show all uses (calls) of a method.
    • Alt+Left: previous cursor position.
  • Important:
    • F4: show Type Hierarchy.
    • Ctrl+O: search for method in class (great for navigating big classes).
  • Others:
    • Ctrl+Shift+F: Format selection.
  • Alt+Shift+A: Toggle block-editing mode.
if(pm.environment.get("key") === undefined){
pm.environment.set("key", "value");
}
@JoseHdez2
JoseHdez2 / .gitconfig
Created October 23, 2019 11:44
Git config with aliases
[alias]
alias = config --get-regexp ^alias\\.
co = checkout
cob = checkout -b
logtree = log --all --decorate --oneline --graph
logi = log --oneline
c = commit -m
ac = commit -am
cp = cherry-pick
b = branch
@JoseHdez2
JoseHdez2 / range.js
Created November 4, 2019 23:56
range in ECMAscript 6
// https://www.westworld.be/range-in-es6/
//range from 0 => n
const range =[...Array(n).keys()];
console.log(range);
//Range from start => end
@JoseHdez2
JoseHdez2 / sort-by-date.sh
Created November 25, 2019 09:48
Sort files in current directory into folders by date (YYYY-MM-DD)
#!/bin/bash
for x in *.*; do
d=$(date -r "$x" +%Y-%m-%d)
mkdir -p "$d"
mv -- "$x" "$d/"
done
/**
* Use to wrap a block of code in a test that should throw an exception.
* @param errorMsg Message to show if the block of code DOESN'T throw an exception. Optional.
* @param withExceptionHaving Substring that the thrown exception must contain. Optional.
* Checking exception strings is generally discouraged, and will cause the need to
* periodically readjust the expected strings, but it guarantees the error is the expected one.
*/
fun shouldFail(errorMsg: String = "Should have failed.", withExceptionHaving: String? = null, method: () -> Unit) {
try {
method()
import random
import string
# https://pynative.com/python-generate-random-string/
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
@JoseHdez2
JoseHdez2 / join.ts
Last active August 3, 2022 12:27
Generic version of String.join().
/** `zip([a, b, c], [1, 2, 3] => [[a, 1], [b, 2], [c, 3]])` */
const zip = (a: Array<any>, b: Array<any>) =>
Array.from(Array(Math.max(b.length, a.length)), (_, i) => [a[i], b[i]]);
/** Generic version of String.join(). Add a separator element between each of the elements. */
const join = (a: Array<any>, separator: any) =>
zip(a, Array(a.length - 1).fill(separator))
.flat()
.splice(-1);