Instantly share code, notes, and snippets.

Chris von Csefalvay chrisvoncsefalvay

View GitHub Profile
View install_if_not_present.R
# R code that checks if a package is installed, and installs it from CRAN if not.
#' Install packages from a list if not present
#'
#' Installs packages from a provided list if they are not already installed.
#'
#' @param packages_list a list of packages to be installed
#'
#' @export
cran_install_if_not_present <- function(packages_list) {
@chrisvoncsefalvay
chrisvoncsefalvay / fetch_drc_data.R
Created May 22, 2018
Plotting the current DRC Ebola status
View fetch_drc_data.R
# Fetch most recent DRC data.
library(readr)
library(curl)
current_drc_data <- Sys.time() %>%
format("%d%H%M%S%b%Y") %>%
paste("raw_data/drc/", "drc-", ., ".csv", sep = "") %T>%
curl_fetch_disk("https://raw.githubusercontent.com/cmrivers/ebola_drc/master/drc/data.csv", .) %>%
read_csv()
@chrisvoncsefalvay
chrisvoncsefalvay / powerlevel9k.sh
Created Dec 4, 2017
Powerlevel9k settings for prompt
View powerlevel9k.sh
POWERLEVEL9K_MODE='awesome-patched'
POWERLEVEL9K_BATTERY_CHARGED='green'
POWERLEVEL9K_BATTERY_DISCONNECTED='$DEFAULT_COLOR'
POWERLEVEL9K_BATTERY_LOW_THRESHOLD='10'
POWERLEVEL9K_BATTERY_LOW_COLOR='red'
POWERLEVEL9K_BATTERY_ICON='\uf1e6 '
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='\n '
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='\n'
POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX="$> "
View Serving Django apps behind SSL with Nginx.md

Configuring Nginx to serve SSL content is straight forward, once you have your certificate and key ready:

server { 
    listen 443 default ssl;
    root /path/to/source;
    server_name mydomain;

    ssl_certificate      /path/to/cert;
    ssl_certificate_key  /path/to/key;
@chrisvoncsefalvay
chrisvoncsefalvay / nginx.conf
Created Nov 6, 2017 — forked from lciolecki/nginx.conf
Nginx config for django rest framework + angular application
View nginx.conf
server {
listen 80;
listen 443 ssl;
server_name your-domain.com;
charset utf-8;
client_max_body_size 32M;
root /project/static;
index index.html;
View keybase.md

Keybase proof

I hereby claim:

  • I am chrisvoncsefalvay on github.
  • I am chrisvcsefalvay (https://keybase.io/chrisvcsefalvay) on keybase.
  • I have a public key ASBW46UZB1-aXHVxnMvOhck6NEvMlQsjiOP7sqxQOuQ3Vgo

To claim this, I am signing this object:

@chrisvoncsefalvay
chrisvoncsefalvay / pipeline.py
Created May 24, 2017 — forked from sampsyo/pipeline.py
multithreaded pipelines for Python coroutines
View pipeline.py
"""Simple but robust implementation of generator/coroutine-based
pipelines in Python. The pipelines may be run either sequentially
(single-threaded) or in parallel (one thread per pipeline stage).
This implementation supports pipeline bubbles (indications that the
processing for a certain item should abort). To use them, yield the
BUBBLE constant from any stage coroutine except the last.
In the parallel case, the implementation transparently handles thread
shutdown when the processing is complete and when a stage raises an
View bootstrap.sh
sudo yum -y install yum-utils
sudo yum -y groupinstall development
sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel
sudo yum install -y wget
# Python 3 IUS
sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum -y install python36u
sudo yum -y install python36u-pip
sudo yum -y install python36u-devel
@chrisvoncsefalvay
chrisvoncsefalvay / CONTEXT_IMPORTING.md
Last active Apr 12, 2017
Context importing in Python
View CONTEXT_IMPORTING.md

Shamelessly stolen from Kenneth Reitz.

@chrisvoncsefalvay
chrisvoncsefalvay / humanized_join_list.py
Created Feb 8, 2017
All sorts of useful Python hacks...
View humanized_join_list.py
def humanized_join_list(item_list: Union[List, Tuple], ordinary_separator: str = ", ", final_separator=" and "):
return final_separator.join([ordinary_separator.join(item_list[:-1]), item_list[-1]] if len(item_list) > 2 else
item_list)