This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
ENV LANG=C.UTF-8 DEBIAN_FRONTEND=noninteractive | |
ENV PATH /opt/conda/bin:$PATH | |
# Install conda | |
RUN apt-get update --fix-missing && \ | |
apt-get install --no-install-recommends -y curl ca-certificates && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* | |
RUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh \ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Script for installing tmux & htop on systems where you don't have root access. | |
# Inspired by https://gist.github.com/ryin/3106801 | |
# tmux will be installed in $HOME/local/bin. | |
# htop will be installed in $HOME/local/bin. | |
# It's assumed that wget and a C/C++ compiler are installed. | |
# exit on error | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
class Heap(object): | |
""" | |
Heap class implementing the heapq interface + some magic methods. | |
Unit Tests: | |
>>> h = Heap([1,5,78,2,5,78]) | |
>>> h | |
Heap([1, 2, 78, 5, 5, 78]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// foreach(it, container) { | |
// CONTAINER_VALUE_TYPE v = *it | |
// ... | |
// } | |
// | |
#ifndef FOREACH_MACRO | |
#define FOREACH_MACRO | |
#define VAR(V,init) __typeof(init) V=(init) | |
#define FOREACH(I,C) for(VAR(I,(C).begin());I!=(C).end();I++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <sstream> | |
#include <vector> | |
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { | |
std::stringstream ss(s); | |
std::string item; | |
while (std::getline(ss, item, delim)) { | |
elems.push_back(item); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Converts a C++ map to a python dict | |
template <class K, class V> | |
boost::python::dict toPythonDict(std::map<K, V> map) { | |
typename std::map<K, V>::iterator iter; | |
boost::python::dict dictionary; | |
for (iter = map.begin(); iter != map.end(); ++iter) { | |
dictionary[iter->first] = iter->second; | |
} | |
return dictionary; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Converts a C++ vector to a python list | |
template <class T> | |
boost::python::list toPythonList(std::vector<T> vector) { | |
typename std::vector<T>::iterator iter; | |
boost::python::list list; | |
for (iter = vector.begin(); iter != vector.end(); ++iter) { | |
list.append(*iter); | |
} | |
return list; | |
} |