Skip to main content

Posts

Showing posts from 2013

Instaworries -- and a resulting mass unfollowing hack

The other day I noticed/remembered that I had an instagram account. And, according to my sister, I was quite active on it. Apparently. I kept following new persons. That suprised me, so I logged on and investigated. “I” followed 974 (or so) persons I had never heard of… My first instinct was to delete the account.* But that would have been too easy, so I decided to investigate the Instagram-API to see if that could help me “get rid” (most) of the people I followed. And lo and behold I found this page  - very promising, so I registered an app to get access to this. Since Instagram uses OAuth that landed me a client ID and a client secret. Not awfully familiar with the innards of OAuth, I realized that for anything to work I would need an access token. Since this script was just for personal use, I figured I could just generate this once(ish) and use that to get access to my account. I followed the instructions on this (page):  http://dmolsen.com/2013/04/05/generating-access-...

Add overall lesson timing to video listings on Coursera

Marché de La Rochelle HDR  Probably about two years ago - when taking Andrew Ng's excellent "Machine Learning" MOOC, Johannes sent me a piece of JavaScript that populated the video lists with overall time per lesson just by pasting it into the URL-thingy in Chrome. Magic. Today when I sat down to start the course on "General Game Playing" that I have signed up for, but, alas, not (yet) found much time for, I thought of that piece of code and wondered if I, with my new knowledge of JavaScript, could whip up something like that. (Also I couldn't find Johannes' original one.) I quickly hacked together something this afternoon over a flat white in a hipster cafe here in Lyon. And lo and behold it worked. Then I extended the functionality to also show minutes and seconds of unwatched video - as well as total overall counters for the entire course. Now each lesson heading reads "Lesson N - Name [time remaining/total time]" instead of just ...

Fix your rapid blinking Marantz SR-6004 using nothing but 3 fingers - and a thumb

A couple of years ago my (most of the time excellent) Maranz SR6004 acted up. It did't want to turn itself on. Properly. Just stood there and blinked rapidly. Its little red light that is. At me. The solution was so simple that I didn't bother to write it down as I was sure to remember it. Alas, no. Some weeks ago it did it again. (Can it be the heat?) Just stood there blinking rapidly at me. The manual just said - as it said last time around - that it was time to return the unit to it's maker. Or similar. Some googling led me to this page:  http://www.allquests.com/question/4056803/Marantz-XXX4-Series-Failure-Issues.html  The technical term for what I had experienced seems to be "The Pop of Death". Aïe. But!, humongous letters said: YOU CAN SOMETIMES RESET THE UNIT BY PRESSING SURR MODE, CLEAR AND EXIT SIMULTANEOUSLY And so I did. And so it was fixed. And all was well. (And now I have written it down for the next time.)

D3 Map Projections revisited

One of my most popular posts on this blog is the one about my quick D3 map projections morphing hack . Today I discovered that Mike Bostock , the creator of D3 himself, has made a similar visualization now - only way nicer. Available here:  http://bl.ocks.org/mbostock/3711652  Enjoy!

10000 views! (Yes, that is decimal, not binary.)

Next week this little blog experiment will turn 6 months, and yesterday it passed 10000 views (sans counting my own revisits - in theory), so I guess some of the things I put up here are useful to others as well (or Google's counting is different than how others might do this)... Anyways: thanks. Update 27/09/2013 : 2 posts (and six months) later and the count has passed 20000...

Implementing k-means clustering in Ruby

Inspired by the partitioning problem I set about to implement a well known algorithm, k-means clustering, from memory, for fun! ... and, for science... Interestingly, this is somehow the opposite of the partitioning problem. In the partitioning problem we tried to maximize variation of categorical variables within groups, whereas here we're trying to find groups of elements that are the most "similar" to each other in a n-dimensional continuous space. The main idea of k-means is the following - if you have a bunch of elements and a given number of clusters: Create the initial clusters randomly within the space spanned by the elements (typically (always?) you would pick randomly from your elements). Lob all elements into the cluster with the nearest center (using some Euclidean distance metric typically). Recenter each cluster on the average of its elements,  If necessary move the elements to their now nearest clusters.  Repeat the "re-centering" and mov...

D3 Map Projections Morphing

Map of Australia mapped on Australia We had a very good geography teacher in high school. He taught us how one should be sceptical and keep an open mind in science (using an anecdote about a scientist proposing an alternative to the theory of tectonic drift). He was also the first person I met that had surfed the Internet - or whatever it was called back in the day. But the thing he showed me the importance of, most relevant to this blog post, is the choice of projections of world maps. You know, the whole 3D globe to 2D piece of paper business. Mapping, qoui. Some are just more equal than others. You see, yesterday evening I decided to finally take a closer look at the D3 visualization library. A couple of the demos on the d3js page , notably the excellent animated  show reel and some of the mapping examples , made me think of discussions I have had with colleagues and friends on map projections. I wondered if animating the transition from one projection to anoth...

D3, gists, and bl.ocks.org

Yesterday I stumbled upon a very useful tool while (trying to) teach(ing) myself D3, namely http://bl.ocks.org . This lets you access, and preview, your webby gists in a browser - just by browsing to http://bl.ocks.org/<gist-id>. Most handy! (The only minor down side is that there seems to be a slight latency if you update your gist before it updates on bl.ocks.org.)

Sequel on the Pi - and how to access Access DBs from Ruby (in parenthesis)

Recently I had to liberate some data from an old MS Access DB, so I discovered a gem of a Ruby gem called " sequel " that generalizes database access (for many different databases) - ORM style. Most excellent, so I figured I wanted to run it on my raspberry pi to access various sqlite databases I have lying around. Assuming you already have ruby (1.9) installed, you can simply do (in any Debian flavored Linux, for that matter): sudo apt-get install sqlite3 libsqlite3-dev and sudo gem install sequel sqlite3 So now one can fire up irb and do things like: require 'sequel' db = Sequel.sqlite('some_db.db') Etc . (This will, of course, not let you access MS Access DBs on your pi, as they rely on the "win32ole" gem - only available on windows, and the " Microsoft Access Database Engine " - also only available on windows. More info on how to connect to those kinds of database can be found here  - under 'ado'.)

MIDI channels in Cubase - or there, and back again

The other day a friend and I experimented with connecting his excellent monotribe (with the miditribe extension) to my Cubase to see if we could record the MIDI-signals coming from it. For Science! This made me realize that, being a MIDI-noob, I hadn't understood how MIDI worked in Cubase, and none of my google searches seemed to help either, since being a MIDI-noob, I probably didn't have the right vocabulary to specify the searches with. The thing is that the 'tribe is supposed to send the synth MIDI on CH 1 and the drums on CH 10. We added two midi tracks in cubase and selected the channels we wanted in the track info. Like so: This did not work, as we got a mix of drums and synths at once all over the place. Interesting, but not right. To try to understand this we created a default project with 16 MIDI tracks, one per channel, and lo and behold all MIDI was sent to all channels. OK. We figured we needed to filter out just the channel needed per channel so we ad...

Counting in Ruby Revisited - Benchmarked

After writing the post a while back on counting in Ruby I wondered if the two different implementations I outlined had similar runtimes. Inspired by this post by makaroni4  I went ahead and wrote the following little "benchmarker": Loading... So, you see the block centered implementation is about 20% faster than my initial one. Interesting.