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
#include <iostream> | |
// Example from Jason Turner's video. | |
// https://youtu.be/JtUZmkvroKg?t=290 | |
void print(int i, const std::string_view s) { | |
std::cout << i << ' ' << s << '\n'; | |
} | |
int 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
#include <iostream> | |
#include <string> | |
#include <memory> | |
#include <algorithm> | |
class DataObject { | |
public: | |
DataObject(std::string_view 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
based on: "A shortcut for wrapping Objective-C objects in C++" | |
http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++ | |
don't forget to turn off ARC: | |
You can disable ARC for individual files in XCode under the 'Build Phases' tab in the build target's properties. | |
Fold out the 'Compile Sources' section and add `-fno-objc-arc` to the compiler flags for the file(s) in question. | |
for MyObject.mm (`-fno-objc-arc`) | |
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
/* | |
Given an input string, reverse the string word by word. | |
Example: | |
Input: "the sky is blue", | |
Output: "blue is sky the". | |
Note: |
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
/* | |
Implement atoi which converts a string to an integer. | |
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. | |
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. | |
If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. | |
If no valid conversion could be performed, a zero value is returned. |
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
/* | |
Validate if a given string is numeric. | |
Some examples: | |
"0" => true | |
" 0.1 " => true | |
"abc" => false | |
"1 a" => false | |
"2e10" => true |
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
#include <vector> | |
#include <iostream> | |
#include <sstream> | |
std::string RLE(std::string data) { | |
std::stringstream ss; | |
auto size = data.size(); | |
size_t sequenceCounter = 0; | |
for (size_t i = 0; i < size; i++) { | |
auto currentChar = data[i]; |
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
#include <vector> | |
#include <iostream> | |
#include <string> | |
std::string simpleRotate(const std::string data) { | |
return std::string(data.rbegin(), data.rend()); | |
} | |
std::string badRotate(std::string data) { | |
auto size = data.size(); |
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
#include <vector> | |
#include <iostream> | |
template<class T> | |
std::vector<T> bubbleSort(std::vector<T> data) { | |
bool changed; | |
do { | |
changed = false; |
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
# debian | |
apt-get install vim curl sudo tmux htop mc | |
apt-get install git |