Skip to content

Instantly share code, notes, and snippets.

@wengxt
wengxt / db.c
Last active August 29, 2015 14:01
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlite3.h"
using namespace std;
var async = require('async');
var obj = ["a", "b", "c"];
function done()
{
console.log("Done");
}
function output(key, n, cb)
{
var async = require('async');
var obj = ["a", "b", "c"];
function done()
{
console.log("Done");
}
function output(key, n, cb)
{
@wengxt
wengxt / gist:3237739d75af08cca1f2
Created June 16, 2014 03:07
copy-ctor-move-ctor.cc
#include <iostream>
#include <string>
#include <vector>
#define CASE 1
class A {
public:
A(const std::string& _s): s(_s) {
}
@wengxt
wengxt / gist:224766ef6268f1797c11
Created July 16, 2014 09:31
slider and stylesheet
#include "mainwindow.h"
#include <QSlider>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
setStyleSheet("QSlider::handle:horizontal {"
"background-image: url(/usr/share/wallpapers/stripes.png);"
"}");
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main() {
std::string s = "13579";
int result = 0;
std::for_each(s.begin(), s.end(), [&](char n){result = result * 10 + n - '0'; });
@wengxt
wengxt / lafilefixer
Created September 10, 2014 19:38
lafilefixer
#!/bin/bash
# Libtool does not support spaces in dependency_libs entries so we won't worry
# overly about them either.
NEWLINE="
"
has() {
[[ " ${*:2} " == *" $1 "* ]]
@wengxt
wengxt / simple-qobject-factory.c
Created October 16, 2014 14:47
simple-qobject-factory
#include <QObject>
#include <QDebug>
class FactoryBase
{
public:
virtual QObject* create() = 0;
};
QMap<QString, FactoryBase*> factoryMap;
/*
* Copyright (C) 2015~2015 by CSSlayer
* wengxt@gmail.com
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
# - Try to find the GETTEXT-PO libraries
# Once done this will define
#
# GETTEXTPO_FOUND - system has GETTEXT-PO
# GETTEXTPO_INCLUDE_DIR - the GETTEXT-PO include directory
# GETTEXTPO_LIBRARIES - GETTEXT-PO library
#
# Copyright (c) 2012 Yichao Yu <yyc1992@gmail.com>
# Copyright (c) 2015 Weng Xuetian <wengxt@gmail.com>
#