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 <random> | |
| std::random_device rd; | |
| std::mt19937 gen(rd()); | |
| std::uniform_int_distribution<> dis(1, 6); | |
| const int rnd = dis(gen); | |
| std::random_device rd; | |
| std::mt19937 gen(rd()); | |
| std::uniform_real_distribution<> dis(-1.f, 1.f); |
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
| ls -al@ |
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
| NSMutableArray *arguments = [[NSMutableArray alloc] init]; | |
| [arguments addObject:[[NSBundle mainBundle] pathForResource:@"MyScript" ofType:@"py"]]; | |
| [arguments addObject:@"--verbose"]; // Any arguments you want here... | |
| NSTask* task = [[NSTask alloc] init]; | |
| task.launchPath = @"/usr/bin/python"; | |
| task.arguments = arguments; | |
| NSMutableDictionary *defaultEnv = [[NSMutableDictionary alloc] initWithDictionary:[[NSProcessInfo processInfo] environment]]; | |
| [defaultEnv setObject:@"YES" forKey:@"NSUnbufferedIO"] ; |
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
| #import <Cocoa/Cocoa.h> | |
| @interface DragAndDropTextField : NSTextField | |
| @end |
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
| set set target.max-string-summary-length 10000 |
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
| void setConsoleCursorVisibility (const bool visible) | |
| { | |
| if (! visible) | |
| std::cout << "\033[?25l" << std::flush; | |
| else | |
| std::cout << "\033[?25h" << std::flush; | |
| } |
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
| (sizeof(a) / sizeof(*a)) |
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)); |
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
| 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; |