Archives 2005 - 2019

How to get the spotify url from sharemyplaylists.com

published Oct 11, 2010 11:34   by admin ( last modified Oct 11, 2010 11:34 )

 

Summary: Go to http://sharemyplaylists.com/playTrack.php?postId= , and paste in the id you can see in the url from the play button after the equal sign. Hit return and you can see the spotify url in  the resulting web page. Paste this url directly into the search field in Spotify. Read on for a longer explanation.

 

If you like me are running Spotify under Wine on Linux, the Spotify integration with sharemyplaylists.com won't work. The play button on the playlists pages at sharemyplaylists.com are javascript urls that do not tell what is the spotify url for the playlist.

Clicking the play button, Firefox will reply that is does not know how to handle the spotify:// protocol and Chrome will ask a command line application to handle it, but that one will fail silently.

But can we at least see the Spotify URL? Firefox will not reveal what the Spotify URL is, Chrome will, but in a dialog box where copy does not work, and it is pretty tedious to read and type a long seemingly random string. Konqueror will do nothing at all.

But if we could get sharemyplaylists.com to tell what the spotify url is, all will be fine. Stepping through the javascript code one can see a jquery call to playTrack.php, and it turns out we can call this directly from the URL field in the web browser. If you right click the play button you can copy the javascript url.

Take the number from that one and append it to:

http://sharemyplaylists.com/playTrack.php?postId=

In the resulting web page, you can see the spotify url. Copy that one and paste into Spotify's search field and hit return and it will be loaded into Spotify.


You can move the cursor in nano with the mouse

published Sep 27, 2010 01:55   by admin ( last modified Sep 27, 2010 01:55 )

Never thought i was going to read nano's man page, but today I did.

Nano is an easy-to-use text editor for console use.

It turns out that if you supply the "-m" flag, you can change the cursor position with the mouse. You can also select menu commands with the mouse, but you cannot select text. In fact, you lose the ability to select text to get into the local clipboard also, so my enthusiasm is waning.


Firefly DAAP server, first impressions

published Sep 25, 2010 04:13   by admin ( last modified Sep 25, 2010 04:13 )

I have just installed the Firefly DAAP server (formerly known as the mt-daap server and still called mt-daapd in the Ubuntu repositories). It functions as a server for a database of your music files.

That does not sound as much until you realise that:

  • It serves out playlists as well
  • It is all really, really well done

I am trying out as a way of partioning my Rhythmbox's music library into two parts. I now have a Firefly DAAP server running, serving out a directory that is a mirror of my Sansa Clip portable player. In this way I can separate the music on that one (mostly latin music) from the music in my main library on the hard disk. Rhythmbox will treat them as completely separate entities with their own playlists and music libraries respectively.

So far, Firefly works like a charm. It feels solid, has a very functional web interface and is fast. I am impressed!

Will get back with more info later

The purpose of this project is built the best server software to serve digital music to the Roku Soundbridge and iTunes; to be able to serve the widest variety of digital music content over the widest range of devices. Current stable releases have been reported to run on Linux, all the BSDs, Solaris, AIX, and a variety of embedded devices such as the Linksys NSLU2, the Maxtor MSS, and the Buffalo Linkstation, to name but a few.



Läs mer: Firefly Media Server :: Home Page


Put -print and -print0 last in a unix command find expression

published Sep 22, 2010 06:28   by admin ( last modified Sep 22, 2010 06:28 )

 

I had treated "-print0" as just another flag to the find command. It is not: In fact when find encounters a "-print" or "-print0" command it prints right then and there, and any flags coming thereafter are ignored (unless another -print or print0 command follows them).

I first tested like this:

find -print0 -name "*.mp3" |xargs -0 tag-command --flags

But that is wrong! The -name flag is completely ignored

This is the way it should be:

find -name "*.mp3" -print0|xargs -0 tag-command --flags

Thanks to jax for pointing this out.

This actually works:

find -print0 -name "*.mp3" -print0|xargs -0 tag-command --flags

If you for some crazy reason would like to pass all files to the tag-command, but pass mp3 files twice...


Use bash to loop over and convert, rename files

published Sep 20, 2010 04:02   by admin ( last modified Sep 20, 2010 04:02 )

