Skip to content

Instantly share code, notes, and snippets.

View autosquid's full-sized avatar

mightu autosquid

  • HangZhou, ZheJiang, China.
View GitHub Profile
@autosquid
autosquid / get_cc_options.cmake
Created August 4, 2015 12:25
cmake get compiler options
macro(get_gcc_compile_flags target flags)
string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" name)
set(flags "${${name}} ${CMAKE_CXX_COMPILER_ARG1}")
get_target_property(value ${target} COMPILE_FLAGS)
if (value)
list(APPEND flags ${value})
endif()
get_target_property(value ${target} TYPE)
get_target_property(value ${target} COMPILE_DEFINITIONS)
if (value)
@autosquid
autosquid / threadpool.cpp
Created August 19, 2015 14:06
boost thread pool
namespace bamthread
{
typedef std::unique_ptr<boost::asio::io_service::work> asio_worker;
struct ThreadPool {
ThreadPool(size_t threads) :service(), working(new asio_worker::element_type(service)) {
while(threads--)
{
auto worker = boost::bind(&boost::asio::io_service::run, &(this->service));
g.add_thread(new boost::thread(worker));
@autosquid
autosquid / updatepython27.py
Created September 1, 2015 08:22
update osx system python
#!/bin/bash
cd /System/Library/Frameworks/Python.framework/Versions
mv 2.7 2.7.bk
mv /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions
chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/2.7
rm /System/Library/Frameworks/Python.framework/Versions/Current
@autosquid
autosquid / batchopensearch.py
Last active October 26, 2015 06:11
python script for batch opening urls and searching with keywords
def slowopen(fname):
with open(fname, 'r') as f:
for url in f:
# url = slowopen_ieee(url)
if platform.system() == 'Darwin':
os.system(" ".join(["open -a Safari", url]))
#os.system(" ".join(["open", url]))
else:
os.system(" ".join(["start", url]))
time.sleep(5)
@autosquid
autosquid / printinfo.hpp
Created October 29, 2015 08:10
A trick for partial specialization of function template
/**
partial specialization of function template is under consideration of C++ Standards Committee
But before that, we need some tricks
*/
#include "boost/format.hpp"
namespace bamutils{
From 870284ed31792708a6139925d00a0aadf46bf09f Mon Sep 17 00:00:00 2001
From: Christopher Moore <[email protected]>
Date: Mon, 24 Aug 2015 14:29:02 -0400
Subject: [PATCH] Fixed missing symbols in libboost_log_setup (on mac/clang)
---
include/boost/log/detail/setup_config.hpp | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/boost/log/detail/setup_config.hpp b/boost/log/detail/setup_config.hpp
@autosquid
autosquid / preprocessor_fun.h
Created December 21, 2015 08:57 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@autosquid
autosquid / get_gcc_compile_flags.cmake
Created December 22, 2015 19:00
cmake get_gcc_compile_flags
macro(get_gcc_compile_flags target flags)
string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" name)
set(flags "${${name}} ${CMAKE_CXX_COMPILER_ARG1}")
get_target_property(value ${target} COMPILE_FLAGS)
if (value)
list(APPEND flags ${value})
endif()
get_target_property(value ${target} TYPE)
get_target_property(value ${target} COMPILE_DEFINITIONS)
if (value)
@autosquid
autosquid / opencvyaml1-1.py
Last active September 26, 2022 08:08
pyyaml loading opencv yaml
# construct node
def opencv_matrix(loader, node):
mapping = loader.construct_mapping(node, deep=True)
mat = np.array(mapping["data"])
mat.resize(mapping["rows"], mapping["cols"])
return mat
yaml.add_constructor(u"tag:yaml.org,2002:opencv-matrix", opencv_matrix)
# loading
@autosquid
autosquid / samuels_python3_setup.md
Created February 17, 2016 09:44 — forked from samueljohn/samuels_python3_setup.md
For my own reference. Brewed Python3, numpy, scipy and the rest goes in a pyvenv.

Samuel's Python3 setup for Mac:

This document describes in which way, what packages, and from where are installed on my Macs to get a decent Python 3.x, scipy/numpy & Co setup.

Note, I switched to Python's 3.x pyvenv from virtualenv in order to handle my pip-installable packages. Also thanks to Anaconda, the whole setup is so simple now that I use this document just to remember which additional packages I like.