Skip to content

Instantly share code, notes, and snippets.

@eerwitt
eerwitt / parse-wav-file.py
Last active Nov 11, 2021
Parsing a WAV file using basic Python
View parse-wav-file.py
# 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'
@eerwitt
eerwitt / example_output.txt
Created Feb 1, 2016
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.
View example_output.txt
Original Image:
[[[255 255 40]
[125 255 67]]
[[ 55 121 231]
[255 40 151]]]
Padded Image:
[[[255 255 40]
@eerwitt
eerwitt / load_jpeg_with_tensorflow.py
Created Jan 31, 2016
Example loading multiple JPEG files with TensorFlow and make them available as Tensors with the shape [[R, G, B], ... ].
View load_jpeg_with_tensorflow.py
# 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
View authentication_with_bcrypt_in_rails_4.md

#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