Found this on the Internet, will add inks if I find the sources again:

Batch convert wav to mp3:

for f in *.wav ; do lame -V 2 "$f" ; done

Batch rename mp3s

for f in *.mp3 ; do AUFILE=`echo "$f" | sed 's/.wav//g'` ; mv "$f" "$AUFILE"; done

 


Making python programs as executables on Windows and Linux

published Sep 16, 2010 01:20   by admin ( last modified Sep 16, 2010 01:20 )

This is just a note to self on what I used to make executables of my python programs for Linux and Windows respectively. It is now some time since I did i t so I had to look at the documentation I wrote for play-next-pause:

 

It is pyinstaller for Linux and Py2exe for Windows.


Open source music fingerprinting

published Sep 13, 2010 10:38   by admin ( last modified Sep 13, 2010 10:38 )

 

LibOFA (Library Open Fingerprint Architecture) is an open-source audio fingerprint created and provided by MusicIP (http://www.musicip.com). It is available cross-platform (win32, OS X, nix), and available for anyone to use in their own digital music applications.



  musicip-libofa - Project Hosting on Google Code

See also: lastmatch.py -command that identifies mp3s


Good article on Erlang from the creator

published Sep 11, 2010 02:24   by admin ( last modified Sep 11, 2010 02:24 )

 

The same component isolation that made it effective for large distributed telecom systems makes it effective for multicore CPUs and networked applications.



Läs mer: Erlang | September 2010 | Communications of the ACM


When J is not J: e-mail miscommunication

published Sep 09, 2010 01:23   by admin ( last modified Sep 09, 2010 01:23 )

One of my customers seemed to had gotten into the habit of calling me "J". I got e-mails like "Nice work J!", "Copy and paste J!".

After about a year of this, actually triggered by the "Copy and paste J!" phrase in an e-mail today, I had to write back and ask if the customer was angry or frustrated about something.

It turned out that what arrived as "J" on my side had been a smiley on his side, but due to some incompatibilities between the e-mail systems, it became mangled into a "J" when I got it. Which by coincidence is of course the initial of my given name.  I had started to think that the customer had some deep seated passive aggressive anger issues.


Märkliga krigsrubriker i SvD om valsystemet

published Sep 01, 2010 11:57   by admin ( last modified Sep 01, 2010 11:57 )

Man bör väl egentligen mer uppmärksamma tidningar när de gör bra saker, men ibland är det så enkelt att peka ut något som blev fel. Det finns kritik i Danmark mot det svenska valsystemet. Det kan man skriva om. Ett valbevakningsorgan skickar inte observatörer till det svenska valet för att det inte har någon kritik att framföra. Det kan man också skriva om. Men om man sätter ihop dessa diametralt motsatta nyheter i en krigsrubrik så kan det bli konstigt:

Det verkar nämligen på rubriken som om danskarna och OSCE tycker samma sak: Danskarna kritiserar, och OSCE är så uppgivna över sakernas dåliga tillstånd att de inte en ids komma.

Det svenska valsystemet har blivit föremål för en internationell debatt. Det är framför allt i danska tidningar som den svenska valsäkerheten blivit en het fråga



Läs mer: Valobservatörer nobbar det svenska riksdagsvalet | SvD


A buildout run from its own bootstrapped python

published Sep 01, 2010 06:32   by admin ( last modified Sep 01, 2010 06:32 )

Just a quick note so I can find it again:

Because the recipe plone.recipe.zope2instance relies on zc.recipe.egg, it also supports the python option. However, the recipe plone.recipe.zope2install did not support that nice option. I added the option and made a new 3.3 release.



Building custom Python in the same buildout as Zope2 — BubbleNet - Plone and Zope services in Belgium


Europeiskt försvar oroande svagt

published Aug 28, 2010 07:12   by admin ( last modified Aug 28, 2010 07:12 )

Alltsedan andra världskriget har den demokratiska delen av Europa förlitat sig på Pax Americana - att USA har varit tillräckligt starkt för att garantera vår säkerhet.

Men USA står mycket möjligt inför stora ekonomiska problem som kan göra att de inte kommer att kunna - eller vilja - garantera Europas säkerhet med samma emfas som idag.

Inom politiken kan man vara oense om vad staten skall göra, men ett gott försvar räknas alltid till kärnverksamheten. Europa behöver ta ett större ansvar för att kunna försvara vår frihet och välstånd.

The beginnings of a sound policy today, he argues, might be for America to withdraw from a costly war in Afghanistan and pull forces out of Europe. Such a move would shock Europeans who hope that the impact of their own defence cuts will be softened by American help in times of need.


Läs mer: The cost of weapons: Defence spending in a time of austerity | The Economist


Catch errors before they become Import Errors

published Aug 20, 2010 04:27   by admin ( last modified Aug 20, 2010 04:27 )

A python script to count bpm (beats per minute) on Linux

published Aug 18, 2010 11:53   by admin ( last modified Aug 18, 2010 11:53 )

As I have written before, soundstretch can do bpm analysis on soundfiles on Linux. However:

  • it needs wav rather than mp3 files.
  • For my music it sometimes report half the correct bpm

 

I have written a script that wraps soundstretch and lame into a command that takes an mp3 file as input and outputs the bpm.

Internally, it converts the mp3 into temporary wav file with lame, runs soundstretch on the file, gets the bpm guess from soundstretch and fits that into a window of bpms.

I do not usually write command line scripts, so there may be problems in the below code, and there are certainly some hard coded assumptions. Use at your own risk. I intend to package this up and release it in some way, but until then, here is is in its present state:

#!/usr/bin/python
DOC = ''' This program detects bpm for mp3 files. It relies on lame and soundstretch being
installed on your system.


Usage:

%s <filename>

-or pipe filenames to it.

Example:

find . -name "*.mp3"| %s\n''' % (__file__, __file__)

import os
import pipes
import select
import shutil
import subprocess
import sys
import tempfile

## Define the window for sane bpm values. This may depend on genre of music. ##
BPM_WINDOW_MAX = 240
# Do not change this one
BPM_WINDOW_MIN = BPM_WINDOW_MAX/2
###############################################################################

def _get_bpm_from_soundstretch(output):
"""Gets bpm value from soundstretch output"""

output = output.split("\n")
for line in output:
if 'Detected BPM rate ' in line:
bpm = line[18:]
return float(bpm)
return None # Could not parse output

def fit_bpm_in_window(bpm_suggestion):
"""Double or halve a bpm suggestion until it fits inside the bpm window"""

if bpm_suggestion is not None:
while bpm_suggestion < (BPM_WINDOW_MIN):
bpm_suggestion = bpm_suggestion * 2
while bpm_suggestion > (BPM_WINDOW_MAX):
bpm_suggestion = bpm_suggestion / 2
return bpm_suggestion

def analyze_mp3(mp3filespec):
"""Uses lame and soundstretch to analyze an mp3 file for its bpm rate"""

# Make a temporary working directory for storing the wav file
# that soundstretch should analyze
workingdir = tempfile.mkdtemp()
wavfilespec = workingdir + "/tempwavfile.wav"

# Use lame to make a wav representation of the mp3 file to be analyzed
wav_command = 'lame --decode %s %s' % (mp3filespec, wavfilespec)
subprocess.call([wav_command], shell=True, stderr=open(os.devnull, 'w'))

# Call soundstretch to analyze the wav file
bpm_command = 'soundstretch %s -bpm' % wavfilespec
p = subprocess.Popen([bpm_command], shell=True,stdout=subprocess.PIPE)
output = p.communicate()[0]

# Delete temporary working directory and its contents
shutil.rmtree(workingdir)

bpm_suggestion = _get_bpm_from_soundstretch(output)

return fit_bpm_in_window(bpm_suggestion)

def process_input(mp3filespec):
bpm_suggestion = analyze_mp3(pipes.quote(mp3filespec))
if bpm_suggestion is None:
print "Unable to detect bpm for file %s" % mp3filespec
else:
print "BPM rate for %s is estimated to be %s" % (mp3filespec, bpm_suggestion)

if __name__ == "__main__":
argv = sys.argv[1:]
if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): # input is piped to program
mp3filespecs = sys.stdin.readlines()
for mp3filespec in mp3filespecs:
process_input(mp3filespec.rstrip('\n'))
elif len(argv) < 1: # No pipe and no input file, print help text and exit
print DOC
sys.exit()
else: # Input file present
mp3filespec = os.path.abspath(argv[0])
process_input(mp3filespec)

