Skip to content

Instantly share code, notes, and snippets.

Avatar

Pablo Hernandez-Cerdan phcerdan

View GitHub Profile
@phcerdan
phcerdan / fix_gfortran_lib_rpaths.sh
Last active Sep 10, 2020
fix_gfortran_lib_rpaths.sh
View 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
View CMakeLists.txt
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 Apr 4, 2018
Swap ordered data, insert/delete of values in ordered container.
View swap_ordered_data.cpp
// 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 Mar 28, 2018 — 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
View Move_DISALLOW_COPY_to_public_section.cpp
// 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:
View itk_error_conceptchecking_gpu.txt
[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 Oct 11, 2017
Vim regex command for django: substitute hard coded static path to template parameter {% static 'path' %}
View vim_s_django_static
" 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
Python plot3D with LineCollection
View plot3D_LineCollection.py
"""
=============================================
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 Mar 29, 2017
ITK Apply a gaussian window using FrequencyIterators.
View gauss_window_itk.cpp
// 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 Feb 15, 2017
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.
View uncrustify_itk_aggressive_phcerdan.cfg
# 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 Dec 19, 2016
Difference between generated DGtalLibraryDepends in build and install tree.
View DGtalLibraryDepends_build_tree.cmake
# 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.
#----------------------------------------------------------------