Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/life/stringfellow/public_html/synfinity/wordpress/wp-includes/theme.php on line 623
stringfellow’s thread » code

Archive for the ‘code’ Category

Shtaggle 1.2.1

Tuesday, February 10th, 2009

With the encouragement of a large German following, and news of the inclusion of Shtaggle on the next MACup magazine cover CD, I present version 1.2.1…

WITH POWER PC SUPPORT!

It isn’t as functional as the Intel version (the transport progress bar doesn’t work properly.) but it does the task it is required to do - tag sh..music.

For those that don’t know, Shtaggle is a music tagging app for OS X, with help from the last.fm community. It also gets lyrics (from lyricwiki.org).

In this version there is also support for Spotify, though limited, and better integration with Last.FM’s web services - including syncronising your tags from last.fm back to your library, so they match up in both places (no tags are deleted, only appended).

Download it here (or Direct link)

Oh, and, if you can, please do blog this or mention it in a post sometime - I’d appreciate the exposure!

-Steve

Pinax prettiness

Sunday, January 25th, 2009

Update on gardening: there is a *lot* of mint root in that little patch… all went well though, and Chris and I fashioned a compost heap out of rubble from the building of our wall. Its very homebrew.

Got some seeds and pots yesterday, so growage should soon commence.

Pinax Prettiness you ask? Well yes, yes indeed. Pinax is a sort of package I guess that is built on the Django project. Its a collection of Django apps which together make an ‘out of the box’ social site. Its what I built http://badlist.co.uk on (but was sorta bodged a little bit because I was finding my way around it) and it is now what I have built the new-look http://synfinity.net on.

It was far too easy.

My thought process went “Hm I could do with a repo for coursework PDFs (for comparative analysis with coursemates) and a place to sort of ’show off’ some bits (CV etc)…”

Django went “How would you like to do that really fast? Here’s a framework for you to store things and manipulate them. Files? Yeah we can do that. Files in different subjects? Yeah, no worries.”

Pinax went “Wanna be able to manage all that really quickly and not worry about the user-login-maintainence cruft? Oh I got some nice apps here if you wanna feed in all your media feeds too..? Oh your coursemates want to upload their work too? Yeah thats cool, I got some funky user profile things built in. Don’t worry about templating too much, I’ve got a nice standard styled template that looks pretty awesome. Change the logo if you like.”

jQuery went “Doc viewers? Don’t do it statically! Here, bosh a bit of AJAX in this page… yeah, then a little nav bar (oi Django, give us a hand!). Sweet, there we go. Oh, I got some rounded edges if you’d like that?”

Steve went “HOLY FUNK! It is done.”

2 to 3 days… could have been done quicker but for interruptions and hosting woes. Pinax is perfect.
Not to mention the creator and co-conspirator (’jtauber’ (James Tauber) and ‘brosner’ (Brian Rosner) respectively) are awesome, dedicated, bright, friendly, helpful… thats 5 characteristics you dont usually find together in the geek world… This project will go far and fast.

-S

PS - if anyone would like a demo/explore of Pinax I would be happy to acquaint you with it.
PPS - if anyone wants a project doing FOR them, and has a little cash to throw at me, I’ll do it for them!

This blog post was brought to you by Welti Productions.

[Django / Pinax] How to send notices when objects are updated (etc.) using django-notification

Monday, December 29th, 2008

django-notification includes a class called ObservedItem, currently used in django-wiki to alert a user about an entry that they are watching, when it has been updated.

It is quite simple to re-use this in your own applications (I needed it for BadList [an ethical purchase informer]) like so:

Step 1: define some notices
So, if you don’t have one, create a management.py in your app and put something like the following in it:

from django.db.models import signals

from django.utils.translation import ugettext_noop as _

try:
    from notification import models as notification

    def create_notice_types(app, created_models, verbosity, **kwargs):
        notification.create_notice_type("watched_ingredient_updated",
                                        _("Watched Ingredient Updated"),
                                        _("an ingredient you are watching has been updated"))

    signals.post_syncdb.connect(create_notice_types,
                                sender=notification)
except ImportError:
    print "Skipping creation of NoticeTypes as notification app not found"

This adds a notice to the notifications database (when you next call python manage.py syncdb)

Step 2: let users ‘observe’ things
Basically you want to create a url-view pair that can retrieve an object (the one you want notifications about).

NB: you need to import notification into your views:

from notification import models as notification

lets say you have this in some a view intended for the URL /ingredients/observe/something/:

@login_required
def ing_watch(request, ingredient):
    """
    Observe an Ingredient
    """
    if request.user.is_authenticated:
        i = get_object_or_404(Ingredient,name=ingredient)

This code should get the requested ingredient. The next line to add is:

        notification.observe(i, request.user,'watched_ingredient_updated',signal='observe')


This makes a new ObservedItem object with the object instance set to ‘i’, attached to the user who requested the page, with the notice that we defined in management.py.
The signal is important: we override the default (which is ‘post_save’ if you dig around in the code) so that we can use different notifications for different things. The *normal* use for this is when an object is updated (in which case the ‘post_save’ makes sense). Indeed, that is pretty much all this example will do, but I show that it can be changed so that you may reuse it for other tasks (the reason I needed it to do this was when an object was related to by another object using a ForeignKey, in which case it is not the observed object which is updated, but another that only references it.)

Anyway…
Step 3: actually make a call to send out notices

So, in the case I describe above (where you only want this to happen after the object itsself has been updated) you can hook in the post_save signal to do the dirty work (assuming you leave ’signal’ as the default ‘post_save’):

At the end of your models.py (containing Ingredient):

if notification is not None:
    signals.post_save.connect(notification.handle_observations, sender=Ingredient)

Otherwise, to use our custom signal ‘observe’, you can use the following code wherever you want to send the notice (e.g. after some form has been validated and saved):

     notification.send_observation_notices_for(i, signal='observe')


where i is the Ingredient instance that you want to notify about (so you could get this from the ForeignKey field of some object you just saved that refers to it, or if you are using a form which updates/adds some Ingredient, then use the object returned from that)

Et Voila, how to quickly add in on-site and email notifications using ‘ObservedItem’ class of django-notification :-)

Thanks to Brian Rosner for the help figuring this out.

Shtaggle, Music tagging for Mac OS X - iTunes and Play.app

Monday, July 14th, 2008

Shtaggle is a little app I wrote, after a few conversations with James and others about how cool it would be to be able to tag your music in iTunes from last.fm’s tags. It started off as a Django standalone project on my Mac, but after encouragement from various peeps it has progressed to an App (via py-cocoa).

So Shtaggle has reached a point where I have let it loose in the world…
It is now on versiontracker and the hoards of other sites that read versiontracker’s RSS feeds.

Shtaggle gets music tags from last.fm, and then allows you to tag the tracks in iTunes using either the tags from last.fm or your own.
You can choose tags by record label, mood and instrument too.
Shtaggle will then send any tags back to your last.fm profile (if you have one) that you haven’t already added to it for a given track.
Shtaggle will also let you auto-tag your music, using the top tags from last.fm, if you don’t have time to do it manually.

I’ve had some good feedback from it, and will be making it even slicker soon I hope… (the windowing is pretty odd).

Anyway, if you are using OS X 10.5 then please do check it out, and blog about it as you like ;-) (yeah I need some advertising to beat off Moody and QuickTag, both of which look a lot slicker, but do less :-P)

http://shtaggle.co.uk

Shtaggers

Sunday, June 1st, 2008

So Shtaggle has come on a bit since the last post.

Now, not only does it get tags from last.fm but it will also push your tags back to last.fm (so if you tag a track, or have tagged it before, but hadn’t tagged it on last.fm, the tags will get sent!)

Also, you can now register an account on shtaggle.co.uk and then you can have your tagging stats online (soon to become RSS feedable) - so, you get to see what you have listened to most per day/week/month according to tags!

Fixed a few bugs too, so its a bit nicer to use.

Here is the latest zip

PS- Sorry its still a zip and annoying to install… I can’t work out how to package appscript into it (there is a way, but I’m not so good at the build scripts to make this happen) and also, I can’t make a mpkg that works to copy the Shtaggle directory into your /Library/Application Support/ so I guess for now you will have to just copy/install things manually :-/
Sorry!
Chances are I’m the only one that is gonna use it anyway, so nevermind!

Shtaggle.co.uk

Friday, May 23rd, 2008


I thought I’d see a project through to completion for once, so I bought shtaggle.co.uk in order to keep all the updates for Shtaggle in one place and so forth!

Also, released a new version now that will check for updates and a couple of other bug fixes…
See downloads

Feature list:
- Direct interface to iTunes via AppScript
o Skip tracks
o Play/pause
o Rate track
o Tag track (the whole point!)
- Tags pulled from Last.FM
- Tags pulled from artist’s previous taggings
- Predefined customisable tags, including:
o Moods (or whatever, but most sensibly used for moods)
o Record labels
o Instruments
- Custom tags (type whatever word you want) with auto-suggest
- Lyrics pulled from LyricWiki.org
- Alert sound when tracks aren’t tagged

Apologies to ROBERT Pointon for calling him Richard on shtaggle.co.uk! Wups!

Enjoy. :-)

Shtaggle!

Tuesday, May 20th, 2008

Apparently web based desktop apps aren’t particularly sensible.

Here’s a first-draft remake of Tagginator, which is more grounded in reality…

Shtaggle

Again, Python-Cocoa, using appscript (included, but you will need to tweak install.sh to install it).

More limited than Tagginator at present (but I’m working on it…)

Features:
- Tag from Last.FM
- Tag ‘by hand’
- Tag from artist’s previous tags
- Tag by predefined ‘moods’ (with images — placed in /Library/Application Support/Shtaggle/mood/)
- Fancy looking tag clouds thanks to … ??? (Dave?!)
- Basic iTunes transport
- Track rating
- Lyric pull from LyricWiki.org

Enjoy :)

Leave bug reports below or mail me :)

For music lovers…

Saturday, May 17th, 2008

I’m really anal about organising my music (which is strange cos I’m not anal about organising anything else in my life) so I wrote a little django site a while ago that uses appscript to interact with iTunes and set tags.

I have now ported this (fairly hackily, in true Steve-style) to an app.
It’s still a bit premature but feedback is welcomed…

Basically it presents you with tags, labels and instruments and you drag the ones you want to a box and this tags them in iTunes using the comment field.
It gets tags from last.fm for the current track, it gets tags from your library from the artist (so where you have already tagged the artist), and it uses pre-defined tags of your choosing for you to select from. you can of course just type your own too, but thereafter they get added to the suggested tags which you can then drag too! lovely.

Tech stuff:
It uses the django base to run a server on localhost:8001 which then serves up webpages, which get shown in a WebView. You can of course just hit up localhost:8001 in a webbrowser once the app is running. This is pretty nasty cos it means you need django and so forth, but it works.
Uses scriptaculous/prototype for ajax and pretty UI things (draggables/droppables)

… there are lots of loose ends, but do have a look!

more explained in the README!

http://synfinity.net/code/Tagginator/Tagginator.zip

enjoy.

UPDATE (2008/05/18 @0030):
I put some prefs in so you can easily change the port and the moods/instruments/labels.
same URL as above for download.

iPod Rip

Wednesday, April 16th, 2008

I just remembered this…
When I was skiing I wanted some of Nicki’s music from his iPod (which he didn’t have on his lappy).
iPodRip (the App) failed, so I was a bit stuck…

COMMAND LINE TO THE RESCUE!

Horrid, but it works:

cd /Volumes/Some\ iPod/
for f in `grep -R -H -a -m1 -o THING . | egrep -o “.*m[p|4][a|3]“`; do b=`basename $f`; echo cp $f /Some/Path/On/Computer/$b; done;

Where THING is some string that will exist somewhere in the ID3 tags of the files you want!

Slooowwww too. But it works. :-)

Task: J2ME MIDP on Mac OS X

Friday, February 1st, 2008

I’m now going to start developing a java app on the Nokia N95, as part of my work…

It CAN be done on a Mac, and this: http://stephendv.livejournal.com/722.html post tells you how!

I am eternally grateful that someone has worked this out and explained it so thoroughly so that I don’t have to use Windows.

Woof!

Monday, November 5th, 2007

Woof.

It’s a small python script to quickly send files across networks by setting up a tiny web server.

I like to play my music loud. Sometimes I happen to play a track that is less weird than most of my collection and my housemates (i.e. James) might like to ‘listen’ to it themselves (eh herm). James suggested a script to deliver such a track to a web browser, and we came up with this… slight modification
$ python woof -T

There we are, under OS X you now have a server that will serve up whatever tune is being played in iTunes at the time the request comes to it. (Needs AppScript)

iSingGTK

Wednesday, December 13th, 2006

Ok, here’s the first release of iSing for Linux. It’s not as complete as the OS X version (for obvious reasons) but it can tag stuff and send the data to the site. If you fancy using it/improving it please do so, but send the modified source back to me please so I can add it to the next release.

If anyone _does_ fancy improving it, the most essential feature at the moment is probably colouring the marked text in the main textview. That and building the artist->track tree in the browser. (Shouldnt be too hard… ?!)

here it is:

http://ising.synfinity.net/static/release/iSingGTK.tar.gz

Its Python with GTK so needs pygtk. and python 2.4+

Cocoa vs. GTK

Tuesday, December 12th, 2006

A quick comparison; How to get the text from a TextView (NSTextView or gtkTextView)

GTK

self.uploadHistory.get_buffer().get_text(self.uploadHistory.get_buffer().get_start_iter(),self.uploadHistory.get_buffer().get_end_iter())

Cocoa

self.uploadHistory.string()

Now tell me again why we love linux so much?

NB: For the pernickity among you, yes I DO know that Linux != GTK, however it’s a fine representation of how much more difficult and unnescessarily verbose everything seems to be in Linux, and how simple and intuitive it seems to be in OS X)

iSingGTK

Monday, December 11th, 2006

I thought seeing as python is so wonderful and the various GUI wrappers for it are also pretty great that I’d port iSing to GTK…

…It’s going well! Almost finished in fact and I only started working on it at about 2pm today. It is not, of course, nearly as sexy as the Cocoa version, but it does mean that it can be used on Linux.

Currently it will work with Rhythmbox, but if anyone uses any other music programs and would like to provide an interface to it which can query basic info (artist, title, rating if poss, lyrics) and set the lyrics, that would be awesome. It doesn’t HAVE to set or get the lyrics, these can be stored elsewhere but it would be cool to do this (my version currently doesnt).

If anyone is interested in helping out I have the project in svn so it can be poked :)

I will also be moving all the iSing guff to http://ising.synfinity.net (kindly hosted by Dave) where we shall be making shiny shiny pages for perusing lyrics and so on.

Cai is also working on a .NET version of iSing, so soon we might have the complete set!

:D

iSing LyricStag major update!

Thursday, December 7th, 2006

Cai suggested centralising the iSing Lyric database.

What a grand idea.

So here is the new, shinier iSing: [Download]
New features include:

  • Central Database upload
  • User registration
  • Version checking
  • a few bug fixes.
  • adium features disabler (specially for Dave)

Any tagged and uploaded lyrics will appear on http://synfinity.net/code/iSing/ which is basic at the moment but we are working on it :-) Expect prettiness by the end of next week!

Please have a play around and uncover bugs etc.

Playlist Prodder

Sunday, December 3rd, 2006

…is a little helper app i decided to make to allow quick copying of tracks in a playlist into a self contained directory (maintaining the artist/album/track.extension structure within that directory)

It’s not of much use but if you want an easy way to copy tracks out of iTunes and don’t want to go hunting through your filesystem, use this. It kindof assumes the tracks are in at least a depth of 2 directories (i.e. if files are in / it will probably break. but maybe not, i dunno. try it.)

Here it is

Lyric Fetch and Tagging for iTunes - iSing!

Friday, December 1st, 2006

Its 2.20am so apologies if this makes little to no sense.

After a long week of coding into the small hours I have achieved 2 things:

1 - I now know a little more about PyObjC and Cocoa and Interface Builder and XCode

2 - I have created (what I hope) is a vaguely useful application for OS X called iSing
So what is it?!

It’s a little app to get the lyrics of the currently playing track in iTunes.

“Its been done” I hear you cry.

Well yes, but iSing lets you tag the lyrics according to what you think of them… I hope to be able to do the same with the actual songs too (i.e. putting tag words in the comment field for easy searching!) but that will come later.

What’s the point in tagging lyrics? I’m not really sure, but sometimes I listen to a tune and think “Thats a really cool lyric”, then later on I’ll be thinking “Aha, its just like so-and-so says in their track, blah, — ‘The Really Profound Lyric’”… Yeah so anyway, my brain doesnt really need to be storing all that in there, so iSing can do it instead.

You can retrieve lyrics by Artist/Title or by tag word. You can tag them with colours too but as yet cannot retrieve them by colour. (Though they will display in colour.. I suppose that makes it the iSing on the cake… uhhh…. :-P )

Couple of bugs i know about:

1 - the thread that ‘auto detects’ track changes leaks objects like a … well like my car leaks radiator fluid actually.

[EDIT: FIXED... but it might still randomly hang if you are 'auto detecting']

2 - if you try and get lyrics when it says “Not Playing” it explodes. I can’t work out how to disable the toolbar button.

Ummm yes. That’s about it. I hope to add a lot more but at the moment I’m pretty pleased with it.

Thanks to Dave for writing the tree source class, I adapted it and that allowed me to bosh it in in about half an hour! woop!

Also - if you put this file into ~/Library/Application Support/iSing/lyrics.cache (you might have to make that dir, ~ being your user’s home) then you will have some pre-tagged stuff (erm… it will probably not show anything if you don’t have the tracks… but try it… it should still work and fail gracefully) to browse.

End!

PS - PLEASE let me know if it breaks, and also what you think! (If you can be bothered it will spew into console.log if it breaks, the last 10 lines of that would be useful)