It needs soundstretch and lame to be installed.


Hur ofta borde man kolla hur börserna gått?

published Aug 18, 2010 09:44   by admin ( last modified Aug 18, 2010 09:44 )

Varför skriver man om världbörsernas upp- eller nedgång som en nyhet snart varje dag på framsidan på de stora nyhetssajterna? Vore det inte bättre att ha en månatlig sammanfattning?

Eftersom börserna svänger varje dag, varje minut och varje sekund, så står det ju fritt att välja tidsintervall man vill rapportera. Att göra det till en daglig nyhet tillskriver dagsläget ett nyhetsvärde som det inte har. Om trenden är en fyraprocentig nedgång över en månad så är en tvåprocentig uppgång någonstans i mitten inte så intressant. Jag antar att man ändå rapporterar en snabb tvåprocentig uppgång för att vara först, eller i all fall inte sist, med nyheten.

Att rapportera det dagliga läget måste dock vara väldigt billigt att göra: Det är bara att läsa av förändringar under dagen, och lägga till ett känsloladdat ord: "Turbulens", "Uppgång", "Nedgång", "Oro". Det är inget fel att använda känsloladdade ord i sig för att beskriva en börs, känslor är i en funktion det vi använder för att koordinera en flock, men det blir lite mycket känslor upp och ner om man rapportera om det varje dag.

