Posts

Oven temperature measurement in real-time

Image
Every time I move apartments, I usually come across a really old gas-powered oven with dubious thermal insulation. I'd like to be a better cook, but every time I start up the oven it feels a bit like black magic guessing how long it takes for the oven to be 'ready', or what temperature it really  is inside the oven, and how long I should cook the food for. Enter, Shitty-Engineering Science! I put together a little temperature display with a thermocouple wire that can be stuck into the oven through the door. My oven temperature reader in use. The golden cable snaking into the oven is the thermocouple The magic lies in the  thermocouple , a fiber-glass braided K-type thermocouple (which can be used in extremely high heats like kilns), which is basically just two pieces of metal connected together. The way the two metals heats up differently results in a (tiny) temperature-dependent voltage that can be measured with a micro-controller, and used to drive a 7-segment di

Generating Morse Code Sounds from Text

Image
I decided to port my python morse code script over into a live demo web page (this is because live demos are infinitely easier with HTML5/javascript web pages which are client-side, instead of web server based solutions that would cost me compute resources to run/maintain). We want to have an input text box, and after the user submits, convert it to a sequence of morse code dots and dashes (dit's and dah's), Morse Code Generator : Link Morse code conversion is simple enough, a look-up dictionary. Then to generate the sounds, I actually started with generating the audio data from a python script into base64 encoded strings  that was then loaded by the javascript. This mostly worked, with some interesting loading issues on mobile web pages. I then transitioned to using Tone.js , which is pretty fantastic and provided an easy method for generating the morse code tones programmatically, and with more accurate timing than the existing javascript setTimeout methods (whic

Calculating your upcoming Life Crises Events

Image
A friend of mine was having their quarter-life crisis (apparently  it's a thing ), which happens around the age of 25, so unfortunately I've missed mine already. This got me thinking about all the life crises that I've already missed and have coming up. I wanted to make a script that given my birthday would let me know all about my life crises. Have a 2/7th life crisis party or something, who knows. So there's the obvious mid-life crisis, which happens around your 40's. Let's assume a lifespan is 100 years, then let's find our mid-life and quarter-life crisis times. On top of that, why not our 1/3 and 2/3 life crises? or even 3/5th of 5/7th. Also, let's put this on a little HTML5/javascript web page that will provide to-the-second accurate estimates for upcoming crises. Life crises : Link Needless to say, this is probably not what one should do when a friend is having a life crisis (they weren't entirely as enthusiastic about this script as

Creating ExistentialRickBot, probably the silliest Redditbot yet

So I'd written SchmeckleBot , a simple bot that converts currency from schmeckles to USD. But I decided to go even simpler, still in the theme of Rick and Morty (if you loved Futurama watch this!). In the pilot episode, when Morty sees something during a chase scene that causes an existential crisis, Rick quickly snaps him out of it with the pithy quote ' Don't think about it! '. It should be immediately obvious that a reddit bot needs to exist and reply with that quote whenever an existential question is asked on the r/rickandmorty subreddit . And thus was born ExistentialRickBot . The core logic is dead simple, if an existential question is posted, respond with an existential answer. questions = [ 'why' , 'happen' , 'think' ] # Match if any of these are found in message def isExistentialQuestion (message): return '?' in message and any ([q in message . lower() for q in questions]) def getAnswerToExistentialQuestio

Writing SchmeckleBot, a simple Reddit bot

This post will discuss the ideation and building of  SchmeckleBot . So, before I wrote the Tensorflow chessbot , I wanted to learn the basics of building Reddit bots, and decided to choose something that was both fun and solved an existing problem. I frequent the / r/rickandmorty  subreddit, which if you haven't heard about it is a place to talk about Rick and Morty, a hilarious and awesome TV show (check it out if you're into animated TV shows like Futurama or Archer). Every so often redditors comment on a post saying they'll buy something for X amount of  schmeckles , a unit of currency from one of the episodes of Rick and Morty. Here's one such post Boogilywoo2   411 points   3 months ago   Hey there! I'm Mr.SculptureBuyer. I'll pay 50 schmeckles for that sculpture! According to the creator Dan Harmond a schmeckle is about $148 (the reason for this conversion is pretty great ). So 50 schmeckles would be $7,400 USD. We want a bot that respond

Learning TensorFlow #2 - Predicting chess pieces from images using a single-layer classifier

Image
Let's train a tensorflow neural network to tell what piece is on a chess square. In the previous post discussed how to parse input images which contained a chessboard into 32x32 grayscale chess squares. Let's look again at our input and outputs. Input 32x32 grayscale normalized image of a single chess tile containing a piece or empty Example input tile, a black pawn Output A label for which piece we think it is, there are 6 white pieces and 6 black pieces, and 1 more for an empty square, so 13 possible choices. Let's define our output label as an integer value from 0-12, where 0 is an empty square, 1-6 is white King, Queen, Rook, Bishop, Knight Pawn, and then 7-12 are the same for black. A black pawn in this case would be 12 then. In a one-hot label vector, this would be [0, 0,0,0,0,0,0, 0,0,0,0,0,1], where the 12th index is 1 and the rest are zero. How do we generate training data where we know the labels? One way is to take screenshots of the

Learning TensorFlow #1 - Using Computer Vision to turn a Chessboard image into chess tiles

Image
I've been wanting to learn how to use TensorFlow , an open-source library that google recently released for machine learning and other applications. The introductory tutorials are great, teaching how to classify written numbers, but it would be nice to try something different and new. So what sort of problems could we solve? Well, one problem that I'd been having involved chess. There's a web forum called Reddit , which has several subforums (they call them subreddits) where people can post about specific topics, in this case the one I'm interested in is the chess subreddit . About once or twice a day someone will publish a new post that links to an image of a 2D online chessboard in a certain layout. An example chess puzzle image posted on /r/chess They're either from games, or sometimes are called tactics puzzles, which is where a person is given a certain layout of chess pieces and tries to guess the next best move or series of moves for one of the sides