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 simple example of json string parsing with json-c. | |
| * | |
| * clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c | |
| */ | |
| #include <json.h> | |
| #include <stdio.h> | |
| int main() { | |
| struct json_object *jobj; |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| //http://stackoverflow.com/questions/18424101/c-small-char-to-hex-function | |
| #include <string> | |
| #include <iostream> | |
| std::string bin2hex(const std::string& input) | |
| { | |
| std::string res; | |
| const char hex[] = "0123456789ABCDEF"; | |
| for(auto sc : input) |
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
| // from http://stackoverflow.com/questions/191757/c-concatenate-string-and-int | |
| std::string name = "John"; | |
| int age = 21; | |
| std::string result; | |
| // 1. with Boost | |
| result = name + boost::lexical_cast<std::string>(age); | |
| // 2. with C++11 |
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
| //g++ -std=c++0x ptr.cpp | |
| #include <cstdio> | |
| #include <cstring> | |
| #include <vector> | |
| #include <memory> | |
| using namespace std; |
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/bash | |
| if [ -z "$1" ]; then | |
| echo | |
| echo usage: $0 network-interface | |
| echo | |
| echo e.g. $0 eth0 | |
| echo | |
| echo shows packets-per-second |
OlderNewer