This file contains 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
struct Foo { | |
void overloadedFunction(); | |
void overloadedFunction(int, QString); | |
}; | |
// requires C++14 | |
qOverload<>(&Foo:overloadedFunction) | |
qOverload<int, QString>(&Foo:overloadedFunction) | |
// same, with C++11 |
This file contains 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 <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <errno.h> | |
struct process_info { | |
char* name; | |
char* path; |
This file contains 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/python3 | |
# coding = utf-8 | |
# youdao.py | |
# To-do: get meaning of a word from youdao.com | |
# Author: alen | |
# Date: 2017/08/05 | |
import urllib.parse | |
import urllib.request |
This file contains 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
const WsStateDisconnected = 0; | |
const WsStateDisconnecting = 1; | |
const WsStateConnected = 2; | |
const WsStateConnecting = 3; | |
class SimpleWSocket { | |
constructor(url) { | |
this.wsState = WsStateDisconnected; | |
this.timer = null; | |
this.url = url; | |
this.ws = null; |
This file contains 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 | |
// copy from | |
// https://stackoverflow.com/questions/14116840/dynamically-call-method-on-interface-regardless-of-receiver-type | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Test struct { | |
Start string |
This file contains 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 ( | |
"bufio" | |
"database/sql" | |
"github.com/alenstar/nanoweb/log" | |
_ "github.com/go-sql-driver/mysql" | |
"os" | |
"strings" | |
) |
This file contains 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
const Lang = imports.lang; | |
const Soup = imports.gi.Soup; | |
let _session = new Soup.SessionAsync(); | |
function POSTJSON(url, params, callback) { | |
log('post started'); | |
let request = Soup.Message.new('POST', url); | |
log('req created'); | |
let _params = JSON.stringify(params) |
This file contains 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
const Lang = imports.lang; | |
const Soup = imports.gi.Soup; | |
let _session = new Soup.SessionAsync(); | |
function POST(url, params, callback) { | |
let request = Soup.Message.new('POST', url); | |
let _params = Soup.form_encode_hash(params); | |
request.set_request('application/x-www-form-urlencoded', |
This file contains 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
const Lang = imports.lang; | |
const Soup = imports.gi.Soup; | |
let _session = new Soup.SessionAsync(); | |
function GET(url, callback) { | |
let request = Soup.Message.new('GET', url); | |
_session.queue_message(request, Lang.bind(this, | |
function(session, message) { |
This file contains 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 UTIL_STRING_UTILS_HPP | |
#define UTIL_STRING_UTILS_HPP | |
// trim from start | |
static inline std::string &string_ltrim(std::string &s) { | |
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); | |
return s; | |
} | |
// trim from end |
NewerOlder