Skip to content

Instantly share code, notes, and snippets.

View hyqhyq3's full-sized avatar

hyqhyq_3 hyqhyq3

  • moonton
  • Shanghai China
View GitHub Profile
struct URL
{
std::string Schema;
std::string User;
std::string Pass;
std::string Host;
uint32_t Port;
std::string Path;
std::string Query;
};
#expr = term + expr | term - expr | term
#term = term * factor | term / factor | factor
#factor = '(' expr ')' | number
#
def getch(expr, ch):
while expr[0] == ' ':
expr = expr[1:]
@hyqhyq3
hyqhyq3 / 0_reuse_code.js
Created September 29, 2015 02:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#include <stdlib.h>
#include <boost/regex.hpp>
#include <iostream>
int main()
{
boost::regex e("(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])");
boost::match_results<std::string::const_iterator> what;
const std::string str("哈哈哈 8.8.8.8 1.2.3.4 256.256.247.1");
auto first = str.begin();
auto last = str.end();
Usage: diskutil coreStorage list
Usage: diskutil coreStorage info[rmation] [-plist]
Usage: diskutil coreStorage convert
Usage: diskutil coreStorage revert
Usage: diskutil coreStorage create lvgName
Usage: diskutil coreStorage delete lvgUUID
Usage: diskutil coreStorage addDisk lvgUUID NewMemberDeviceName
Usage: diskutil coreStorage removeDisk pvUUID
Usage: diskutil coreStorage deleteVolume lvUUID
Usage: diskutil coreStorage resizeVolume lvUUID size
@hyqhyq3
hyqhyq3 / daemon.go
Last active December 29, 2015 14:48
cgo daemon
package main
import (
"time"
)
/*
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@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;
var net = require("net");
var server = net.createServer(function(req) {
req.on('data', function(data) {
req.write(data);
});
});
server.listen(8000);
@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>
@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;