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 | |
users=($(cat /etc/passwd | awk -F":" '{print $1}')) | |
uids=($(cat /etc/passwd | awk -F":" '{print $3}')) | |
for i in "${!users[@]}"; do | |
groups=($(cat /etc/group | grep "^${users[i]}" | awk -F":" '{print $4}')) | |
echo ${users[i]} ${uids[i]} $groups | |
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
{ | |
"payload": [{ | |
"name": "Aquaman", | |
"stars": 5, | |
}, { | |
"name": "Christopher Robin", | |
"stars": 4.5, | |
}] | |
} |
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
double add(double a, double b) { | |
return a + b; | |
} | |
int main() { | |
assert(add(3, 4) == 7); | |
return 0; | |
} |
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
function add(a, b) { | |
return a + b; | |
} | |
let sum = add(3, 4); | |
if (sum !== 7) { | |
console.log("add(3, 4) failed. Expected: 7, Actual: " + sum); | |
} |
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
# Functions. | |
# These are like aliases, but can take arguments | |
# All functions are in ~/.bash_functions for modularity | |
if [ -f ~/.bash_functions ]; then | |
. ~/.bash_functions | |
fi |
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
function extract { | |
if [ -z "$1" ]; then | |
# display usage if no parameters given | |
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>" | |
else | |
if [ -f $1 ] ; then | |
# NAME=${1%.*} | |
# mkdir $NAME && cd $NAME | |
case $1 in | |
*.tar.bz2) tar xvjf ./$1 ;; |
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 extract='tar xvzf' |
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
vector<pair<int, int>> findCells(const vector<pair<int, int>>& gameBoard, const int FLAG_CODE) { | |
if (gameBoard.empty()) { | |
return vector<pair<int, int>> {}; | |
} | |
vector<pair<int, int>> cells; | |
for (pair<int, int> cell : gameBoard) { | |
if (cell.second == FLAG_CODE) { | |
cells.push_back(cell); |
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
int hash(string input) { | |
int output = 5381; | |
// Less collisions than simply adding ASCII characters of value | |
// simple method: hash("tab") = hash("bat") | |
// this method: hash("tab") != hash("bat") | |
for (char c : input) { | |
output += (output << 5) + c; | |
} | |
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
vector<Cell> findCells(const vector<Cell>& gameBoard, const int FLAG_CODE) { | |
vector<Cell> cells; | |
for (Cell cell : gameBoard) { | |
if (cell.status == FLAG_CODE) { | |
cells.push_back(cell); | |
} | |
} | |
return cells; |
NewerOlder