Skip to content

Instantly share code, notes, and snippets.

View hyqhyq3's full-sized avatar

hyqhyq_3 hyqhyq3

  • moonton
  • Shanghai China
View GitHub Profile
@hyqhyq3
hyqhyq3 / gist:3925580
Created October 21, 2012 03:39
牌面翻转
var t = new Date().getTime()
function getTime() {
return (new Date().getTime()-t)/1000;
}
function fun(n,order) {
console.log(getTime(),"卡片" + n + "正面")
setTimeout(function(){
console.log(getTime(),"卡片" + n + "反面")
setTimeout(function(){
conn,err := net.Dial("tcp", "test.com:1024")
if err != nil {
//这里如何确定出错的原因
//是因为主机不可达,还是因为不能解析域名,或者说是连接被拒绝?
}
// Copyright 2006 Nemanja Trifunovic
// Copyright 2011 Jack.arain
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
@hyqhyq3
hyqhyq3 / streambuf.js
Last active December 18, 2015 07:09 — forked from anonymous/streambuf.js
/**
* Created with JetBrains WebStorm.
* User: kiyangqi
* Date: 13-6-9
* Time: 下午11:36
* To change this template use File | Settings | File Templates.
*/
function StreamBuf() {
this.chunks = [];
INCLUDE (FindPackageHandleStandardArgs)
FIND_PATH (FFMPEG_ROOT_DIR
NAMES libavcodec/avcodec.h include/libavcodec/avcodec.h
PATHS ENV FFMPEG_ROOT
DOC "FFmpeg root directory")
FIND_PATH (FFMPEG_INCLUDE_DIR
NAMES libavcodec/avcodec.h
HINTS ${FFMPEG_ROOT_DIR}
#include <iostream>
#include <boost/bind.hpp>
class T {
public:
T() {
}
T(T&& other) {
std::cout << "moving" << std::endl;
@hyqhyq3
hyqhyq3 / echo_server.cpp
Created August 29, 2013 04:44
echo_server.cpp g++ -O3 echo_server.cpp -lboost_system -lboost_thread -o echo_server
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
using boost::asio::ip::tcp;
@hyqhyq3
hyqhyq3 / echo_client.cpp
Created August 29, 2013 04:45
g++ -O3 -lboost_system -lboost_thread echo_client.cpp -o echo_client
#include <boost/asio.hpp>
namespace asio = boost::asio;
using asio::ip::tcp;
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
class session
: public boost::enable_shared_from_this<session>
var net = require("net");
var server = net.createServer(function(req) {
req.on('data', function(data) {
req.write(data);
});
});
server.listen(8000);
@hyqhyq3
hyqhyq3 / gist:7444287
Created November 13, 2013 05:39
ini grammar
template<typename Iterator>
struct IniGrammar
: qi::grammar<Iterator, std::map<std::string, std::string>()>
{
IniGrammar()
: IniGrammar::base_type(start)
{
using ascii::char_;
using qi::lexeme;
using spirit::skip;