Nicholas Nassim Taleb rekommenderar i sin bok "The Black Swan" att man inte kollar börsen för ofta, just för att slippa den känslomässiga turbulensen kring rörelser som i det större perspektivet kan betraktas som slumpmässiga.

De ledande börserna i Asien steg under onsdagens handel i linje med börserna i New York. Undantaget var de kinesiska börserna.



Läs mer: Mest upp på Asiens börser - DN.se


Editing services on Ubuntu 10.4

published Aug 18, 2010 06:08   by admin ( last modified Aug 18, 2010 06:08 )

 

Summary: Install rcconf from the usual repositories and use the space bar to toggle services on or off.

 

On CentOS 5 there is a GUI for turning on and off services. on Ubuntu 10.4 I could not find anything similar installed. So I decided to go the the Ubuntu synaptic package installer and have a look around. I found bum and rcconf that both claim to have GUIs for editing runlevels, which seems close enough to what I needed.

Bum

Bum did not work. Bummer. It exited with the message: "cannot open display 1.0". I am testing through VNC to a daemonized tightVNC server, and maybe bum cannot handle that. Unrelated to this I had the same error message with an X utility called xcutsel, so maybe it is tightVNC doing something wrong, I do not know.

rccconf

rcconf worked, but it took me a while to figure out what key on the keyboard toggles a service on and off. It is the spacebar.

Screenshot of rcconf. No mouse support, use pgUp and pgDown to scroll (or arrows), space bar to toggle and tab to switch to next UI element (i.e. the OK button, and then the Cancel button).


How to put an independent VNC server on Ubuntu 10.4

published Aug 15, 2010 06:59   by admin ( last modified Aug 15, 2010 06:59 )

...and fix the drag and drop problem. The following guide worked for putting an independent VNC server running on Ubuntu 10.4. With independent I mean that is separate from the desktop session running on the computer that is connected to the physical monitor. Instead the below guide will give you an "always on" desktop session independent of what you see on the monitor. One advantage compared to desktop sharing is that you can adjust the screen resolution to fit comfortably in a window on the controlling computer. Another advantage is that you can run the vnc session as another user than who is currently using the computer, or as the same user but with a different desktop.

 

This guide intends to show you how to build a headless server with tightvnc, such that you can remotely access the server’s gui using any vnc client. I’m still working on it, so if you have any comments or questions, please feel free to let me know.

  Ubuntu TightVNC Server - Dave Lachapelle

 

I followed the instructions to a "T" and it worked. Lachapelle recommends you remove the geometry option for Ubuntu 10.4, but it worked fine on my 10.4 computer.

After install i ran the script as "/etc/init.d/vncserver start" once. Xtightvncserver then prompted me to define passwords for accessing the new desktop, one password for full control, and one for viewing only.

