This file contains hidden or 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
run_mode=debug | |
echo () | |
{ | |
[[ "$run_mode" ]] && builtin echo $@ | |
} |
This file contains hidden or 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
clearDisplay() | |
{ | |
clear && printf '\e[3J' | |
} |
This file contains hidden or 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 with extension | |
find ~/ -iname "*.jpg" | |
# Find something with a matching name | |
find ~/ -name "Y" |
This file contains hidden or 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
// Checkout branch and track remote | |
git checkout -b feature/project --track origin/feature/project | |
// Show current branch name | |
git rev-parse --abbrev-ref HEAD | |
// Show all local branches with your starred: | |
git branch | |
// Are we up to date with remote |
This file contains hidden or 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
// round n down to nearest multiple of m | |
int roundDown (int n, int m) | |
{ | |
return n >= 0 ? (n / m) * m : ((n - m + 1) / m) * m; | |
} | |
// round n up to nearest multiple of m | |
int roundUp (int n, int m) | |
{ | |
return n >= 0 ? ((n + m - 1) / m) * m : (n / m) * m; |
This file contains hidden or 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 convertRGB565ToRGB888 (int c) | |
{ | |
int a = 255; | |
int r5 = ((c >> 11) & 0x1F); | |
int g6 = ((c >> 5) & 0x3F); | |
int b5 = ((c) & 0x1F); | |
int r8 = (r5 * 255 + 15) / 31; | |
int g8 = (g6 * 255 + 31) / 63; |
This file contains hidden or 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
#define BitVal(data,y) ( (data>>y) & 1) /** Return Data.Y value **/ | |
#define SetBit(data,y) data |= (1 << y) /** Set Data.Y to 1 **/ | |
#define ClearBit(data,y) data &= ~(1 << y) /** Clear Data.Y to 0 **/ | |
#define TogleBit(data,y) (data ^=BitVal(y)) /** Togle Data.Y value **/ | |
#define Togle(data) (data =~data ) /** Togle Data value **/ |
This file contains hidden or 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 pack (int a, int r, int g, int b) | |
{ | |
return a << 24 + r << 16 + g<< 8 + b; | |
} | |
void unpack (int& a, int& r, int& g, int& b, const int argb) | |
{ | |
a = (argb >> 24) & 0xFF; | |
r = (argb >> 16) & 0xFF; | |
g = (argb >> 8) & 0xFF; |
This file contains hidden or 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
const auto myString = R"identifier( | |
This string wont be "processed" like a normal string | |
Line breaks will be preserved | |
And you wont need to do escapes... | |
)identifier"; |
This file contains hidden or 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
a.insert (std::end (a), std::begin (b), std::end (b)); | |
// Less efficient but can be used for const members: | |
std::copy (std::begin (b), std::end (b), std::back_inserter (a)); |