Skip to content

Instantly share code, notes, and snippets.

@OXPHOS
OXPHOS / csvloader.md
Last active June 10, 2018 15:30
From installing mysql to load csv to sql tables

Install Mysql:

export PATH=$PATH:/usr/local/mysql/bin

Run Mysql:

mysql -uroot -ppassword

CREATE DATABASE dbname;

@OXPHOS
OXPHOS / io.md
Last active May 10, 2018 02:16
Effort to improve I/O rate

Xml files are small (~100kB per file), but the ingest, transform and dump-to-database is extremely slow.

Two improvements can be done with the code:

Bottleneck 1:

Because the error, using psycopg2 to connect to PostgreSQL across nodes are not easy. Originally, updating entries in psql database is done by extracting dataframe information as plain strings and save to dictionary:

 def update_patient_info(info, key):
@OXPHOS
OXPHOS / setup_spark_manually.md
Last active April 26, 2018 19:33
log in to nodes and install spark

Setup Spark manually - gap filling of Insight Spark Intro

1. log on to control machine, usually ssh dd-control

~/aws-ops-insight/terraform$ terraform apply
@OXPHOS
OXPHOS / Cholesky_solver_test.sh
Created February 15, 2017 22:02
Eigen Compatability Test
#!/bin/bash
# Test Cholesky decomposition with different Eigen versions
function fclean {
make clean
rm -rf ../third_party/Eigen3
rm -rf ../third_party/include/eigen
}
function frun {
class LinalgBackendBase
{
public:
/**
* Wrapper method that computes mean of SGVectors and SGMatrices.
*
* @see linalg::mean
*/
#define BACKEND_GENERIC_COMPLEX_MEAN(Type, Container) \
virtual typename std::enable_if<std::is_same<Type, complex128_t>::type, complex128_t>::type \
/*
* Copyright (c) 2016, Shogun-Toolbox e.V. <shogun-team@shogun-toolbox.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
template<class Archive>
void cereal_save(Archive& ar) const
{
switch (m_datatype.e_containertype) {
case TYPE_SGVECTOR
case TYPE_INT_32:
ar(*(reinterpret_cast<int32_t*>(storage))); break;
case TYPE_FLOAT_64:
ar(*(reinterpret_cast<float64_t*>(storage))); break;
case TYPE_SGVECTOR_INT_32:
template<class Archive>
void CSGObject::cereal_save(Archive& ar) const
{
int y = 0;
for (auto it = self->map.begin(); it != self->map.end(); ++it, ++y)
{
std::cerr << "num. " << y << std::endl;
ar(it->second);
}
}
#define CEREAL_SAVE_FUNCTION_NAME cereal_save
#define CEREAL_LOAD_FUNCTION_NAME cereal_load
template<class Archive>
void CSGObject::cereal_save(Archive& ar) const
{
for (auto it = self->map.begin(); it != self->map.end(); ++it)
ar(it->second); // archive Any object
}
Mac148934:test2 zora$ g++ -c -std=c++11 base.cpp
Mac148934:test2 zora$ g++ -c -std=c++11 test.cpp
Mac148934:test2 zora$ g++ -std=c++11 base.o test.o -o test
Undefined symbols for architecture x86_64:
"void base::serialize<cereal::JSONOutputArchive>(cereal::JSONOutputArchive&) const", referenced from:
decltype(fp0.serialize(fp)) cereal::access::member_serialize<cereal::JSONOutputArchive, derived>(cereal::JSONOutputArchive&, derived&) in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)