- Avoid comments when possible; they are unnecessary and may potentially lie.
- Use clear method (and variable) names, as long as necessary.
- Break down long methods
- Avoid secondary effects when possible; they obfuscate the code.
- Use constants/enums instead of literals; they help maintainability.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
- 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(pm.environment.get("key") === undefined){ | |
pm.environment.set("key", "value"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.westworld.be/range-in-es6/ | |
//range from 0 => n | |
const range =[...Array(n).keys()]; | |
console.log(range); | |
//Range from start => end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for x in *.*; do | |
d=$(date -r "$x" +%Y-%m-%d) | |
mkdir -p "$d" | |
mv -- "$x" "$d/" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** `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); |
OlderNewer