Skip to content

Instantly share code, notes, and snippets.

View gist:30306a0fb5b4acf964528ffc71230f71
#include <iostream>
template <typename F, typename T1, typename T2>
void flip2(F f, T1 &&t1, T2 &&t2)
f(t2, t1);
void g(int &&i, int &j)
Charles0429 / gist:bed283d6a20900b9789a
Created Jul 30, 2014
an automatically expandable buffer
View gist:bed283d6a20900b9789a
#include "cstr.h"
cstr cstr_new_len(const char *str, int len)
cstr_internal *ci;
int size;
size = sizeof(cstr_internal) + len + 1;
View gist:106553afa21433b00459
int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout) {
int s, rv;
char _port[6]; /* strlen("65535"); */
struct addrinfo hints, *servinfo, *p;
int blocking = (c->flags & REDIS_BLOCK);
snprintf(_port, 6, "%d", port);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;