Sync iTunes playlists to Spotify

iTunes is dumb and has a super restrictive API. Spotify is awesome, and has an API for all my things, like my PS4 and Amazon Echo. But I like the iTunes UI, and it plays better with my local library than Spotify. As a result, I subscribe to both services, but it’s such a pain managing playlists between the two.

I present to you, the super not janky at all sync script/setup that I wrote up in a 3 hour burst of inspiration last night. The main flow of the idea is this:

  1. CRON job runs AppleScript periodically
  2. Applescript queries iTunes for playlist information and saves each playlist and its songs to a .txt file
  3. Python script compares .txt files to Spotify playlists – information retreived via API calls
  4. Python script updates Spotify playlists with differences found between the two services

AppleScript is a very interesting programming language, where the code is incredibly human readable at the cost of ease of use when coding. Here’s what I wrote for extracting playlist information out of iTunes:

This extracts playlist information and saves each playlist as a .txt file to a specified directory. The Python component does most of the legwork in terms of finding which tracks needed to be added to Spotify. You’ll need to create a new application at the Spotify Developers page to get a client_id and client_secret_key.
[Read more…]

Teaching cars to drive with genetic algorithms

“What the heck Sophie?!” You say, “Why are you writing a debrief for a project you did 3 years ago???”

Hahaha, please bear with me dear reader. If I don’t, I’ll forget about the cool thing I did as a freshman in college still stumblin’ through Python. And how cool and easy genetic algorithms are. 😀

Anyhow, carrying on….


For our software design final project, we wrote a simulation program that would allow you to draw a track, then generate cars that would eventually learn how to drive around said track. It was a pretty fun project, and we got a pretty cool result.

Here’s our website!
Here’s the code!

Demo video:

What’s happening is that the cars are starting with random parameters for their wheels relative to its distance from the wall. As the the cars progress through the generations, these parameters are selected using our parameters, such that the car that make it around the track is the only one that survives.

[Read more…]

Installing and setting up ROS in 5 mins

[*disclaimer: not really 5 mins. Downloading ROS will probably take longer than that lol]

ROS is a really great library for robotics research. It might even be good for not robotic applications, I don’t know, but my general feel is that I like ROS about as much as I like nutella. (read: a lot). The ROS install tutorial is really good at explaining the process, but it’s spread over too many pages and requires too much scrolling. I’ve consolidated the information here in one page for ease of use. Our robotics lab only uses ROS Indigo, so I’m writing install instructions with that in mind. Also, ROS only works well with Ubuntu, so I’m assuming you’re also using the correct OS.

Everything that follows, unless explicitly stated, should be typed in a terminal window. Okay, so the steps:

1. Set up sources.list
We need to add the ROS package sources to our sources list so we can actually find the ROS packages using the apt package manager. Open up a terminal window and paste the following:
sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

2. Set up your keys
Next we need to set up keys so Ubuntu will actually allow us to download + install the packages.
sudo apt-key adv –keyserver hkp://ha.pool.sks-keyservers.net –recv-key 0xB01FA116
If you get a gpg: keyserver timed out error, use this instead:
sudo apt-key adv –keyserver hkp://ha.pool.sks-keyservers.net:80 –recv-key 0xB01FA116

3. Install ROS via apt-get
Make sure the apt package index is up to date from when we added those new sources at step 1.
sudo apt-get update
Then install ROS!
sudo apt-get install ros-indigo-desktop-full
There are a couple of flavors of ROS that you can install, but for most applications, you might as well do the full install to make sure you get all the packages you’ll ever need.
[Read more…]

She doesn’t mind pebbles.

I started writing this one 8 months ago, but never really found the inspiration to finish it. For some reason, inspiration is hitting me like a hailstorm today, so here’s the finished piece.

Posts tagged “People” are short pieces inspired by people I know in real life. No naming names here~

Also — Checkout this cool photo I took when we went hiking! 😀

the drive


I couldn’t understand her the first time we met. She was loud–so loud, and her laughter bounced like a bowling ball across the nervous tension of that room filled with complete strangers. The way she spoke had a curious lilt, her sentences always rushed towards the periods like she was scared they wouldn’t have a chance to be spoken fully. She spoke a lot, and listening to her talk was like listening to roller coaster scream down a metal track.

Three years ago, I could recognize her voice from a mile away just by the sound of wind whistling past her words. People here are nicer than most, they remember to drop the stones they hold instead of throwing them at things they don’t like. Despite that, she used to cause people to pick up an awfully many number of rocks. I remember wondering why she never noticed all those stony stares and pained laughs scattered around her path.

At one point, I asked her if she tripped a lot when she walked.
“Oh, I do.” She had laughed, meeting my slanted gaze with confidence. “But I don’t mind it now.”
“Why?”
“I’ve learned to like myself.”

A cliche one-liner from the mouth of any other,  but I knew her words were formed by the kaleidoscope of purple bruises on her shin where she had collided with those dropped rocks. Her answer struck me like a knife. At that time (maybe even now), the thought of liking myself felt like a lonely dream. I remember this single moment as the one when I thought that we just might be able to be friends.
“Why?”

She responded slowly, quietly, so as to make it clear that the words she spoke next were important.
“Because if I don’t, how can anyone else?”

 

Summary of modern bone trauma analysis

*Edit 10/21/16: Fixed broken link to pdf, sorry. :C


tl;dr contents:

  • Material Properties of Bone
    • Classifying bone trauma by time of occurrence
  • Types of bone trauma
    • Ballistic
    • Blunt force
    • Sharp force
    • Thermal

I’m not gonna include a lot of pictures because this is a topic that not everyone will want to see images of. You can google stuff if you want to see examples, or read my final paper where everything is cited.

Material Properties of Bone

Bone is divided into two kinds of osseous material. Cortical bone is about 80% of the mass of the exoskeleton, and forms a hollow cylinder in which the cancellous bone resides. The main purpose of cortical is for structure, while cancellous bone is spongy interior that is responsible for nutrient storage and transport. 

A cross-section of a human femur, look at how cancellous bone is a lot less dense than the cortical bone.

A cross-section of a human femur, look at how cancellous bone is a lot less dense than the cortical bone.

Injuries to bone are classified based on when the injury occurs.

Ante-mortem trauma: Refers to trauma on the skeleton that occurs prior to the death of the individual. In-vivo bone exhibits healing, and edges of a fracture will be fairly smooth. As healing rates differ depending on the characteristics of the individual, the same injury may look different from case to case.

Peri-mortem trauma: Refers to trauma occurring around death. Fracture patterns observed in peri-mortem trauma can be similar to those seen in ante-mortem trauma, but have sharper edges since no healing will have occurred (in most cases). Patterns will show evidence of some terminal event, i.e fast collision with an object, but fracture edges will show characteristics of plastic deformation as the external fibers of the bone tissue begin to show micro-tears.

Post-mortem damage: Refers to damage occurring after death. Bone becomes brittle once it has dried out, and exhibits ceramic-like material properties. Fractures will be jagged and exhibit no healing, and may also be irregular. I.E: Fractures lack a common correlation to an event that caused the damage, such as those resulting from post-mortem bone shrinkage.

Types of Bone Trauma

Ballistic
Ballistic trauma on bone is usually the result of a bullet or an explosive, though this categorization may be applied to any fast traveling object that has collided with bone. Features that indicate possible ballistic trauma include the presence of a projectile that can be associated with bone, fracture patterns corresponding to a high velocity impact, or fragmentary foreign material found within the bone or the environment.

[Read more…]

Infinity and Zeno’s Paradoxes

Infinity is a well explored concept across many disciplines. As of yet, I’ve managed to only interact with infinity behind the safety net of definite integrals and unbounded limits. So I thought I’d take a deeper look at infinity though the lens of Zeno’s paradoxes. But first, a short discussion about English.

When I was 6, “red” was the color of my favorite rain jacket. That was it.

When I was 14, “red” was no longer simply a color, it was an emotion, an object, a physical force. I could smell the redness of a cherry orchard and hear the redness of a laugh.

In fact, if I were imaginative enough, I could make the word “red” mean anything I wanted. “You are a poet!” my teacher cried, “Bend your words, twist them, pepper them with your thoughts; present to the world a feast of poetry.” English was quite a willing and malleable medium, which was great, but this foray into non-literal completely defeated the sure-ness of words that I had believed in as a kid. With poetry, even the most innocuous sentence like “today was sunny” could have ten different meanings.

Now, I’ve held on to the belief in the certainty of mathematics since my days of Algebra I. Unlike poetry, the result of a definite integral doesn’t change with the whims of the one grading the problem. Math was unmoved by emotion, and (to borrow the words of Bertrand Russell) I felt that it was the turtle that could hold all other turtles.

However, take a hard look at this concept called “infinity”. Infinity is to mathematics what poetry is to English—it takes the previously solid math of algebra into the fuzziness of philosophy. Though I knew nothing of its intricacies, I often invoked the threat of infinity upon my childhood friends when I “triple times infinity dared” them to do something dumb. Infinity was a big deal, since we didn’t know anything of what it was other than the fact that it was really, really big. But what is the actual value of infinity? How can a mere concept of “really, really, big” become something we can realistically use?

[Read more…]

French Baguettes

French Baguettes
Super easy bread
Write a review
Print
Prep Time
1 hr 30 min
Cook Time
15 min
Total Time
1 hr 45 min
Prep Time
1 hr 30 min
Cook Time
15 min
Total Time
1 hr 45 min
Proofing yeast
  1. 1/2 C warm water
  2. 2 envelopes dry yeast (1 1/2 tbps)
  3. 2 tbsp honey
Bread
  1. 1 C warm water
  2. 3 1/2 to 4 C AP flour
  3. 2 tsp salt
  4. 1 egg, beaten
  5. Vegetable oil for greasing bowl
Instructions
  1. 1. Mix 1/2 C warm water with the yeast and honey. Wait for about 5 minutes for the yeast to eat the honey, until its bubbly.
  2. 2. Mix the flour and salt together.
  3. 3. Pour the yeast mixture into the dry, and mix
  4. 4. Gradually add the 1 C warm water to the flour mix, only until the dough is slightly damp and holds its shape. You might not need to use the whole cup.
  5. 5. Knead the dough for 2-5 minutes--You can tell when it's about ready if the dough springs back if you push on it lightly with your thumb.
  6. 6. Lightly grease a bowl with vegetable oil. Let the dough sit in the bowl for an hour or so in a warm place, covered with a damp towel until it's about doubled in size
  7. 7. Shape the dough into 2 baguette sized pieces, let sit for another 30 minutes or so
  8. 8. Stick it in the oven for 15 minutes, at 450C. You can choose to use an egg wash to make the crust a bit more crunchy and shiny.
  9. 9. Yummy bread! 😀
Adapted from Kelsey Nixon
Adapted from Kelsey Nixon
sophie's blog http://blog.justsophie.com/

I love bread. But I love freshly baked bread and strawberry jam even more. Here’s a recipe I found for really incredibly easy french baguettes that ends up being pretty delicious. I was a bit nervous when I made these at first since I didn’t have a bread maker nor bread flour, but it turned out pretty well even when I worked the dough by hand. Bread that you eat after a bit of hard work tastes leagues better than bread anywhere else!

bread

-Sophie

Algorithm for knight’s tour in Python

I’ve written an updated version of this code here. Please take a look! It adds a visualizer, ability to solve for closed tours and step requirements, and has a better exiting strategy. 🙂


In Discrete class, we’ve been talking about planar graphs and stuff like Hamilton traversals. One of our in-class exercises involved the knight’s tour, and whether we could find a rule that would allow us to decided if a knight’s tour was possible given a chessboard of a certain dimension. I have a hard time understanding graphs, but the “Knight’s Tour” sounded really cool so I looked it up on Wikipedia. The problem is actually a pretty interesting one, so I decided to try my hand at implementing an algorithm for solving it in Python.

From Wikipedia:
A knight’s tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight’s move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open.

The .gif below is an example of what knight’s tour would look like on an 8×8 board.
Gif of knight's tour

In writing my own implementation, I heavily referenced this site and this site. I’ll do a walkthrough of my code below.

[Read more…]

Python speech to text with PocketSphinx

I’ve wanted to use speech detection in my personal projects for the longest time, but the Google API has gradually gotten more and more restrictive as time passes. In order to ensure that my projects could work even without an internet connection, I looked for another speech recognition package that would preferably be easier to use. I found the Sphinx voice recognition suite of CMU to be a really great speech to text package. However, documentation and sample code is non-existent, so it took me forever to get anything done. Finally, I’ve figured it out! The example code is at the bottom of this post, but you can directly download it from Github here.

Here are the steps to take to get this working:

  1. Download SphinxBase and follow the install instructions
  2. Download PocketSphinx and follow the install instructions
  3. Download PocketSphinx-python and follow the install instructions
  4. Run the code below

[Read more…]