Wednesday, August 12, 2015

A better use of Caps Lock

One of the best ideas of Colemak is to remap the Caps Lock key to the backward deletion action. I never type in all caps anyways (who does?), but I mistype things all the time, especially now that I'm learning a new layout. Moving backward deletion to the Caps Lock key also freed up my Backspace key, which I in turn mapped to the forward deletion action, an action which my compact keyboard previously required a highly awkward combo to achieve. Am I happy? Yup.

Unfortunately, though, the Colemak that came bundled with Yosemite did not make the magic happen by itself. Or maybe it was not unfortunate at all, seeing that the solution also work for any layout, including my beloved Dvorak (in case I decide to go back). These are the instructions I followed (for Yosemite):
  1. Download and install Seil.
  2. In System Preferences -> Keyboard -> Keyboard (the tab) -> Modifier Keys, select "No Action" for Caps Lock. Remember to do this for all your keyboards in the drop-down list (see picture; if you don't, then pressing and holding to delete multiple characters might not work).
  3. Open Seil, and select "Change the caps lock key." Keycode 51 is for the backward deletion action, which is also the default.
  4. In Seil under "Other keys," the delete key can also be remapped. Keycode 117 is for the forward deletion action.
  5. Quit Seil and reboot for changes to take effect.

Tuesday, August 11, 2015

Colemak: Yet another keyboard layout

(It has been a while since last time. I don't feel sorry; it was never my intention to update regularly. Many things have happened which deserves a mention on the blog, most of which I have already forgotten; some of which I will never forget)

I am writing today because I foolishly decided to learn the Colemak keyboard layout. This in spite that I already write fluently in the rivalling ergonomic layout Dvorak, and that I am to present my master's thesis in less than a week. Writing this short paragraph has already given me a mild headache due to the vast number of characters required to make the words come together, each of which demanding my full attention. If someone gave me a penny for every character I wrote, my thesis alone would have earned me a respectable $1,427.50. If I then sold the pennies for their copper, that would yield a whopping $2,148.42. Enough to buy a new iPhone. And an Apple TV. And an Apple Watch. At least a non-exclusive version.

It all started because I co-inspired two classmates to switch layouts. However, they didn't switch to just plain old Dvorak, which was what I taught myself 15 years ago; these guys were betting on newer and fancier layouts more tailored towards computer scientists, namely Colemak and Programmer Dvorak. Admittedly, some special characters common to programming were awkwardly placed on my Dvorak layout, such as [] and {}. Thus, I wanted something better too. So here I am.

Of course, I first tried Programmer Dvorak. I really liked the idea with special characters as default on the number row, and as a Dvorak native, I learned it quickly. However, some of the most common symbols and numbers (for instance =,*,0,1) had an outright horrendous placement in the unreachable middle of the row. Yack.

So now I am typing my first lines of Colemak. We'll see for how long.

Friday, February 22, 2013

The best of Carnegie Mellon

It is now more than three and a half years since I moved to Pittsburgh. I do not believe I have senioritis quite yet, but graduation is approaching at an ever-increasing rate, and I have already been considering my future for a couple of months. And while it certainly is the time to think about the future and the many great opportunities it holds, it is also the time to evaluate the past and appreciate the best of Pittsburgh and CMU while I am still here. So, here is my attempt to compile my best memories from four years at CMU.

Orientation
As an incoming freshman, you are required to attend one week of orientation before classes start. This week is packed with exciting activities, all aimed at getting to know each other better. I got a lot of great friends in that first week, and we had tremendous fun. We went bowling, went on a boat trip with big speakers and dance music, and we played "I gotta feeling" by The Black Eyed Peas over and over again. We even had a giant "rock, paper, scissors" tournament among all the (over 1500!) incoming freshmen at Playfair.


The atmosphere was simply amazing, and everybody felt comfortable randomly talking to everybody else. All without a single drop of alcohol.

The housing communities
From my first year in Henderson House, through my sophomore year at the Neville Co-op, junior year in West Wing and senior year in Morewood Gardens, an excellent community and great friends have always surrounded me. I have had some truly excellent roommates, which I hope to keep in touch with as I leave Carnegie Mellon and leap into the future. Who would have thought I'd be a best friend with one from the Bronx?

Yuva India Restaurant
This restaurant simply serves the best meal that a man could ever wish for. Located at Craig Street, this is where I end up whenever it is too cold or too wet to walk to Oakland. Frankly, I might end up here even it is warm and bright as well, because the Lamb Karahi is just amazingly good; at least when they get it right, which they do most of the time. At least 50% of the time. Oh, and the woman in charge who wears sunglasses indoors? Priceless!

The academic community
I have no other word than outstanding to describe the academic community I have found here at Carnegie Mellon. It was the rumour of great work ethics and friendly geeks that attracted med to this school in the first place, and the CMU community has exceeded my every expectation. This is a school were everybody takes deep pride in their work, and I have always been encouraged by my peers and teachers to give my very best in everything I do.

While we certainly had a superb community in my TAF class at Knarvik Vidaregåande Skule (high school), our focus on quality and work ethics was not quite at the level of CMU. The support that this community has given me in pursuing excellence is something for which I will be ever grateful. I now have an appreciation for hard work that I did not have before. It has grown on me this that Andrew Carnegie once said: "My heart is in the work."

The weather
Growing up in the Bergen Area on the west coast of Norway, I am acquainted to rain; thus, the rumour I found on the Internet about terrible Pittsburgh weather did not at all scare me. And when I got here, it turned out that the weather is excellent! Maybe a little too hot the first two weeks of fall, and a little too cold the first two months of spring, but generally: the weather is excellent. The sun shines regularly, the temperature is great and the rain comes in sudden thunderstorms rather than being spread thin across several days. It is great! It was particularly funny my freshman year, when 30 cm of snow fell on one night. The streets were closed for three days! It gave me time to make this video about Pjeff.


Volunteering at an old monastery.
We restored the building so it could
be used for after-school programs
The clubs and organisations
The variety of organisations on campus is tremendous, and I have been blessed to participate in several of them. My freshman year I went to the Dominican Republic with Alternative Break, and started my very own Floorball Club with a friend from Singapore. The university supported us by providing us with a place to play, and helped fund some of our equipment costs. I have also been a part of one of the many great Christian fellowships on campus, an ad-hoc soccer group, the table tennis club, and the pool club, as well as academic honour societies.

The educational flexibility
At Carnegie Mellon, we are allowed to pursue depth and breath sequences of our own choice, by putting together our own schedule every semester. As a student in Electrical and Computer Engineering, I have been able to take classes from the Departments of Civil Engineering, History, Philosophy, Computer Science and Music that I find interesting. I have for instance taken several interesting courses in religion, and the music courses I am allowed to take counts towards my general education requirements. I believe it is an excellent quality of the education model that the students gain deep insights in more than a single field.

The ice cream
Pittsburgh, and in particular the Oakland and Squirrel Hill areas, are the Mecca and Medina of great ice cream. Carnegie Mellon, being strategically located between the two, is thus a great starting point when hunting for the sugar shot of the day: Go east to Squirrel Hill, and you will experience the deepest, darkest, most fulfilling chocolate milkshake that man has ever made at the Cold Stone Creamery; Go west to Oakland, and your taste buds will praise you in utter astonishment for the chocolate with hot fudge you got at Dave & Andy's Homemade Ice Cream.

The professors and teaching assistants
Getting to know the teachers and professors have been one of my great experiences at Carnegie Mellon. The vast majority of them do their upmost to provide plenty of time where the students may ask clarifying questions, and the professor or his assistants will answer general or specific questions to the best of their ability. While I was ignorantly unaware of how great this offer really was my freshman year, I really started appreciating this form of learning when I became a teaching assistant myself, first semester of sophomore year. Talking about course material (or even material that only is only vaguely related to the course) with course staff is simply one of the best ways I could possibly learn, and also a good way to find fellow students to work with.

One of my many favourite professors, Helmut Vogel
Having the opportunity to teach as a course assistant for three semesters myself was also a rewarding experience, both because of how well I got to know the professor, and also because of the rewarding interactions with students in the course. I sincerely hope I will have the chance to do more (that resembles) teaching in my future career.

Research opportunities
The research opportunities at Carnegie Mellon are wide and diverse. As an undergraduate in Electrical and Computer Engineering, I have been encouraged to participate in research projects with world-renowned professors, and one of the research projects I have participated in have already shown some quite remarkable results. Applying what we learn to a real research projects is immensely rewarding, and is an excellent supplement to the required Capstone project classes that I think everybody ought to take advantage of.

The game room
How often do you get to play as much pool as you want, on good tables and with excellent opponents? Answer: All the years that you spend on Carnegie Mellon. The game room community is diverse, and covers table tennis players, DDR –dancers, foosball players and pool players, as well as the many occasional flirters who attempt to teach their targets how to hold a pool stick, and those who just play randomly with a bunch of friends. Yup, there is an air hockey table and a curling –table as well.


In sum, I am very happy that I studied at Carnegie Mellon, and I would have chosen to study here again. I hope to maintain the best friendships I have made here, and I hope to come back to visit during spring carnival some time. It has been an honour staying here, and I am confident that Carnegie Mellon University will continue to excel in teaching and research in years to come. I pray that its students, staff and faculty will continue to see the fruits of their hard labour, experience personal fulfilment and live in happiness. As they would put it here in America:

May God bless Carnegie Mellon.

Tuesday, February 19, 2013

Serial Communication with RXTX in Java 1.6 for Mac OS X 10.7 (Lion) with Intel 64 bit processors

After spending way too many hours installing the RXTX library for Java on my Mac, I though it might be worthwhile to save others the trouble by sharing what I did to make it work. (Version 2.2) (2/18/2013)

None of the binaries I found that were available worked for me, and getting the configuration and build instructions right was neither completely trivial; some of my attempts plainly did not import at all (even though my code seemed to compile nicely), while in other attempts the code crashed and gave a non-sensical PortInUseException. (What I gathered from reading the online discussions, is that there are some issues regarding 32-bit vs 64-bit architectures, some issues regarding different parts of RXTX not working well together, some issues with the use of lock-files in Mac, and some issues with regards to RXTX not always working well with Java 1.6)

In any case, these are the steps I found to work:

(Most of which are based on this far more insightful walkthrough by Chris Bartley)

0. Remove all files from previous attempts to make RXTX work.

1. Install XCode Command Line tools, if you haven't already (I used XCode 4.6). (You can get XCode from the App Store. After XCode is installed, open XCode, and go to XCode -> Preferences -> Downloads -> Components -> Command Line Tools to install)

2. Download the source in order to build RXTX yourself. (None of the binaries that I found online worked for me, but you are welcome to jump to step 8 using my binaries if you want). You can get the source by telling this to the Terminal:

$ export CVSROOT=:pserver:anonymous@qbang.org:/var/cvs/cvsroot
$ cvs login
Logging in to :pserver:anonymous@qbang.org:2401/var/cvs/cvsroot
CVS password:
$ cvs checkout -r commapi-0-0-1 rxtx-devel

For the password you may have to type something random (e.g. a space character), if the Terminal goes off looking for a password in a file; but you should not need a password per se.

3. Check that, in your ~/.profile, the PATH environment variable has /usr/bin and /bin first (if needed, modify .profile so that the places where you set the PATH (e.g. "export PATH=$PATH:/opt/local/bin:/opt/local/sbin") have the additions at the end)

4. Set the variable JAVA_HOME:
$ export JAVA_HOME=`/usr/libexec/java_home`

(This step may not be necessary, but if Chris Bartley includes it, so do I)

5. Make sure there are no spaces in the absolute path to the rxtx-devel folder

6. Run the configuration script in the rxtx-devel folder
$ sh ./configure

7. In the rxtx-devel folder, manually edit the Makefile such that the JAVAINCLUDEDIR variable gives the correct path for the file jni_md.h (you will have to search for the file jni_md.h on your hard drive).
JAVAINCLUDEDIR = /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers

Of course, your path will be different than this; it will be the path to where you found jni_md.h. (This variable was found somewhere around line 107 in the Makefile when I did this.)

8. Build
$ make

Two files are produced with which we are concerned. They are:
    * rxtx-devel/RXTXcomm.jar
    * rxtx-devel/i386-apple-darwin11.4.2/librxtxSerial.jnilib
    
Note that the name of the folder I call "i386-apple-darwin11.4.2" may change depending on your system. This is simply the folder name I got, running OS X 10.7.5 (Lion) on a 2.4 GHz Intel Core 2 Duo (64-bit architecture).

(The files that I produced in this step are available here, in case you want to try those, rather than making your own.)

9. Move the two files acquired in step 8 to /Library/Java/Extensions
Updated! See below

10. Add execution permissions to RXTXcomm.jar
$ chmod +x RXTXcomm.jar

At this point, RXTX works for me. In your Java source file, you should only need to
import gnu.io.*


UPDATE (2/20/2013)
It turns out that step 9 above will break some other Java applications (e. g. the Arduino IDE). A better version of step 9 is the following (these steps are specific to Netbeans, but I am sure you can do something similar using other development environments):

9.1  Move the file RXTXcomm.jar to a location where you can access it from the project where the library is needed, e.g. in a folder "libraries" inside your project folder.

9.2  Move the file librxtxSerial.jnilib to the base directory of your project

9.3  Open your project in Netbeans, then right click on the "Libraries" folder and choose "Add JAR/Folder." Find and select the file RXTXcomm.jar in the dialog that shows up. Since librxtxSerial.jnilib is in the base directory for your project, it will be automatically recognised.

Sunday, October 21, 2012

Vote According to Faith


As a republican pastor friend of mine once pointed out to me, I am a very opinionated person. I will make no attempt to deny that characteristic, and by writing this blog post, I assume that trait will only become more apparent. Because I will here give my take on the presidential election that is coming up, and explain why I hope my favourite candidate will be re-elected.
First of all, let me defend my right to have an opinion, since this may not be obvious to everyone. I am a Norwegian citizen, and do not have a permanent residence in the United States. I have, however, lived in the US for the last three years during the undertaking of my bachelor's degree. More importantly, the United States is the leading nation of the western world, is the major player in the NATO military alliance, and has an enormous cultural, economic and political influence around the globe. The course that America is taking has had, and will have, a direct impact on the life of me and my family, my country and our common world.

Still, the most important reason why I am entitled to have an opinion is because the US represents me, whether I like it or not. The actions of America represent the actions of the entire Western World. The actions of America are by many also (mis-)understood to represent the actions of Christianity. I love my home, my heritage and my faith, and it is important to me how these are represented. Therefore, I have an opinion.

Secondly, let me make it clear that my opinions are not representative of Intervarsity Christian Fellowship, Woodland Hills Church, any other faith-society I may or may not associate with, or Jesus Christ himself; my political view is merely my personal opinion, though of course influenced by my faith and worldview. In fact, Jesus specifically stated that his kingdom is not of this world.

"My kingdom is not of this world. If my kingdom were of this world, then my servants would be fighting so that I would not be handed over to the Jews; but as it is, my kingdom is not of this realm."
 - Jesus (John 18:36)

"You know that the rulers of the Gentiles lord it over them, and their high officials exercise authority over them. Not so with you. Instead, whoever wants to become great among you must be your servant, and whoever wants to be first must be your slave – just as the Son of Man did not come to be served, but to serve, and to give his life as a ransom for many."
 - Jesus (Matthew 20:25-28)

The job description of a Christian, then, is not to pass laws against people, like politicians do, but instead to be a servant for the people around us. The job description of a Christian is not to participate in election campaigns to protect our rights or take America back for God; rather, the Kingdom of God is manifested whenever we pick up our cross and sacrifice in love for the weak and the oppressed. The job of the church is not to dictate a certain moral for people outside of the church, but to worship God by merit of how we live our own lives.

At this point I was supposed to tell you whom to vote for, and why. But that will be for another time. I temporarily persuaded myself to shut up.


Woodland Hills Church: The cross and the sword
Jeff Figearo's blog: The cross and the sword
Warrior of Agape: What has faith got to do with it

Greg Boyd on the difference between the two kingdoms:


Tuesday, July 10, 2012

Ten things that should be legal

It has been a popular topic for discussion in certain political circles lately, which bans are stupid, or if bans are stupid at all. It started with the leader for the social liberal youth party, Sveinung Rotevatn, who published a list of 21 things he wanted to allow. Now, I totally agree with his sentiment, but I could not agree less with most of the list itself. Therefore, I have created my own list of things I want to allow, borrowing some from Sveinung and bringing up some of my own.

Water Scooters
Water scooters are fun boats, and if people use them irresponsibly, we should stop the irresponsible use rather than the vessel itself.

Bringing liquids through airport security
Airport security is not at all proportional to the risk of terrorist attacks. We should start easing up the security hysteria by allowing passengers to bring their sunscreen and chocolate milk through security.

Breeding Rabbits
I see no reason why breeding rabbits for fur is any different from breeding any other animal for fur. If rabbits are tortured in breeding, we should stop the torture, not the breeding.

Segway
Moving from one place to another can be tiring for some people, so why not allow them to use a Segway?

Walking the dog without a leash in certain areas
The vast majority of dogs do not need a to be in a leash to behave properly. Every municipality should allow some part of their land to be free for walking dogs without a leash. For instance, Bergen could allow this on Løvstakken and Blåmannen. Of course, the owner of the dog will still be 100% responsible for the dog's actions.

Hunting with bow and arrow
Bow and arrow is an old and historic way of hunting. And The Hunger Games was an excellent movie. I vote that we allow it.

Right turn on red
It is effective, easy to learn, and is used in other countries with success. Why not give it a try?

Biking across a pedestrian crossing
Biking should be convenient and legal. No reason to have a law that nobody follows anyways.

Dual citizenship
In many families, the most natural state would be to have citizenship in more than one country. The disadvantages are few, and it works elsewhere. I say go for it!

Voting for 16-year olds
16-year olds are interested in politics, and care about the society, probably more than many older people do. I say we give them a vote.

Thursday, April 12, 2012

Distributed Laptop Orchestra

So, this semester I've been involved with this really interesting class at Carnegie Mellon: 15-323 Computer Music Systems and Information Processing. Taught by one of the creators of Audacity and Nyquist, Roger Dannenberg, the course aims to give the students a broad background in how music is treated programatically, to the point were at the end of the semester we can all co-operate to build a full-blown laptop orchestra application!
On Monday April 16, it is going to happen; the world largest distributed laptop orchestra is going to perform as a part of "Symposium on Laptop Ensembles & Orchestras" at Louisiana State University. Apart from LSU and Carnegie Mellon, five more universities in the US and UK will participate

Stanford University
Texas A&M University
University of Colorado
University of Huddersfield (West Yorkshire, England)
Queen's University (Belfast, Northern Ireland)

It will definitely be a late night for our friends on the east side of the Atlantic, as the concert starts at 20:30 EDT (New York -time). That equates to 01:30 BST! And at that time, I will sit on the stage at UC McConomy, eager to hammer notes and sounds out of my keyboard. I expect my fellow europeans to be the same.

The previous CMU laptop orchestra
I also hope the laptop orchestra will actually work. That piece of software right there is running my code - I do not want it to crash with such great universities watching and participating.

If you can't come to McConomy to hear the Carnegie Mellon -version, you should tune in to the live stream from LSU!



If you are interested in the source code for the project, it is available as open source. In fact, you can even download the code and participate yourself! There are instructions on how you should use the system online as well, so I will not go into details here; but I'd still like to give a brief technical overview of the project, and discuss some of the interesting challenges:

(At least to me, they are. But I take no offence if you stop reading now :-)

A performer's computer is connected physically to a live PA system in each of our 7 locations via mini-jacks on the headphone port; our software contains sampled sounds it will loop or play once, depending on the nature of the sound, and it can also generate a few waveforms.

(In order to do this, we must know how to generate, process and play back music in real time on the computer. The music is generated in blocks of bytes, each representing a very short time of sound, by the standard of an ear; this block is then pushed into the computer's music playback buffer, and then the next block is generated. This must be done on a high priority thread, to prevent any lagging. That kind of stuff is what you learn in this course.)

After the music is pushed out to the analog mixer, it is mixed and sent two places: a) To the local speakers, and b) as a soundstream to LSU.

In the local mixer, there is then one input channel for each performer, as well as a stereo input coming from LSU. The stream from LSU contains all the sounds from LSU as well as all the sounds from the 5 remaining locations. Thus, there will be some pretty significant latency issues; speed of light is only so fast, and there is lots of network jitter as well. The sound from LSU will then have some latency, and the sound from the other universities will have an average of twice that latency. This also has the consequence that the performance will sound different at each location, depending on the local mix and also on the varying latencies.

Roger Dannenberg, conductor
(play picture as sound)
So how do the performer know what to play? It certainly can not be very rhythmic considering the constraints discussed in the previous paragraph. But it should be somewhat synchronised, to create at least some sense of structure. To do this, we have created a conductor interface.

The conductor (Roger) will be able to send various conducting messages through a special mode in the software. These messages will appear in the window for all the performers, so that the we can play according to the conducting; variable parameters controlled by the conductor include

* Intensity
* Dynamics
* Pitch (high/med/low)
* Play/stop/fade in/fade out
* Music language/Sound architecture
The performer interface; top half is determined by conductor
Note that the conductor can send different messages to different universities, or "orchestras" as we cleverly named them in the software. There is also a chat system based on an hierarchal form, so anyone can send chat messages to anyone, everyone in a single orchestra, or everyone in the federation of orchestras.

To make all of that work, there is a lot of network logistics going on. The network is organised by nodes and supernodes; all nodes are connected to a supernode, and all supernodes are interconnected. When sending a message from a node (say, the conductor node), the message is first sent to the supernode, then from the supernode to the correct supernode(s) (if applicable) and then from the supernode to the individual node(s).

But, how do the conductor node know at what IP address its supernode is? To do this, each node will register with a special server (currently running at CMU) when they start up. This server will inform the node of what IP its supernode has, or if there is no supernode yet. If there is no supernode yet, then the supernode will initiate a connection when it is set up. In this fashion, as soon as a node is registering with the server, the server will provide information about all the nodes with which it should connect; if the node is a supernode, this includes all nodes in his orchestra, as well as all the other supernodes.

In addition to this, there is a clock synchronisation protocol running, and there is also a performance monitoring system that keeps track of how much data is being sent to and from each node. My contribution to the code has mainly been on this performance monitoring system. It basically collects information of all messages going in and out of a node, as well as the latency to the closest "parent" node (where the node containing the original clock is the uppermost parent; this should be the supernode at LSU).


In sum, this is going to be pretty awesome, and I'm looking forward to celebrate the anticipated huge success of our concert. Wish me luck, and tune in on Monday!

CMU School of Computer Science: Laptop Orchestras in Seven Cities Unite Via Internet for First-of-its-Kind Concert
15-323: Computer Music Systems and Information Processing
LSU: Symposium on Laptop Ensembles & Orchestras