You could extend the script to start several independent vnc sessions, to make the server work as a multiple desktop provider. That is how I use my CentOS 5 server (which is soon is going to be Ubuntified).

 

Update 2010-08-16, 2010-08-20, 2011-01-28

Currently drag and drop is broken in Gnome on Ubuntu 10.4 when you use tightvnc. Everything else seems to work though, and in most cases you can get around drag and drop by e.g. instead do a cut and paste. However for e.g. reordering playlists in Rhythmbox there is no workaround. Actually I spend a bit of time trying to figure out why the heck drag and drop did not work, when everything else worked. A bug in Gnome itself was not the first thing that sprang to mind. According to some sources on the Internet this bug affects all remote desktop sessions, but I have noticed that x11vnc works, although that is strictly for sharing an existing screen session.

See here for bug report and workaround for the drag and drop issue:

https://bugs.launchpad.net/ubuntu/+source/gtk+2.0/+bug/587856

Basically, you need to slightly downgrade a couple of Gnome packages. I did this and drag and drop started working again. There is now what seems to be identification of the offending code upstream in the Gnome bug tracker, but it is not clear when a fix will find its way into Ubuntu.

The downgrade at the link above seems to be volatile. When you do other installs on your system, and possibly just straight updates, the downgraded Gnome packages will be replaced. I have currently done like this to fixate ("pin") the downgrade:

nano -w /etc/apt/preferences.d/pinGnomeForRemoteAccess

and in that file I put:

Package: libgtk2.0-0
Pin: version 2.20.0-0ubuntu4
Pin-Priority: 1001

Package: libgtk2.0-bin
Pin: version 2.20.0-0ubuntu4
Pin-Priority: 1001

Package: libgail18
Pin: version 2.20.0-0ubuntu4
Pin-Priority: 1001

Package: libgail-common
Pin: version 2.20.0-0ubuntu4
Pin-Priority: 1001

Package: gtk2-engines-pixbuf
Pin: version 2.20.0-0ubuntu4
Pin-Priority: 1001

2010-10-03: The pinning works! It's been in place now for several weeks, and drag and drop is still working.

2010-08-26: Added version keyword to pin file

 


Link - How to make Rhythmbox et al treat a storage as a player

published Aug 14, 2010 12:27   by admin ( last modified Aug 14, 2010 12:27 )

(See also Firefly DAAP server, first impressions.)

Rhythmbox will not initially identify the device. To get rhythmbox to see the device, you simply place a text file into the root directory of the player named '.is_audio_player' (/media/Sansa View/.is_audio_player).

You can also tell rhythmbox where to store files it transfers to the device:

audio_folders=MUSIC/
folder_depth=2



Taken from: Sandisk Sansa View on Ubuntu Linux


Getting the code for Facebook's "Like" button

published Aug 12, 2010 02:13   by admin ( last modified Aug 12, 2010 02:13 )

Here is a link going directly to a page on Facebook with boiler plate code for making a Facebook "Like" button.

This evening I tried filling out a form on Facebook that should give me the code for a Facebook button to put on a page. Trying with different browsers I could not get it to output any code, the submit did not seem to work. Analyzing the submit button, it submits to a url that if you just access it directly (i.e. a GET without parameters) you get some boiler plate code where you easily can replace relevant parts. I guess the form submit button will start to work again, but if not accessing the taget url directly works somewhat.


"Classicists have continued their efforts to suppress Wittgenstein's arguments up to the present day, e.g. on Wikipedia."

published Aug 02, 2010 02:36   by admin ( last modified Aug 02, 2010 02:36 )

Det här är lite utanför mitt område, men om jag förstår andemeningen så är det att logik bör betraktas som en slags ingenjörskonst, och att den måste användas på ett liknande sätt som ingenjörskunskap, dvs inom rimliga ramar, och att man får acceptera motsägelser. Författaren föreslår något som han kallar "Consequently Direct Logic", som ska göra logikområdet mer relevant för t ex programvaruutveckling.

Classicists have continued their efforts to suppress Wittgenstein's arguments up to the present day, e.g. on Wikipedia.



Läs mer: Incompleteness Theorems - a knol by Carl Hewitt (see http://carlhewitt.info)