Skip to content

Instantly share code, notes, and snippets.

#include <sys/signal.h>
#include <unistd.h>
void handler()
{
write(2, "a\n", 2);
}
int main(void) {
signal(SIGSEGV, handler);
include(ECMFindModuleHelpersStub)
ecm_find_package_version_check(XKBCommon)
# Note that this list needs to be ordered such that any component
# appears after its dependencies
set(XKBCommon_known_components
XKBCommon
X11)
# - find where dlopen and friends are located.
# DL_FOUND - system has dynamic linking interface available
# DL_INCLUDE_DIR - where dlfcn.h is located.
# DL_LIBRARY - libraries needed to use dlopen
include(CheckFunctionExists)
find_path(DL_INCLUDE_DIR NAMES dlfcn.h)
find_library(DL_LIBRARY NAMES dl)
if(DL_LIBRARY)
# - 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>
#
/*
* 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,
@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;
@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 "* ]]
#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 / 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);"
"}");
@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) {
}