Skip to content

Instantly share code, notes, and snippets.

View yifu's full-sized avatar

Yves Baumes yifu

  • Montpellier, France
View GitHub Profile
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main () {
int myints[] = {10,20,30,30,20,10,10,20};
vector<int> v(myints,myints+8);
vector<int>::iterator low,up;
@yifu
yifu / Makefile
Created September 21, 2012 15:01
unix network tests.
error2str.o: error2str.h error2str.cpp
g++ -c error2str.cpp
client.cpp: error2str.h
client.o: client.cpp
g++ -c client.cpp
@yifu
yifu / server.cpp
Created September 21, 2012 15:00
unix network tests.
#include <iostream>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/socket.h>
#include "error2str.h"
int main(int argc, char* argv[])
{
const int fd = socket(AF_INET,SOCK_STREAM,0/*protocol*/);
if (fd == -1)
@yifu
yifu / error2str.h
Created September 21, 2012 15:00
unix network test.
#ifndef ERROR2STR
#define ERROR2STR
#include <errno.h>
// --------------------------------------------------------------
namespace std
{
template<typename _Alloc>
class allocator;
@yifu
yifu / error2str.cpp
Created September 21, 2012 14:59
unix network test.
#include <sstream>
#include <string>
#include <errno.h>
// --------------------------------------------------------------
std::string error2str(const int err)
{
char buf[1024] = "";
errno = 0;
@yifu
yifu / client.cpp
Created September 21, 2012 14:59
unix_network test.
#include <iostream>
#include <sstream>
#include <string>
#include <errno.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
@yifu
yifu / test.cpp
Created September 21, 2012 14:58
#include <iostream>
class StaticClassType {
public:
StaticClassType()
{
// Notify when the static member is created
std::cout << "We're in." << std::endl;
}
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#include <google/heap-profiler.h>
// Usage is HEAPPROFILE=./profiler.hprof ./test
// Then,
/*
test : test.cpp
g++ -o test test.cpp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -I /Soft/mag/dev/tools/google-perftools/include/ /Soft/mag/dev/tools/google-perftools/lib/libtcmalloc_and_profiler.a
#test : test.cpp
# g++ -o test test.cpp
*/
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
map<string,string> tmp;