This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import gevent | |
from gevent import monkey;monkey.patch_all() | |
import sys, argparse, socket, time | |
def ping(sock, requests): | |
fileobj = sock.makefile() | |
for i in xrange(requests): | |
sock.sendall("PING\r\n") |
This file contains hidden or 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
function test1(co2) | |
print(12) | |
coroutine.resume(co2) | |
print(34) | |
coroutine.resume(co2) | |
end | |
function test2() | |
print(56) |
This file contains hidden or 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 gevent | |
from gevent.queue import Queue | |
q = Queue() | |
session = {} | |
def producer(): | |
i = 1 | |
while True: | |
q.put(i) |
This file contains hidden or 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 <stdio.h> | |
#include <assert.h> | |
#include <stdint.h> | |
#include "lua.h" | |
#include "lauxlib.h" | |
inline int | |
_bytes(uint8_t c) { | |
if(c < 0x80) return 1; |
This file contains hidden or 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
--[[ | |
-- polynomial: 0x104c11db7 | |
-- 根据MSB-first的crc polynomial,生成单字节表 | |
-- http://en.wikipedia.org/wiki/Cyclic_redundancy_check | |
-- http://www.cnblogs.com/esestt/archive/2007/08/09/848856.html | |
-- 这个算法对于crc64应该也是一样的 | |
--]] | |
local polynomial = 0x04c11db7 | |
local length = 32 |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"net" | |
"bufio" | |
) | |
func handleConnection(conn net.Conn) { | |
reader := bufio.NewReader(conn) |
This file contains hidden or 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
package main | |
import "net" | |
import "fmt" | |
import "sync" | |
import "os" | |
var wg sync.WaitGroup | |
var addr *net.TCPAddr |
This file contains hidden or 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 gevent | |
from gevent import monkey;monkey.patch_all() | |
import socket | |
def handle_client(csock): | |
while True: | |
data = csock.recv(1024) | |
csock.sendall(data) | |
csock.close() |
This file contains hidden or 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 <process.h> | |
#include <iostream> | |
void work1(void* p) | |
{ | |
while (1) { | |
printf("hello world"); | |
_sleep(1); | |
} |
This file contains hidden or 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/sh | |
# | |
# Amazon EC2 user-data file for automatic configuration of IPsec/L2TP VPN | |
# on a Ubuntu server instance. Tested with 14.04 (Trusty) AND 12.04 (Precise). | |
# With minor modifications, this script *can also be used* on dedicated servers | |
# or any KVM- or XEN-based Virtual Private Server (VPS) from other providers. | |
# | |
# DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! THIS IS MEANT TO BE RUN WHEN | |
# YOUR AMAZON EC2 INSTANCE STARTS! | |
# |
OlderNewer