Skip to content

Instantly share code, notes, and snippets.

@eerwitt
eerwitt / example_output.txt
Created February 1, 2016 23:32
TensorFlow resize_image_with_crop_or_pad with an input pipeline to avoid issues with the image's shape not being fully defined. The example image is a 2x2 pixel color image used for testing.
Original Image:
[[[255 255 40]
[125 255 67]]
[[ 55 121 231]
[255 40 151]]]
Padded Image:
[[[255 255 40]
@eerwitt
eerwitt / authentication_with_bcrypt_in_rails_4.md
Last active June 19, 2020 18:35 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@eerwitt
eerwitt / load_jpeg_with_tensorflow.py
Created January 31, 2016 05:52
Example loading multiple JPEG files with TensorFlow and make them available as Tensors with the shape [[R, G, B], ... ].
# Typical setup to include TensorFlow.
import tensorflow as tf
# Make a queue of file names including all the JPEG images files in the relative
# image directory.
filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once("./images/*.jpg"))
# Read an entire image file which is required since they're JPEGs, if the images
# are too large they could be split in advance to smaller files or use the Fixed
@eerwitt
eerwitt / parse-wav-file.py
Last active July 3, 2023 21:21
Parsing a WAV file using basic Python
# http://soundfile.sapp.org/doc/WaveFormat/
import struct
def parse_wave_raw(filename):
# Open the example wave file stored in the current directory.
with open(filename, 'rb') as wav_file:
# Main Header
chunk_id = wav_file.read(4)
assert chunk_id == b'RIFF', 'RIFF little endian, RIFX big endian: assume RIFF'