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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo | |
echo usage: $0 network-interface | |
echo | |
echo e.g. $0 eth0 | |
echo | |
echo shows packets-per-second |
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
//g++ -std=c++0x ptr.cpp | |
#include <cstdio> | |
#include <cstring> | |
#include <vector> | |
#include <memory> | |
using namespace std; |
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
// 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 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 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 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 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 "UITableView+reloadDataAnimated.h" | |
@implementation UITableView (reloadDataAnimated) | |
- (void)reloadDataWithAnimated:(BOOL)animated | |
{ | |
[self reloadData]; | |
if (animated) { | |
CATransition *animation = [CATransition animation]; |
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 <stdlib.h> | |
#include <stdio.h> | |
#include "list.h" | |
typedef struct episode { | |
int epid; | |
struct list_head list; | |
} episode_t; |
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 "logger.h" | |
int DebugLevel = DEBUG_WARN; | |
int main(void) | |
{ | |
DBGPRINT(DEBUG_WARN, ("hello,debug=%s\n", "aaa")); | |
return 0; | |
} |
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
// | |
// 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 |
NewerOlder