Skip to content

Instantly share code, notes, and snippets.

E7 e7

Block or report user

Report or block e7

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
@e7
e7 / get-active-window.c
Last active Jan 18, 2019
xwininfo也可以获取窗口id号
View get-active-window.c
// -*- coding:utf-8-unix; mode:c; -*-
/*
get the active window on X window system
http://k-ui.jp/blog/2012/05/07/get-active-window-on-x-window-system/
*/
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
@e7
e7 / capture.conf
Last active Jan 12, 2018
capture location for nginx
View capture.conf
location /capture/ {
internal;
rewrite ^/capture/(https?)/([^/]+)/(\d+)/(.*) /$4 break;
proxy_pass $1://$2:$3;
}
usage like this:
-- url: http://www.hejizhan.com/s/forum.php
ngx.location.capture("/capture/http/www.hejizhan.com/80/s/forum.php"
@e7
e7 / scoped_thread.cpp
Last active Jan 11, 2018
raii确保c++11线程被join
View scoped_thread.cpp
class scoped_thread
{
std::thread t;
public:
explicit scoped_thread(std::thread t_) : t(std::move(t_)) {
if (!t.joinable()) {
throw std::logic_error(“No thread”);
}
}
~scoped_thread() {
@e7
e7 / gohfs.go
Created Jan 9, 2018
简单的http文件服务器
View gohfs.go
package main
import (
"net/http"
"github.com/urfave/negroni"
)
func main() {
mux := http.NewServeMux()
@e7
e7 / body-parser.go
Created Jan 8, 2018
negroni的middleware示例
View body-parser.go
type bodyParser struct{
unused int;
}
func NewBodyParser() (*bodyParser){
return &bodyParser{}
}
func (m *bodyParser) ServeHTTP(rsp http.ResponseWriter, req *http.Request, next http.HandlerFunc) {
var err error
@e7
e7 / golang-orm.go
Created Jan 4, 2018
golang的orm示例(mysql)
View golang-orm.go
applist := make([]appinfo, 0)
for rows.Next() {
elmts := reflect.ValueOf(&appinfo{}).Elem()
onerow := make([]interface{}, elmts.NumField())
for i := 0; i < elmts.NumField(); i++ {
onerow[i] = elmts.Field(i).Addr().Interface()
}
rows.Scan(onerow...)
applist = append(applist, elmts.Interface().(appinfo))
}
@e7
e7 / qiniu-token.go
Last active Mar 8, 2018
七牛云上传示例
View qiniu-token.go
package token
import (
"io/ioutil"
"encoding/json"
"net/http"
"github.com/sirupsen/logrus"
"github.com/qiniu/api.v7/storage"
"fmt"
@e7
e7 / example_apache_pool2.java
Created Dec 26, 2017
apache common pool2用法
View example_apache_pool2.java
// 首先实现PooledObjectFactory接口
public interface PooledObjectFactory<T> {
PooledObject<T> makeObject() throws Exception;
void destroyObject(PooledObject<T> var1) throws Exception;
boolean validateObject(PooledObject<T> var1);
void activateObject(PooledObject<T> var1) throws Exception;
View example_regex.txt
https://jex.im/regulex/
# 合法URL
(https?)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]
@e7
e7 / check_type.hpp
Last active May 3, 2018
check type
View check_type.hpp
#ifndef CHECK_TYPE_HPP___
#define CHECK_TYPE_HPP___
#include <typeinfo> // typeid
#include <sstream> // std::ostringstream, std::string
#include <type_traits> // std::is_array
#include <utility> // std::move
#if defined(__GNUC__)
#include <memory> // std::unique_ptr
#include <cxxabi.h> // abi::__cxa_demangle
You can’t perform that action at this time.