Skip to content

Instantly share code, notes, and snippets.

View gnperdue's full-sized avatar
👋

Gabriel Perdue gnperdue

👋
View GitHub Profile
@gnperdue
gnperdue / IntegerTextField.swift
Created January 14, 2021 01:05 — forked from grosch/IntegerTextField.swift
SwiftUI TextField which only accepts integers and binds to an Int? instead of a String
import SwiftUI
private class IntegerTextFieldValue: ObservableObject {
@Published var value = "" {
didSet {
let numbersOnly = value.filter { $0.isNumber }
if value != numbersOnly {
value = numbersOnly
}
}
void TBBSession::SchedClosure(tbb::task_arena& arena, tbb::task_group& g, std::function<void()> c) {
arena.execute( [&g, &c] () {g.run( c ); } );
}
===========
Then in TBBSession::Run
… Before creating the ExecutorBarrier
// Use a task_arena to avoid having unrelated tasks start
// running on this thread (which could start deadlocks)
@gnperdue
gnperdue / hdf5_batch_test.py
Last active November 30, 2023 15:42
TensorFlow Dataset `from_generator` reading HDF5
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import os
import h5py
import numpy as np
import tensorflow as tf
# Get path to data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Mon Apr 16 09:51:20 2018 by ROOT version 5.34/36
// from TTree NuECCQE/Tuple created by an AnaTuple managed by AnaTupleManager
//
// found on file: SIM_minerva_00113270_Subruns_0001_NuECCQE_Ana_Tuple_v21r1p1.root
// It contains some modifications to deal with stupid ROOT STL errors and some const values
//////////////////////////////////////////////////////////
#ifndef NuECCQE_h
@gnperdue
gnperdue / simple_logreg.py
Created November 29, 2017 14:13
Super-simple logistic regression in TF (just train)
"""
Super-Simple logistic regression to test TF framework APIs.
MNIST TF records available here:
https://github.com/gnperdue/RandomData/tree/master/TensorFlow
Sample run script:
```
#!/bin/bash
@gnperdue
gnperdue / gist:56092626d611ae23370a21fdeeb2abe8
Created November 27, 2017 22:40
Test script to read TFRecord image data with new TensorFlow Dataset API
#!/usr/bin/env python
"""
MNIST data in TFRecord form available at:
https://github.com/gnperdue/RandomData/tree/master/TensorFlow
Example run script:
```
#!/bin/bash
FILEPAT="mnist"
@gnperdue
gnperdue / ns-cheatsheet.clj
Created February 2, 2016 03:24 — forked from ghoseb/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@gnperdue
gnperdue / caffe-git-diff
Created January 6, 2016 22:40
Git diff on my Caffe
perdue@mic> git diff
diff --git a/data/mnist/get_mnist.sh b/data/mnist/get_mnist.sh
index 8eb6aee..0219498 100755
--- a/data/mnist/get_mnist.sh
+++ b/data/mnist/get_mnist.sh
@@ -2,6 +2,7 @@
# This scripts downloads the mnist data and unzips it.
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
+echo "Going to $DIR..."
@gnperdue
gnperdue / Caffe_MNIST_Tutorial_error
Created January 6, 2016 22:24
MNIST tutorial error with more detail
Interactive GPU job:
qsub -q gpu -l nodes=1:gpu -A minervaG -I
. caffe_gpu_setup.sh
caffe.bin device_query -gpu 0
I0106 16:20:46.109344 29397 caffe.cpp:111] Querying GPUs 0
I0106 16:20:48.749228 29397 common.cpp:168] Device id: 0
I0106 16:20:48.749281 29397 common.cpp:169] Major revision number: 3
I0106 16:20:48.749287 29397 common.cpp:170] Minor revision number: 5
I0106 16:20:48.749294 29397 common.cpp:171] Name: Tesla K20m