Programming and Exciting Things

Flask, Flask-SQLAlchemy & Flask-Security

July 19, 2014

My last 3 weeks has mostly consisted of programming for a Flask Web Environment.

What is flask? Flask is a fancy python library allowing rapid web application, api, and interface development. It tackles many of the hard parts of programming web apps in nice and easy paradigms.

Flask has many extensions available, two being Flask-SQLAlchemy and Flask-Security. These two are must haves for any kind of application development involving a database and a level of security management.

Back in my PHP days, I would slave away and create a fancy PHP permissions structure for whatever web application I was writing. Horrible. Probably filled with vulnerabilities & all sorts of bad things. Flask-Security is made so you don’t need to do this.

How about SQLAlchemy? SQLAlchemy is a database interface wrapper, but it’s more than just a wrapper. It does ORM, which means you can represent your database entities as objects/classes. A very similar paradigm to both CoreData on iOS AND my own, NWRestful/NWManagedObjects framework.

So, how do we use all this?

As this isn’t a tutorial, I won’t go through it, however there are some AMAZING examples hosted on the Flask website and the Flask-SQLAlchemy website. I cannot say the same for Flask-Security however.

Over my first project, programming for Flask/Flask-security, I found the security library’s documentation to be greatly lacking. This was a slight drawback, however once I got my head around the library, everything went nicely.

I will aim to upload a Flask example package/boilerplate with the structure of how I use flask within the next few weeks.

From The Shard #tiltshift #view #london #blog

July 7, 2014


via Instagram ift.tt/1sn1Yrc…

Quadcopter Electronics Assembly Complete

June 22, 2014

So far i’ve almost completed all the electronics components of the quadcopter. I am now waiting for my 5v regulator to arrive. I will use this to drive the Raspberry Pi from the 7.2 Lipoly battery. Once this arrives the quad will be able to become fully wireless (currently 5v power inlet is requiring a cable).

I wrote a basic program to control the PWM speeds from the RPi. This is letting me test the power that the quad has. At the moment it can easily lift off at about 40/100 (however I’m not sure if this is linear).

This video shows me bringing the controller speed up to 30/100:

watch?v=lVxbO1KiBK8&feature=youtu.be

The next challenge is going to be mounting everything in such a way that it’s accessible and still lightweight. At the moment electrical tape is a great mounting tool.

DIY Quad Frame

June 17, 2014

I just ordered a cheap $30 56g lightweight frame off ebay, however, I need something in the mean time to get set up with. Instead of using the ugly and heavy (~250g) wooden frame, I have built this frame from some spare materials I found in the garage.

Next up, I will need to make all the electronic connections and determine where to house the RPi and battery on the quad. I am going to have to now be careful about positioning of the electronics as the entire frame is conductive :S

Here are a couple of picture of the new frame’s construction

IMG_0010

Assembled onto the new frame!

Close up of the material i'm using

Close up of the material i’m using

Quadcopter Arrived! (Most of it)

June 16, 2014

Today a majority of the electronic components of my quadcopter arrived. I received an email from the online shop saying that my order had been dispatched today and they included a tracking number. Upon checking the tracking, it turned out it had actually been posted on the 13th and it was “Delivered”. Being curious, I went downstairs, and there it was, a package on my door step. Excellent.

The items packed in the box

The items packed in the box

So it was a given I was going to have the rest of the afternoon off study – now that I had a new fun thing to play with.

As I am not building this from a kit, I had ordered all my parts individually and hoping for the best. For someone with such little hobby RC knowledge, google has definitely been my friend.

My package contained:

  • 4x 10A ESC Combo Kits with a 1700Kv motor (not Kilovolts, RPM in K per volt)
  • 1x Lipoly Balance Charger (For charging my Lipoly battery)
  • 1x 2100mAh Lipoly Battery (2S, 30C)
  • 1x Wooden Frame (Only cost $5, thought it would be worthwhile)
  • 3x Different packs of Propellors
  • 1x Power Distribution (Which I stupidly bought the one with the wrong plug)
IMG_0003

The contents of my package, laid out

So, Let’s get started. What on earth do all those numbers mean? I didn’t know – until I started looking them up. So, let me explain the motors to begin with.

Continue reading »

iTunes vs Spotify

June 15, 2014

So I just caved into starting a 3 month free trial of Spotify. What have I got to lose? It’s going to make syncing to my android device much easier, plus I can listen to any song I want wherever I am (provided Optus is decent).

Lots of PlaylistsUpon starting my Spotify experience, I needed to import my iTunes playlists. I needed to get all of my playlists out of iTunes. I have a LOT of playlists (Over 300). See the image to the left for example. That’s only just a minority of them (I’ve included the scroll bar for reference). Now, getting these outside of iTunes is a process on it’s own, and getting them into Spotify is even more difficult. This would be somewhat easier I suppose if Spotify’s “iTunes Import” feature wasn’t greyed out, however there clearly is a problem here:

Spotify's Broken iTunes Importer

Spotify’s Broken iTunes Importer

So the next best thing was to use the iTunes playlist export functionality. This can be done by right clicking a playlist and choosing “Export”. Tedious – yes. I only exported about 15 playlists before researching the next step – converting these playlists to a format Spotify can handle. Fortunately there are online tools to do this – however they’re slow, and can only do one playlist at a time. So this was clearly not an option.

I ended up settling for dragging and dropping playlists into Spotify. The flow was as follows:

  1. Create a new Spotify Playlist
  2. Drag Songs From iTunes into Spotify.
  3. Ensure you didn’t duplicate anything

Tedious, especially for 300 playlists. I’m not even sure if I can be bothered to export my entire library to a service I may not use forever. Anyway, we will see where I go with Spotify, and maybe I’ll end up building the tool that I previously wrote about here.

New Theme

June 13, 2014

It’s the time of year again I suppose. I have given my blog a good clean and given it a fresh new look. This year I have gone with a flattened design, using typography to get the message across (Yes, I just called Open Sans typography).

Hopefully this refreshment will entice me to write more blog posts, however, as usual, the novelty disappears after a short period of time.

Bridging the Gap: iTunes to Android

June 13, 2014

I hate proprietary things. Specifically iTunes. It’s a great music manager, it’s robust, stable, and has a brilliant store. It also offers fantastic integration with iOS devices. As much as that is great for iOS users, it sucks for anyone on Android. In my opinion this is driving people to move to streaming music services such as Google Play Music or Spotify (both of which I am contemplating).

There are various tools available which bridge the gap. Apps such as DoubleTwist for Mac & Android do the job, however they’re just too clunky.

For me, leaving my iTunes Library and picking up some new music management tool would be a big hassle. iTunes has all my music, including over 300 of my playlists. I need a program to bridge iTunes and my Android Device.

At the moment I’m on the verge of writing a tool to extract iTunes music, track playlists and keep music in sync onto my Android phone. My roadmap for the tool is as follows:

  1. Read iTunes Library & Copy Playlists onto device without duplicates
  2. Synchronise Playlists with the device, so songs removed in iTunes are removed on the Phone.
  3. Write metadata to the device for playlists
  4. OR Write a music playing app – however this may be overkill.

Anyway, this will be a learning process. I’m aware tools are available to do this task, however building one tailored to my needs to possibly the best solution in my case. Looking at the iTunes Library XML files, they look relatively easy to work with, and maybe eventually I’ll set up a auto importer for my “external purchases” to automatically add them to my Library and put them in the right folder on my computer.

Exams! / New Phone / QuadCopter

June 12, 2014

Horray, what a brilliant time of year.

Tomorrow I will be sitting my first of many exams in my time at uni. Since finishing High School I haven’t really done any proper study, so sitting down and forcing myself to put pen to paper and practise math is getting a bit frustrating. I’ve found myself procrastinating and somehow doing things that are not study – such as eating…

Anyway, in the midst of procrastination, I have managed to somehow go shopping. (online shopping lol).

Over the weekend I decided I would use my old RaspBerry Pi to create a quadcopter. On Monday I ordered all the parts, such as ESC’s (Electronic Speed Controllers – they convert PWM to a big electric current for the energy sucking motors), Motors, Batteries, and electronic components such as a gyro/accelerometer/magnometer and a barometer/temperature/altitude meter. These will all connect to the RaspBerry Pi via I2C (I squared C).

So far, although I haven’t even recieved anything in the mail, just the process of gathering parts has taught me so much – Mostly in the electronics, like understanding that I won’t be able to get enough power out of using a standard speed control IC chip, and instead will need a ESC to give power to the motors.

As the project continues, I will continue to blog about the progress and all sorts of the things relating to the project. One stage I am particularly looking forward to within the project is developing a PID software to do the balance of the drone.

In other news, I also managed to buy a Galaxy S5. This does mean that I will be ditching my iPhone 5. Bye bye apple. :’)

Picaxe Microcontroller

June 7, 2014

This week was my last week for the semester at uni. At our last computing lecture our lecturer told us there would be a micro controller question as part of the test. He did state that if we wrote a micro controller emulator in C and shared it, it would be allowed into the test. This is greatly useful for checking machine code during the exam.

I decided I would set about writing up an emulator. I finished the task with no issues. I’m very happy with my emulator (of a fictional microprocessor).

The microprocessor is noted as the “8005″ chip. A chip with 256 bytes of memory. It’s got about 17 different instructions. The sorts of programs we have written in machine code for these are amazing, we have written halving functions, as well as wondrous number generators. I’m certainly amazed.

Now, whilst writing the emulator, I remembered I had a picaxe micro controller stored away in my cupboard. I brought it down after I was done and started playing. My interest in this also comes about due to my father wanting to read RS232 data off our solar panel inverter and viewing it on his iPad. This is my challenge tomorrow – this was just the warm up.

I hooked up the picaxe on a breadboard, and wrote a basic program:

Screen Shot 2014-06-08 at 12.08.34 am

Continue reading »

© Nick Whyte 2014