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
| // Adapted from Trie code in Algorithms (4 Ed) by Sedgewick | |
| #include <iostream> | |
| #include <string> | |
| // Size of alphabet | |
| constexpr int R = 256; | |
| struct Node | |
| { |
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
| #include <unordered_set> | |
| #include <iostream> | |
| using IntHashTable = std::unordered_set<int>; | |
| void PrintBuckets(const IntHashTable& htab) | |
| { | |
| for (auto bi = 0; bi < htab.bucket_count(); ++bi) | |
| { | |
| std::cout << "B[" << bi << "]:"; |
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 _USE_MATH_DEFINES before including math.h to expose these macro | |
| * definitions for common math constants. These are placed under an #ifdef | |
| * since these commonly-defined names are not part of the C/C++ standards. | |
| */ | |
| /* Definitions of useful mathematical constants | |
| * M_E - e | |
| * M_LOG2E - log2(e) | |
| * M_LOG10E - log10(e) | |
| * M_LN2 - ln(2) |
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
| #include <cstdint> | |
| #include <iostream> | |
| int main() | |
| { | |
| std::cout << "Precise" << std::endl; | |
| std::cout << sizeof(int8_t ) << std::endl; | |
| std::cout << sizeof(int16_t ) << std::endl; | |
| std::cout << sizeof(int32_t ) << std::endl; |
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 char * GetGLErrorStr(GLenum err) | |
| { | |
| switch (err) | |
| { | |
| case GL_NO_ERROR: return "No error"; | |
| case GL_INVALID_ENUM: return "Invalid enum"; | |
| case GL_INVALID_VALUE: return "Invalid value"; | |
| case GL_INVALID_OPERATION: return "Invalid operation"; | |
| case GL_STACK_OVERFLOW: return "Stack overflow"; | |
| case GL_STACK_UNDERFLOW: return "Stack underflow"; |
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
| std::string GetMatDepth(const cv::Mat& mat) | |
| { | |
| const int depth = mat.depth(); | |
| switch (depth) | |
| { | |
| case CV_8U: return "CV_8U"; | |
| case CV_8S: return "CV_8S"; | |
| case CV_16U: return "CV_16U"; | |
| case CV_16S: return "CV_16S"; |
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
| #! /bin/sh | |
| # listppa Script to get all the PPA installed on a system ready to share for reininstall | |
| # From: http://askubuntu.com/questions/148932/how-can-i-get-a-list-of-all-repositories-and-ppas-from-the-command-line | |
| for APT in `find /etc/apt/ -name \*.list`; do | |
| grep -o "^deb http://ppa.launchpad.net/[a-z0-9\-]\+/[a-z0-9\-]\+" $APT | while read ENTRY ; do | |
| USER=`echo $ENTRY | cut -d/ -f4` | |
| PPA=`echo $ENTRY | cut -d/ -f5` | |
| echo sudo apt-add-repository ppa:$USER/$PPA | |
| done |
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
| #include <iostream> | |
| using namespace std; | |
| template <typename Derived> | |
| struct Creature | |
| { | |
| int eye_num; | |
| friend bool operator == (const Derived& lhs, const Derived& rhs) | |
| { |
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
| #include <limits> | |
| std::numeric_limits<int>::max() // INT_MAX | |
| std::numeric_limits<int>::min() // INT_MIN | |
| std::numeric_limits<int>::lowest() // INT_MIN | |
| std::numeric_limits<float>::max() // FLT_MAX | |
| std::numeric_limits<float>::min() // FLT_MIN | |
| std::numeric_limits<float>::lowest() // -FLT_MAX |