Skip to content

Instantly share code, notes, and snippets.

View jcausey-astate's full-sized avatar

Jason L Causey jcausey-astate

  • Arkansas State University
  • Jonesboro, AR
View GitHub Profile
@jcausey-astate
jcausey-astate / _exam-template.md
Created July 2, 2015 13:41
Markdown Exam Templates: Write quizzes and exams in Markdown!
TODO: TITLE HERE
Name:
Read questions carefully and answer all parts as completely as possible. Vague, off-subject, or illegible answers will not earn credit.

  1. TODO: Question 1
@jcausey-astate
jcausey-astate / easy_rand.h
Last active September 29, 2015 18:21
A simple function to generate random integers in a specified range using modern C++ random functions. Inspired by Stephan T. Lavavej's 2013 talk: https://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful
/**
* @file easy_rand.h
*
* Makes it easy to generate good pseudo-random values in a
* given numerical range using the new C++11 <random> features,
* without the setup overhead.
*/
#ifndef EASY_RAND_H
#define EASY_RAND_H
@jcausey-astate
jcausey-astate / sendemail.py
Last active April 3, 2023 06:06
Send email using Python without requiring an MTA or installing sendmail. Adapted from https://moythreads.com/wordpress/2015/07/09/sending-email-with-python-without-an-mta/
#!/usr/bin/env python2.7
#
# Send email without requiring account credentials to be stored on the
# Docker instance.
#
# Adapted from:
# https://moythreads.com/wordpress/2015/07/09/sending-email-with-python-without-an-mta/
#
# Dependencies:
# `smtplib` (pip install smtplib to install)
@jcausey-astate
jcausey-astate / replace_missing_values_in_matrix.py
Last active September 26, 2016 20:15
Given a CSV or tab-delimited input file (ASCII-encoding), replace all missing values or all occurances of a specified value with a new marker. Useful for large scientific data where some values are missing (i.e. gene microarrays, etc).
#! /usr/bin/env python
###################################################################################################
# Given a CSV or tab-delimited input file (ASCII-encoding), replace all
# missing values or all occurances of a specified value with a new marker.
# Useful for large scientific data where some values are missing (i.e. gene
# microarrays, etc)
#
# The MIT License (MIT)
#
# Copyright (c) 2016 Jason L Causey, Arkansas State University

Keybase proof

I hereby claim:

  • I am jcausey-astate on github.
  • I am jcausey_astate (https://keybase.io/jcausey_astate) on keybase.
  • I have a public key ASA4rcY4g2eyBqkPVFpLAKkmMKe8a26ZQwt_EJmB0qZMZgo

To claim this, I am signing this object:

@jcausey-astate
jcausey-astate / git-filter-to-current-tree.sh
Created May 26, 2017 22:33
Modify Git repo history so that any files/folders not present in the current worktree when the script is run will be retoactively erased from history.
#!/usr/bin/env bash
####################################################################
# Removes any files that are not currently in the working tree from
# the git repository history.
####################################################################
KEEPFILES=$(mktemp)
FULLLIST=$(mktemp)
REMOVEFILES=$(mktemp)
@jcausey-astate
jcausey-astate / easy_python_virtualenv_tricks.md
Last active February 3, 2022 03:51
Simple way to automatically select virtual environments based on direcotry in Linux.

Tricks for working with many virtualenv environments on a Linux server.

Much of this was adapted from Justin Abrahms. I've just collected the bits related to setting up the environment in bash here.

Assumptions

This page assumes that you have access to pip, but that you are not the administrator (no root or sudo access).

Get virtualenv if it isn't installed

If you don't have virtualenv installed, you can do:

pip install --user virtualenv
@jcausey-astate
jcausey-astate / run_after_proc_exit.sh
Last active March 17, 2018 16:58
Watches a running process, executing a specified command when it finishes (Bash).
#!/bin/bash
script="$(basename ${0})"
read -r -d '' USAGE <<-EOF
Watches a specified process (by pid or name) and runs
a specified command after it exits.
If watching by name, the command executes when no process
by that name is running.
Usage:
/**
* EXAMPLE FROM: https://iamtrask.github.io/2015/07/12/basic-python-network/
* I'm replicating the "3 Layer Neural Network" code using C++ and Eigen below.
* This network is trying to learn to recognize an XOR in the first two elements
* of a 3-value vector, the third value doesn't matter.
*/
#include <iostream>
#include <fstream>
#include <ctime>

Data Analysis Tools You (may) Already Have

This example will use the text of Grimms' Fairy Tales available from Project Gutenberg.

grep - Search in text!

The grep tool is installed by default on most Linux and UNIX-like systems.

Documentation is available at: