Skip to content

Instantly share code, notes, and snippets.

@cheuerde
cheuerde / tp_test.cpp
Created April 1, 2014 16:08
Template class to std::vector
#include <iostream>
#include <vector>
using namespace std;
template<typename T1>
class test_class{
T1 X;
@cheuerde
cheuerde / gist:9930609
Last active August 29, 2015 13:58
C++ derived template Class with container of pointers to base-class
#include <iostream>
#include <vector>
using namespace std;
class base{
public:
float X;
void getX(){ cout << endl << X << endl;}
@cheuerde
cheuerde / fastGBLUP_asreml.r
Last active March 30, 2021 07:01
Computing GBLUP efficiently in Asreml-R #algorithm #R
# Claas Heuer, 2014
###############################
###############################
# Using transformed model for efficient GBLUP
#
# X = Incidence matrix for fixed effects
# G = Genomic relationship matrix
# y = vector of phenotypes
# id = vector of ids
@cheuerde
cheuerde / recursive_sed
Last active May 16, 2023 20:58
Recursively replace string in all files in current folder and subfolders #unix #tools
# take from http://serverfault.com/questions/172806/use-sed-recursively-in-linux
find . -type f -print0 | xargs -0 sed -i 's/foo/bar/g'
@cheuerde
cheuerde / svn_tut.txt
Last active August 29, 2015 14:04
Using SVN (Subversion) for package submission on Rforge #install #R
# get svn:
sudo apt-get install subversion
# get the svn-repository you are working with (e.g. Rforge project)
svn checkout svn+ssh://cheuer@r-forge.r-project.org/svnroot/cgen/
# a local folder on your machine will be created in the place from where
# you executed the command.
@cheuerde
cheuerde / gist:a5b8dae8a421fad09c6f
Last active September 18, 2019 05:28
Install an R-Package from Rforge repository with CRAN dependencies #install #R
# from the Rfroge manual:
install.packages("mypackage", repos = c("http://R-Forge.R-project.org",
"http://your.nearest.CRAN.mirror.org"), dep = TRUE)
# for example
install.packages("cgenpp", repos=c("http://R-Forge.R-project.org",
"http://cran.at.r-project.org"),dependencies=TRUE)
@cheuerde
cheuerde / osx_cpgen_GNU.sh
Last active August 29, 2015 14:05
OSX - Change the default compiler from Clang/Clang++ to GNU-Compiler for package: cpgen #install #C++
### Download the most recent source package
curl -L -o master.zip https://github.com/cheuerde/cpgen/archive/master.zip
# Extract source package
unzip master.zip
mv cpgen-master cpgen
HAS_MV=true
# check if Makevars-file exists
if [ ! -e ${HOME}/.R/Makevars ];then mkdir ${HOME}/.R;
@cheuerde
cheuerde / calc_aic_bic_asreml.r
Last active August 29, 2015 14:05
AIC / BIC for Asreml #R
'calc' <- function (asreml)
{
summ <- summary(asreml)
vc <- summ$varcomp
DF <- nrow(vc)
if ("Fixed" %in% levels(vc$constraint))
DF <- DF - table(vc$constraint)["Fixed"]
if ("Constrained" %in% levels(vc$constraint))
DF <- DF - table(vc$constraint)["Constrained"]
names(DF) <- ""
@cheuerde
cheuerde / unix.sh
Last active August 29, 2015 14:05
unix commands #tools #unix
# Befehl 'sed'
sed 's/AA/0/g' phen_gen.txt >phen_gen_neu.txt
# ein programm lokal ausführen:
./
@cheuerde
cheuerde / Compile GCC
Last active August 29, 2015 14:05
Script for compiling GCC with all dependencies - Taken from: https://github.com/beurdouche/scripts #install
#!/bin/bash
#
# GNU GCC COMPILER INSTALLATION SCRIPT
#
# Copyright (c) 2014 Benjamin Beurdouche. All rights reserved.
#
# You might want to modify the first line to specify your own install location.
# Prerequisites : binutils autoconf automake libtool autogen gettext cloog dejagnu