MYSQL IN OPERATOR NOT USING INDEX
After being alerted for elevated cpu on a staging mysql instance, I logged into the mysql console and ran a SHOW PROCESS LIST :
SHOW PROCESSLIST\G
*************************** 1. row ***************************
Id: 1
User: my_user
Host: x.x.x.x:xxx
db: my_db
Command: Sleep
Time: 2
State:
Info: NULL
*************************** 2. row ***************************
Id: 3
User: my_user
Host: x.x.x.x:xxx
db: my_db
Command: Query
Time: 786
State: Sending data
Info: SELECT file_id, fs_file_id
FROM my_data
WHERE file_id IN ('123456', 123457);
A query running for 786 seconds quickly caught my eye, my next course of action was to run an EXPLAIN :
REMOTE CONTROLLED CAR USING RASPBERRY PI AND WEBCAM
Setup
First thing I tackled was setting up the L293D H-Bridge on the Bread Board.
I found myself referencing the following Diagram a couple times.
Step one is connecting your chip down the center of your board:
From here I connected the 3 power pins to my board’s power rail using a few Jumpers :
A few more Jumpers connect each side of the chip to ground:
Finally I use a couple Wires to connect both sides of my power and ground rails:
PYTHON SAYS, SIMON'S HIPSTER BROTHER
Many of you may remember playing with a
Simon Electronic Memory Game
when you were younger, you know something that looks like this:
At it’s core the game is rather simple, the device lights up random colors, and you need to repeat the pattern. Of course it gets harder the longer you play.
I thought it would be fun to build a Simon game using Raspberry Pi and a few electronic components:
ARDUINO VALUES TO PYTHON OVER SERIAL
I’ve done a little bit of reading on the ReadAnalogVoltage of Arduino’s home page, and they give a straight forward way to read voltage from an analog pin.
I wanted to take this one step further and send the value over serial, then read it in Python using pySerial .
My setup is very straight forward, I have a
Arduino UNO
, a bread board, and a battery pack holding 4x AA batteries:
To start out I want to merely print the voltage value in Arduino Studio to the serial console, my code looks something like this:
PYTHON AND SENTIMENT ANALYSIS
While looking for datasets to throw at sklearn , I came across UCI Sentiment Labelled Sentences Data Set.
UCI is providing us with positive / negative tagging on real world data, the data comes from three sources ( Amazon , Yelp , and IMDB ).
The only problem is the format is a little strange.. We have a .txt file for each source, this is a raw unstructured formatting, plus not every line is tagged with sentiment.
TEST YOUR MACHINE LEARNING
In my previous post " Python Machine Learning with Presidential Tweets “, I started messing around with sklearn and text classification.
Since then I’ve discovered a great tutorial from SciPy 2015 . This video starts out slow enough for novices, and a reoccurring theme is testing your datasets.
After watching a good chunk of this video, I decided to go back to my code and implement a testing phase. Basically I’ll split my data into two pieces, a training set , and a testing set .
PYTHON MACHINE LEARNING WITH PRESIDENTIAL TWEETS
I’ve been spending a little bit of time researching Machine Learning , and was very happy to come across a Python library called sklearn .
While digging around Google, I came across a fantastic write up on Document Classification by Zac Steward . This article went pretty deep into writing a spam filter using machine learning, and sklearn. After reading the article I wanted to try some of the concepts, but had no interest in writing a spam filter.
SENSORTAG DATA MERGED WITH OPEN WEATHER MAPS
About a week ago I worked on SensorTag metrics .
This week had some interesting weather today here in Austin, and I wanted to see to visualize it as well. Luckily Open Weather Maps offers a free API for gather near real-time weather data based on city code.
def __get_open_weather_data():
url_path = 'http://api.openweathermap.org/data/2.5/weather'
api_key = '??????????'
url = '%s?zip=73301&APPID=%s'
res = requests.get(url % (url_path, api_key))
if res:
if res.json().get('main'):
return res.json()
res = requests.get(url % (url_path, api_key))
if res:
if res.json().get('main'):
return res.json()
def get_open_weather():
data = __get_open_weather_data()
# format our json response
temp = round(data['main']['temp'] * 9/5 - 459.67, 2)
pressure = round(data['main']['pressure'], 1)
humidity = round(data['main']['humidity'], 2)
rain = round(data['rain'].get('1h', 0.00), 2)
clouds = data['clouds']['all']
wind = data['wind']['speed']
return dict(
open_weather_temperature=temp,
open_weather_pressure=pressure,
open_weather_humidity=humidity,
open_weather_rain=rain,
open_weather_clouds=clouds,
open_weather_wind=wind
)
Then I merge with my SensorTag data, appending these new keys to my json file:
ARDUINO MEET RASPBERRY PI
While at the electronics store the other day, I noticed they had motion detectors on sale for only $4. I decided with my latest obsession of electronic tinkering, picking up a OSEEP Passive Infrared Sensor (PIR) Module might be fun.
I guess I should have done a little more reading on the packaging; by the time I was home, I noticed this sensor reported in
analog
, not digital. This was an issue as the
Raspberry Pi
only reads digital input.
RASPBERRY PI AND OFFICIAL NFL SCORE BOARD API
Now that I’ve got my hands on a
Raspberry Pi 3 Model B Motherboard
, I decided nows a good time to play around with the
16x2 LCD Module Controller HD44780
I had laying around (I’ve had this thing since December 2015).
A live NFL (National Football League) score board seemed fitting as the season just started.
I found a really good write up on raspberrypi-spy.co.uk about wiring up the controller and Pi, here is the diagram I used: