Skip to content

Instantly share code, notes, and snippets.

View clungzta's full-sized avatar

Alex McClung clungzta

View GitHub Profile
Returns:
if output_type == 'csv_zip':
Flask File -- sends file contents to client using Flask send_from_directory()
elif output_type == 'json':
Flask File -- sends file contents to client using Flask send_from_directory()
import os
import time
import pickle
import logging
import argparse
import numpy as np
import tensorflow as tf
from tensorflow.python.keras.models import Model
from tensorflow.python.keras import backend as K
from tensorflow.python.keras.utils import plot_model
import time
from lockfile import LockFile, LockTimeout
filepath = '/home/alex/Downloads/blah.txt'
lock = LockFile(filepath)
if lock.is_locked():
print('Waiting to acquire the file lock...')
lock.acquire(timeout=10)
@clungzta
clungzta / compile_and_run.md
Last active August 21, 2018 09:53
Super Simple OpenCV C++ to Python Interface

Compile

gcc -shared -o libsimpleopencvtest.so -fPIC ./simple_opencv_test.cpp -lopencv_core -lopencv_highgui -lopencv_objdetect -lopencv_imgproc -lopencv_features2d -lopencv_ml -lopencv_calib3d -lopencv_video

Run

python simple_opencv_test.py

@clungzta
clungzta / qsub_with_output.sh
Created August 2, 2018 07:23
Run's a PBS job using qsub, displays output as the program runs
#!/bin/sh
# usage ./qsub_with_output.sh cnn_match.sh
# where cnn_match.sh is a qsub script
jobID=$(qsub $1)
jobIDNumeric=${jobID//[!0-9]/}
echo $jobIDNumeric
qstat -s -u am893

Thunderbird Setup

Download and Install Theme

wget https://github.com/spymastermatt/thunderbird-monterail/archive/master.zip
unzip master.zip
@clungzta
clungzta / cloudSettings
Created July 10, 2018 04:14
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-07-10T04:14:10.448Z","extensionVersion":"v2.9.2"}
@clungzta
clungzta / siamese_data_batching.py
Last active July 3, 2018 13:36
Simple utility function for batching data into a Siamese Neural Network
import numpy as np
def sample_pairs_siamese(train_X, train_y, batch_size):
# Generate a random batch of batch_size samples
rand_index = np.random.choice(len(train_X), size=batch_size)
batch_xs, batch_ys = train_X[rand_index], train_y[rand_index]
new_batch_xs, new_batch_ys = [], []
@clungzta
clungzta / fasttext_tinkering.py
Last active June 1, 2018 02:39
Playing around with facebook fasttext vectors
import io
import pickle
import numpy as np
from nltk.tokenize import word_tokenize
def load_vectors(fname):
fin = io.open(fname, 'r', encoding='utf-8', newline='\n', errors='ignore')
n, d = map(int, fin.readline().split())
data = {}
for line in fin: