Sunday, November 10, 2013

Things a PC guy is learning about Macs

I've recently bought a used iMac from ebay in order to learn more about these computers. I've learned a few things since buying it. I'm hoping to post on here from time to time various tidbits that I've learned. The ultimate goal is to become certified as Apple Certified Support Professional.

The windowing concept in Mac OS is a little different from Windows, or even X Windows. If you hit the red button at the top left of a window, it doesn't close the application. There's a doc at the bottom of the screen with several common applications, and any running applications. If you look under/in front of an application and see a blue light, that's your indication that the program is still running. Even if there are no open windows, a program will continue to run until you exit it. Two ways that I know about include going to the menu at the top when the program is active, picking the main menu item (Usually the program's name) and then picking the Quit option at the bottom. The other way is to make the program active, then push the Command-Q keyboard shortcut.

On a keyboard with the Windows keys, the Start button will stand in for the Command button on an Apple keyboard.

Here is a list of other keyboard shortcuts.

I like the way Mac OS software is distributed. Mostly in the form of DMG files, which are like disk images. Opening one causes it to show up like a hard drive, or CD. According to information I've found online, they can be compressed or password protected as well. Installing a program can be as simple as downloading a dmg file, mounting it, and then copying the program to the application folder. The dmg file could also have an installer as well.

It was incredibly easy to setup my printer. I've read the backend of the printing support is based on CUPS which also can handle printing in Linux. Common Unix Printing System was originally what it stood for. Mac OS X has a BSD-based kernel named Darwin. That part of the system is released as open source software. It's missing elements required for the GUI part of Mac OS and can't run Mac OS applications when installed separately from Mac OS X. You can interact with the BSD side with the Terminal application in Applications|Utilities.

The default shell for the Terminal is TCSH, but others are supported and included depending on the version of Mac OS X. Bash, csh, ksh, zsh are some of the options available. Looks like according to the Wikipedia article on TCSH, it's no longer the default as of OS X 10.3.. the default shell is BASH. Running "echo $SHELL" on mine seems to back that up.. the result was "/bin/bash"

X11 was already installed on the one I bought, apparently it is no longer included by default in new installs of Mac OS X. I've used this before to open an X session to one of my Ubuntu computers. It's handy to do so in order to run programs on that computer, or manage files on it.

I've played around with various applications and settings so far. I tried out the Speech recognition. It's not very accurate for me, but it is a neat idea. It makes me wonder if later versions of OS X have that supplemented with SIRI or even still have it at all.

Wednesday, October 30, 2013

Minesweeper clone in Javascript

This is a little project I've been working on lately. It's a clone of Minesweeper implemented in Javascript. I'm not done yet but it is playable. It's missing some features that are common in Minesweeper and other clones of it, such as a timer.

It currently renders game board as a table of set size: 20x18, with 50 mines.
I don't consider this done, I certainly need to re-factor a fair bit of the code to make it more maintainable. Not to mention also easier to use. I'd also like to add a way to let the player choose his or her own play size and number of mines. Maybe even add a timer, and a way to submit scores to a central server whether that's mine or someone else's.

This is playable though. Most of what I consider to be the basics of the game is here. It will randomly generate a field of mines, put the numbers down over the whole board where they are suppose to be, if you click on a blank space then it will expand until it hits a non-zero number, I've even added the flags. If you right click on an unexplored space then it will turn yellow to flag that space as having a mine. Once you've exposed all of the spaces without mines, it will end the game and all of the mine spaces will turn green to show they are cleared. Refresh the page to start a new game.

Like I said, features that I want to add include:

  • GUI for player to choose their own options.
  • Timer to show how long the game has been going, starting from the first move.
  • Ability to right-click on a number and, if you have the right number of adjacent spaces flagged, have it expose the remaining spaces.
  • Possibly a way to submit high-scores to a website. Might not do this though, due to people who would cheat it.
  • Modify the code so when you click on a mine, it will stop you from making additional moves and turn all of the mine spaces red.
  • Make it impossible to click on a mine as the first round of the game. I think other variants regenerate the board before revealing that space.

This is implemented as a Single Page Application, so if you go to the file menu and save it to your drive then you can run it from there, or from a flash drive without an Internet connection. Of course if you do, you'll miss out on automatically getting any updates I post on my website. Although, maybe I could embed a version number in a variable then link it to a Javascript file on my website that simply compares the variable to a variable in it and shows a link if they don't match.

Wednesday, September 11, 2013

Access 2010 Runtime Security Notice

This was a particularly hairy problem. There's an error message that shows up whenever you open a database with embedded code. It says "A potential security concern has been identified." Followed by a warning in bold. "It is not possible to determine that this content came from a trustworthy source."

(I blanked out the name of the file here)

Many guides I found on the Internet showed this as the registery code to insert to make that go away:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations]

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location0]

But they forgot one key thing. This is the only way I got this to actually work on my Windows XP test machine.
Windows Registry Editor Version 5.00


[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations]

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location0]
Note the VBAWarnings key above? That is the deciding factor for Access 2010 Runtime to not show the warning message box on my Windows XP test machine. Your mileage may vary.
The AllowNetworkLocations key will allow it to apply this to files stored on a windows share.

Wednesday, June 26, 2013

Citrix XenServer 6.2 Open Source!

This is big news. You can still purchase a license for it, but instead of enabling features, it only enables you to use Citrix support and apply hotfixes with XenCenter. Hotfixes can still be applied without the licensing, but you have to use the command line to do it.

Feature Matrix

I've been running a server here with Ubuntu for the host and using the XAPI package to do Xen virtualization (and use XenCenter) but it never really worked right. You could see the virtual machines and control the mouse but keyboard events never made it through.

Hopefully I can find time this week/weekend to install XenServer 6.2 on it.

Sunday, May 26, 2013


This is a protocol for working with files over HTTP (or HTTPS). Thanks to that, it's very possible to setup a file share that can be accessed through a firewall without opening any more ports. You can use a WebDAV share with native clients built into many modern operating systems or by using dedicated clients.

One thing to be aware of is that Microsoft Windows Vista and 7, by default, have an option set to not allow Basic Authentication over insecure HTTP traffic. They will allow you to use it over and SSL connection however. This is a problem when using an owncloud instance without SSL. How to mount ownCloud storage over WebDAV. If you follow the Microsoft KB 841215 article, you can change that to allow Basic Authentication without SSL for Vista/7. One thing to note, username and password credentials are sent in the clear without even encryption in this mode so it makes it much easier for someone to snoop your credentials.

I setup an ownCloud instance in my home network to experiment with and ran into all of these issues. One major thing I've learned is that WebDAV is suitable for use to allow people to access their files remotely without having to touch any firewall settings. That was a technical interview question I have been asked in the past.

Now I'm researching why the file transfers seem so slow. KB 2445570 shows one possible solution but not one that works for me.

Sunday, April 14, 2013

MSP430 Morse Code in Energia Part 2

So I wasn't entirely satisfied with my earlier work on this and decided to upgrade it somewhat. All valid letters and numbers are stored in an array now. There's also space and a couple of punctuation. Originally I made the array match up exactly with an ascii table, but there was some sort of a problem with that. Running the program would result in nothing being output, even if I forced it to return the first few locations in the array rather than up in the 50-70 range. It's either a bug in how Energia stores arrays that prevents a larger one or I wasn't doing something right. Once I reduced the array in size enough, it started working. I compensated by subtracting 31 from whatever letter I was trying to return.

Something that may help in understanding that is you can operate on Char values, which are single letters, as if they were numbers and it matches up directly to the ASCII table. Given that, you can put things in the same order in an array and simply match up the values to the letters. Furthermore, you can read a String variable similar to an array where each location returns a Char value of whatever is stored in that location.

In my array, undefined spaces are filled with 65000. This could just as easily been 0, but I did that as a debugging measure as it wouldn't be valid morse code but should be distinctive if it's landed on.

Now it's possible to enter a string in and have the program take care of what to do to send it out.

I'm still not 100% satisfied with this, but thought it would be nice to post my progress for now. I'd like to clean up some various variables that are unused. I'd also like to figure out how to specify how fast to send the code by Words Per Minute. I'd like to see if I could have it produce an audio tone on one of the pins instead of just flashing an LED. Preferably with the option of adjusting what frequency the tone is, 600hz is common. Eventually add the option to program the message, speed, and options like tone or LED by a serial connection to a computer, rather than needing to reprogram it with the Energia IDE every time.

James Hall - N9XLC
Small program to push out my callsign via the red LED on a MSP430 board.
Developed 8/24/2012-8/25/2012
Modified 4/11/2013

Started off modifying, then totally replacing the code in the 'Blink' example project.
This could probably be wrapped up in a function to send out arbitrary sentences.
Only enough morse code is implemented to get my callsign out, but it would be trivial to add the rest.
Could be used to blink out current temp or maybe short status info in morse code in other projects.
 #define output 2 // pin 2 has the red led on a msp430 board, pin 14 is the green led.
unsigned int mask = 1;
int dot = 1;
int dash = 3; //dash is equal to 3 dots
int lspace = 1; //spacing in same letter is 1 dot
int llspace = 3; //spacing between two letters in same word is 3 dots
int wspace = 7; //spacing between two words is 7 dots.

int didot = 2;
int didash = 3;
int spacems = 120; //100ms is a little slower than 20wpm (60ms) so maybe 13-15wpm?
// 10 dot, 11 dash, 00 end
// 01 = space?
// unsigned int is 16 bits
unsigned int aCW[] = {
unsigned int numCW[] = {
unsigned int cwN = 11; //0000 0000 0000 1011 <-read right-to-left
unsigned int cw9 = 767; //0000 0010 1111 1111
unsigned int cwX = 235; //0000 0000 1110 1011
unsigned int cwL = 174; //0000 0000 1010 1110
unsigned int cwC = 187; //0000 0000 1011 1011
String MorseCode = "CQCQCQ DE N9XLC";

byte testbyte;
void setup() {                
  // initialize the digital pin as an output.
  // Pin 14 has an LED connected on most MSP430 boards:
  pinMode(output, OUTPUT);     
  pinMode(14, OUTPUT);
 // pinMode(5, INPUT);

void loop() {
  digitalWrite(14, LOW);
  digitalWrite(output, LOW);
  unsigned int cwout;
  unsigned int mask = 3;
  unsigned int x;
while(true) {
 for(x=0; x<MorseCode.length(); x++){
   //subtract by 31 because of reduced size array
   cwout = aCW[MorseCode[x]-31];
  //cwout = numCW[MorseCode.length()];
    while (cwout) {
     testbyte = cwout & mask;
     //testbyte = 00000010;
       if (testbyte == 1 ) {
          delay(wspace * spacems);
       if (testbyte == 2 ) {
          digitalWrite(output, HIGH);
          delay(dot * spacems);
          digitalWrite(output, LOW);
       if (testbyte == 3 ) {
        digitalWrite(output, HIGH);
        delay(dash * spacems);
        digitalWrite(output, LOW);
       delay(spacems * dot); //inner letter spacing 
     cwout >>= 2; 
 delay (spacems * dash); //outer letter spacing


delay (spacems * wspace); //word spacing

Sunday, March 17, 2013

Google Reader replacement

Google recently announced it is shutting down their Google Reader service on June 1st. I'm a long time user of this service, like many people, and I was a little dismayed to hear this news. I've been using Google Reader probably ever since it first came out in 2005. One thing I really like about it is because it is a web-based service, it is available anywhere you can use the web. So I don't have to keep separate programs on each computer I use and my cellphone.

There is a good alternative to replicate this functionality.. Tiny Tiny RSS. This is a web-based RSS reader that can be installed on your own hosting or other server. I actually set it up on an old computer at my house and it runs just fine. It is a very easy setup too, if you have a little bit of technical skill. It requires Apache, PHP and MySQL.

Very basically the steps can be summed up as:

  • Acquire the files from the website
    • You might notice it's on github. I just did a  git clone  in my home directory on my Ubuntu server which made a local copy of the most recent tree. Then I made a tt-rss subdirectory under /var/www/ and copied the whole thing there.
    • If you download the tar.gz instead, make sure you unpack that. You could probably unpack it directly into /var/www/. 
  • Make a database and database user in MySQL. It will also work with PostgreSQL but since I already had MySQL, I used that instead. There are several ways you can do this. I used a local copy of phpMyAdmin.
  • Once you have the database and database user setup with correct permissions, install the schema.
    • Look under the schema directory for a file named like "ttrss_schema_mysql.sql" if you are using MySQL.
    • Copy the whole file and paste it into a SQL window in phpMyAdmin. Then run it.
    • This will create all of the appropriate tables, views, etc that Tiny Tiny RSS uses.
  • Go back to your shell and make a copy of config.php-dist in the root of the app. Name it config.php and then edit it.
    • It's a good idea to go through each option and at least read them. The most major options that you have to worry about are the ones you need to set for the database server. Make sure you set IP, database, username, and password.
    • I believe you should enable multi-user mode to use the built-in user account options. If not, you may need to setup authentication in Apache.
  • At this point you can try to open it in your web browser.
    • I had to chmod several files so they could be read/written to. You might even need to chown all of the files to your Apache user such as www-data.
    • Default password is admin/password. Everyone knows this so you should change it right away. Especially if you set it up somewhere where it is Internet accessible. Even if not, it would be best to change it anyways.
    • Rather than using the admin account in normal usage, it is even better if you make a user account and save the admin account for administration.
  • Figure out how you want it to update your RSS feeds. See UpdatingFeeds on the wiki
    • The recommended way is to run update.php -daemon or update_daemon2.php from the shell or from a shell script. These will continuously run in the background.
    • Run update.php -feeds in your crontab occasionally to update your feeds.
    • There's a command in the config.php you can set so while you are browsing via the web interface, it will try to update your feeds. If you don't visit for a while using this method you could miss some entries.
    • If you don't run one of these methods, nothing will ever show up in your feeds.

So once you set this up, what then? If you already have an active Google Reader account, it is possible to import all of your existing feeds. Even the categories you have each feed in can come across!

  • Log into your Google Reader account.
  • Click on the gear shaped icon near the upper right and choose Reader settings.
  • Click on the Import/Export button.
  • Click on Download your data through Takeout
  • Click on CREATE ARCHIVE button.
    • This can take several minutes to run.
    • Once it is done, click on the Download button to download it.
    • The file I downloaded was around 10MB, yours might vary. More than just subscriptions, it also contains all the items you shared, starred, liked, and more in JSON format. That stuff isn't really useful right now unless you can make a program to do something with it.
    • subscriptions.xml is the important file.
  • Log into your Tiny Tiny RSS site in your browser at this point.
  • In the very top right there's a menu named "Actions...", click that.
  • Then click Preferences.
  • Click on the Feeds tab.
  • Look for a bar that says "OPML" and click on it to expand it.
  • Click on "Choose File" and pick your subscriptions.xml
  • Finally click on "Import my OPML"
It should import all of your existing feeds and already have them in all of your original categories.

Now there is a good Android app made by the original author of Tiny Tiny RSS with a 7 day limitation. Despite it being open source, he would like you to pay $2 to unlock it for unlimited use. This application requires access to an instance of Tiny Tiny RSS such as one you just setup or a public one to operate. Someone else has forked the source as TTRSS-Reader which is similar but has a few nicer features and isn't limited to a 7 day trial like the other one. I recommend it.

To use either one, make sure you enable the external API in the options of your instance. Look in Preferences again for that.

Saturday, March 2, 2013

PHP work and APIs

I've been learning PHP for a while. I think I have a long way to go but I have completed a few projects in PHP and have a fair amount more that I'm working on. My most recent portfolio website is written in PHP. It queries a MySQL database for the contents of a page and then it dynamically builds the page. That includes dynamically building the navigation links on the said, breadcrumbs and so on. The PDFs that I host also are shown on their own generated page. It's really neat.

Something else I've been working on recently is a utility for the local Amateur Radio club I belong to. It's a membership roster that can be managed online. Each member is stored in a database and I will have a page to edit details and another page to add a new member. I haven't completed the edit page just yet. It loads the member's details and even generates a form with the correct input elements for the data type. Checkbox for bool, textbox for varchar, date (HTML5) for date. The date picker in HTML5 is really neat. I have it show the ID field but greyed out because that is not user generated. I'll have to add some sort of authentication to this before I turn it loose. I also want to add some tracking for who the officers are, and maybe even some tracking of who is in what committee because they do those too. Another thing that I will add is the ability to download a PDF copy from the roster page and also to send out some sort of version to the email list, like what normally happens. It'd be great if I could integrate this into Drupal, at least for authentication, but I don't know that is going to happen. I did write a PHP script that can be used to look up someone's information by their callsign. Originally this information came from the FCC but I am using the API and querying their database for it.

Something else club related that I would love to write is a callsign logging program for the club to use on field day. Especially if I can put it on a Raspberry Pi with a WiFi router in a box, then each station could have a laptop connected over wifi that would show the page and let each individual station make entries. Field day also is a competition so you get points for so many contacts in various situations. That could be handled by the computer and it could give real-time results. Maybe with a 1200-baud packet radio link those results could be sent somewhere with an Internet connection and shown live on the club's website, or posted to Facebook.

For work I wrote a PHP script to be run at the command line in Windows and using TCPDF it would scan through a list of patients in the EMR software we support and print out 1 PDF per patient with all of the internal emails related to that patient. It looked really nice. I'm excited for the customer to see the result because I think they are going to be pleased.

I have a few more personal projects that I'd like to work on. One is a tracking program someone can use to keep track of their headaches and maybe more usefully.. taking medications. I'm 10% done with that. Another one is a gas log for my car and my wife's car. Yet another one is for groceries. All of these I'm working on something that shows up fine on a cellphone browser. My wife could be at the store and looking at the list on her phone. There are utilities that should integrate letting me do barcode scanning with the camera. Eventually, a couple years down the road probably, I will have something that can suggest sales and help us save money by buying at certain times.

Another idea I had the other day is I would like to write a PHP class that can take a string input consisting of the contents of a Tiddlywiki file. Then using the class methods I can easily extract information from the Tiddlywiki. Once that is done, I may inject that information into a MySQL database. I just have to figure out how to use the DOM methods in PHP to look for the div containers that Tiddlywiki uses and then pull various information from it including the contents.

There are a couple of APIs I need to learn for work:
Google Analytics
I'll be using these to build a nice application for someone with a lot of reporting and control.
I hope what I learn can be applied to other places. I'd love to write something that uses the API to help me keep track of wish-lists and maybe even make purchases. (Maybe not, if I have something stuck in a loop that orders 1000 copies of a CD I want, that wouldn't work out well for me)
I'd also like to connect to Facebook and Twitter over their APIs.