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
# Homebrew | |
brew update | |
brew install p7zip | |
# Macport | |
sudo port install p7zip |
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
// Clear all the nodes inside the element with id 'main-area' | |
function clearView() { | |
var mainArea = document.getElementById('main-area'); | |
var firstChild = mainArea.firstChild; | |
while (firstChild) { | |
mainArea.removeChild(firstChild); | |
firstChild = mainArea.firstChild; | |
} | |
} |
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
let arr = ['a', 'b', 'c']; | |
Object.keys(arr).forEach(key => { | |
console.log(key) | |
}); |
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
// using Array.from | |
let array = Array.from(mySet); | |
// simply spreading the Set out in an array | |
let array = [...mySet]; |
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
# $ python main_func.py | |
def main(): | |
print("Hello from main()") | |
if __name__ == '__main__': | |
main() |
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
# HTML Encoding | |
try: | |
from html import escape # python 3.x | |
except ImportError: | |
from cgi import escape # python 2.x | |
print(escape("<")) | |
# HTML Decoding | |
try: |
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
public class Test { | |
private int num; | |
private String data; | |
public boolean equals(Object obj) { | |
if (this == obj) { | |
return true; | |
} | |
if ((obj == null) || (obj.getClass() != this.getClass())) { |
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
APP_PROJECT_PATH := <path to project> |
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
str="asdkljfgaskdlgjkladsjfg123_abc_d4e5#asdfgerhgreg" | |
regex="[0-9]+_([a-z]+)_[0-9a-z]*" | |
if [[ $str =~ $regex ]] | |
then | |
name="${BASH_REMATCH[1]}" | |
echo "${name}.jpg" # 123_abc_d4e5.jpg | |
name="${name}.jpg" # same thing stored in a variable | |
else | |
echo "$str doesn't match" >&2 |
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
find /path/to/dir -name "filename" | |
find /path/to/dir -name "*.h" |