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
| 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() { |
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/http" | |
| "github.com/urfave/negroni" | |
| ) | |
| func main() { | |
| mux := http.NewServeMux() |
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
| 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 |
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
| 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)) | |
| } |
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 token | |
| import ( | |
| "io/ioutil" | |
| "encoding/json" | |
| "net/http" | |
| "github.com/sirupsen/logrus" | |
| "github.com/qiniu/api.v7/storage" | |
| "fmt" |
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
| // 首先实现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; |
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
| https://jex.im/regulex/ | |
| # 合法URL | |
| (https?)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|] |
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
| #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 |
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
| XMLConfiguration cnf; | |
| { // remote | |
| cnf = new BasicConfigurationBuilder<>(XMLConfiguration.class) | |
| .configure(new Parameters().xml()).getConfiguration(); | |
| InputStream is = new ByteArrayInputStream( | |
| "xxxxxxxxxxxx".getBytes() | |
| ); | |
| new FileHandler(cnf).load(is); | |
| } |
NewerOlder