Skip to content

Instantly share code, notes, and snippets.

View phcerdan's full-sized avatar

Pablo Hernandez-Cerdan phcerdan

View GitHub Profile
@phcerdan
phcerdan / fix_gfortran_lib_rpaths.sh
Last active September 10, 2020 15:45
fix_gfortran_lib_rpaths.sh
#!/bin/bash
####################
# Display help
display_usage() {
echo "Replace relative paths: @rpath/libname.dylib for /fullpath/libname.dylib."
echo " otool -L libname.dylib"
echo " install_name_tool -id \${full_libpath} -change \${@rpath/libname} \${full_libpath} -change ... \${full_libpath}"
echo -e "\nUsage:\n $(basename "$0") /path/gfortran_folder/lib \n"
}
# if less than one argument supplied, display usage
@phcerdan
phcerdan / CMakeLists.txt
Created August 21, 2018 18:45
ale clangtidy with headers using https://github.com/phcerdan/ALE
cmake_minimum_required(VERSION 3.1)
project(ale_test)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Generate compile_commands.json")
add_executable(main main.cpp)
@phcerdan
phcerdan / swap_ordered_data.cpp
Last active April 4, 2018 19:09
Swap ordered data, insert/delete of values in ordered container.
// rotate algorithm example
#include <iostream> // std::cout
#include <algorithm> // std::rotate
#include <vector> // std::vector
std::vector<int> init_data()
{
std::vector<int> data;
// set some values:
for (int i=1; i<10; ++i) data.push_back(i); // 1 2 3 4 5 6 7 8 9
@phcerdan
phcerdan / Move_DISALLOW_COPY_to_public_section.cpp
Created March 28, 2018 20:51 — forked from N-Dekker/Move_DISALLOW_COPY_to_public_section.cpp
The script used for "COMP: Moved ITK_DISALLOW_COPY_AND_ASSIGN calls to public section", http://review.source.kitware.com/#/c/23289/ on Visual C++ 2017
// Script to move ITK_DISALLOW_COPY_AND_ASSIGN calls to the public section
// of the classes.
//
// Niels Dekker, LKEB, Leiden University Medical center, 2018
// Discourse discussion: https://discourse.itk.org/t/noncopyable/648/24
// compiling:
// g++ Move_DISALLOW_COPY_to_public_section.cpp -lstdc++fs
// clang++ Move_DISALLOW_COPY_to_public_section.cpp -lstdc++fs
// Tested with:
[1/1832] Building CXX object Modules/Filtering/GPUA...PUGradientAnisotropicDiffusionImageFilterTest.cxx.o
FAILED: Modules/Filtering/GPUAnisotropicSmoothing/test/CMakeFiles/ITKGPUAnisotropicSmoothingTestDriver.dir/itkGPUGradientAnisotropicDiffusionImageFilterTest.cxx.o
/usr/lib/colorgcc/bin/c++ -std=c++11 -IModules/ThirdParty/KWIML/src -I/home/phc/Software/ITK/ITK-development/Modules/ThirdParty/KWIML/src -IModules/ThirdParty/KWSys/src -I/home/phc/Software/ITK/ITK-development/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/home/phc/Software/ITK/ITK-development/Modules/ThirdParty/VNL/src/vxl/vcl -I/home/phc/Software/ITK/ITK-development/Modules/ThirdParty/VNL/src/vxl/core -IModules/ThirdParty/VNL/src/vxl/v3p/netlib -IModules/ThirdParty/VNL/src/vxl/vcl -IModules/ThirdParty/VNL/src/vxl/core -I/home/phc/Software/ITK/ITK-development/Modules/ThirdParty/VNLInstantiation/include -IModules/Core/Common -I/home/phc/Software/ITK/ITK-development/Modules/Core/Common/include -I/home/phc/Software/ITK/ITK-development/Modules/Core
@phcerdan
phcerdan / vim_s_django_static
Last active October 11, 2017 20:55
Vim regex command for django: substitute hard coded static path to template parameter {% static 'path' %}
" Vim regex command to substitute hard coded static path to template parameter {% static 'path' %}
:s@\v/static/(.{-})"@{% static '\1' %}"
" test:
" <img src="/static/images/user.png" class="avatar" alt="Avatar">
"
" <img src="{% static 'images/user.png' %}" class="avatar" alt="Avatar">
" You can also use it for all hits:
@phcerdan
phcerdan / plot3D_LineCollection.py
Created May 18, 2017 05:11
Python plot3D with LineCollection
"""
=============================================
Generate 3D plot with multiple lines sharing axis.
=============================================
"""
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import LineCollection
import matplotlib.pyplot as plt
@phcerdan
phcerdan / gauss_window_itk.cpp
Last active March 29, 2017 00:50
ITK Apply a gaussian window using FrequencyIterators.
// Apply a gaussian window of the size of the input.
#include "itkGaussianSpatialFunction.h"
#include "itkFrequencyImageRegionIteratorWithIndex.h"
bool apply_gaussian = false;
if(apply_gaussian == true)
{
typedef itk::GaussianSpatialFunction<double, dimension> FunctionType;
typename FunctionType::Pointer gaussian = FunctionType::New();
typedef FixedArray< double, Dimension > ArrayType;
ArrayType m_Mean;
@phcerdan
phcerdan / uncrustify_itk_aggressive_phcerdan.cfg
Last active February 15, 2017 01:11
ITK uncrustify to my taste. Align function arguments, ignore how the user handle spaces inside <>,(), etc. And might not be 100% compatible with KWStyle typedef alignment.
# Uncrustify 0.63
#
# General options
#
# The type of line endings. Default=Auto
newlines = auto # auto/lf/crlf/cr
# The original size of tabs in the input. Default=8
@phcerdan
phcerdan / DGtalLibraryDepends_build_tree.cmake
Created December 19, 2016 04:23
Difference between generated DGtalLibraryDepends in build and install tree.
# Generated by CMake 3.6.3
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------