Skip to content

Instantly share code, notes, and snippets.

@waveacme
waveacme / json_parser.c
Created April 7, 2016 09:40 — forked from alan-mushi/json_parser.c
Examples for the json-c tutorial.
/*
* 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;
@waveacme
waveacme / 0_reuse_code.js
Created April 11, 2016 07:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@waveacme
waveacme / bin2hex.cpp
Last active September 10, 2021 01:25
c++ version of bin2hex
//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)
@waveacme
waveacme / append.cpp
Created April 15, 2016 03:54
append int to string in c++
// 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
@waveacme
waveacme / ptr.cpp
Created May 11, 2016 08:26
c++11 shared_ptr example
//g++ -std=c++0x ptr.cpp
#include <cstdio>
#include <cstring>
#include <vector>
#include <memory>
using namespace std;
@waveacme
waveacme / netpps.sh
Created November 1, 2017 01:37 — forked from joemiller/netpps.sh
shell: quick linux scripts for showing network bandwidth or packets-per-second
#!/bin/bash
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second