Skip to content

Instantly share code, notes, and snippets.

Charles Charles0429

Block or report user

Report or block Charles0429

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
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;
if(str)
{
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);
memset(&hints,0,sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
You can’t perform that action at this time.