Skip to content

Instantly share code, notes, and snippets.

@limingzju
limingzju / SSLTest.java
Created September 21, 2014 05:29
https java test
package hello;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import javax.net.ssl.SSLContext;
@limingzju
limingzju / rwmutex.go
Created June 5, 2014 06:57
go read write lock
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sync
import (
"sync/atomic"
"unsafe"
)
@limingzju
limingzju / rwlock.cc
Last active August 29, 2015 14:02
read write lock
#include <pthread.h>
struct rwlock {
pthread_mutex_t lock;
pthread_cond_t read, write;
unsigned readers, writers, read_waiters, write_waiters;
};
void reader_lock(struct rwlock *self) {
pthread_mutex_lock(&self->lock);
@limingzju
limingzju / EchoServer.py
Created September 8, 2013 10:19
A simple Python echo server, show how to write socket program use python.
# Echo server program
import socket
HOST = '' # Symbolic name meaning all available interfaces
PORT = 50007 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()