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> | |
int main() | |
{ | |
int i = 9876; | |
float f = 3.14; | |
std::string si = std::to_string(i); | |
std::string sf = std::to_string(f); |
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
# Check if Qt4 is present | |
find_package(Qt4 REQUIRED) | |
# Add Qt headers for compiling | |
include( | |
${QT_USE_FILE} | |
) | |
# Add Qt definitions for compilation | |
add_definitions( |
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
// Sample code to demonstrate emplace_back operation of vector | |
#include <iostream> | |
#include <vector> | |
struct Creature | |
{ | |
Creature() : is_mammal_(false), age_(0), population_(0) | |
{ | |
std::cout << "Default constructor called\n"; |
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
# Class to execute a function in parallel across multiple data | |
# Adapted from code in Sec 9.5 of book Python Cookbook (2 Ed) | |
import threading | |
import time | |
import Queue | |
class MultiThread(object): | |
def __init__(self, function, argsVector, commonArgs, maxThreads=5, queue_results=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
// Checking for math error in C++ | |
#include <cerrno> | |
#include <cmath> | |
#include <cstring> | |
#include <iostream> | |
std::cout << log(0) << std::endl; | |
if (errno) | |
std::cout << std::strerror(errno) << std::endl; |
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
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,00,00,3a,00,00,00,00,00 |
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 <mutex> | |
#include <queue> | |
std::queue<int> q; // Queue which multiple threads might add/remove from | |
std::mutex m; // Mutex to protect this queue | |
void AddToQueue(int i) | |
{ | |
m.lock(); | |
q.push(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 <mutex> | |
#include <queue> | |
std::queue<int> q; // Queue which multiple threads might add/remove from | |
std::mutex m; // Mutex to protect this queue | |
void AddToQueue(int i) | |
{ | |
std::lock_guard<std::mutex> lg(m); // Lock will be held from here to end of function | |
q.push(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
:%s/\<foo\>/abracadabra/ |