Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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 / UITableView+reloadDataAnimated.m
Created April 6, 2016 08:24 — forked from tony0x59/UITableView+reloadDataAnimated.m
tableview重载数据时的淡入淡出动画过渡效果
#import "UITableView+reloadDataAnimated.h"
@implementation UITableView (reloadDataAnimated)
- (void)reloadDataWithAnimated:(BOOL)animated
{
[self reloadData];
if (animated) {
CATransition *animation = [CATransition animation];
@waveacme
waveacme / example.c
Last active April 12, 2023 12:07
linux list.h for userspace
#include <stdlib.h>
#include <stdio.h>
#include "list.h"
typedef struct episode {
int epid;
struct list_head list;
} episode_t;
@waveacme
waveacme / logger.c
Created March 25, 2016 02:45
a macro logger for c
#include "logger.h"
int DebugLevel = DEBUG_WARN;
int main(void)
{
DBGPRINT(DEBUG_WARN, ("hello,debug=%s\n", "aaa"));
return 0;
}
@waveacme
waveacme / ViewController.swift
Created March 18, 2016 09:19
text filed delegate sample
//
// ViewController.swift
// FoodTracker
//
// Created by Jane Appleseed on 5/23/15.
// Copyright ? 2015 Apple Inc. All rights reserved.
// See LICENSE.txt for this sample’s licensing information.
//
import UIKit