Wednesday, June 26, 2013

Citrix XenServer 6.2 Open Source!

http://blogs.citrix.com/2013/06/25/xenserver-6-2-is-now-fully-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
http://www.citrix.com/content/dam/citrix/en_us/documents/products-solutions/citrix-xenserver-core-feature-matrix.pdf

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

WebDAV

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.

 http://www.arduino.cc/en/Tutorial/BitMask
 http://wiring.org.co/reference/bitwiseAND.html
 http://wiring.org.co/reference/bitwisebitshiftleft.html
 */
 #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[] = {
65000,1,65000,65000,65000,65000,65000,65000,65000,65000,
65000,65000,65000,65000,65000,65000,65000,1023,1022,1018,
1002,938,682,683,687,703,767,65000,65000,65000,
65000,65000,2810,3006,14,171,187,43,2,186,
47,170,10,254,59,174,15,11,63,190,
239,46,42,3,58,234,62,235,251,175,
};
unsigned int numCW[] = {
 1023,1022,1018,1002,938,682,683,687,703,767
};
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(GREEN_LED, 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 https://github.com/gothfox/Tiny-Tiny-RSS/archive/1.7.4.tar.gz
    • You might notice it's on github. I just did a  git clone https://github.com/gothfox/Tiny-Tiny-RSS  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 73s.com 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
MailChimp
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 Amazon.com 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.

Friday, November 16, 2012

OpenOffice / LibreOffice Base timestamp quickie

The built-in database for these is hsqldb.

To setup an automatic timestamp when you enter data.. it cannot be done from the table design view. It must be done from within the "Execute SQL Statement" window. Go to Tools, SQL to get there. Then enter this command:
ALTER TABLE "TableName" ALTER COLUMN "ColumnName" SET DEFAULT CURRENT_TIMESTAMP

Replace "TableName" with the name of your table and "ColumnName" with the name of your column. The type of your column should be Date/Time [ TIMESTAMP ].

I find that the case of the SQL commands isn't really that important but it is very particular that you have the correct case for your table name and column name. If you have a table named Contacts, then you must enter "Contacts". It will give you an error if you enter "contacts" instead.

This will cause that column, or field, to be filled with the time & date that the row was inserted to the table. It's possible to set it to insert the time & date on an update as well but I don't need to use that as of yet.

Wednesday, September 26, 2012

Toolbox: Notepad++

Notepad++ is a program I've used a lot lately, both at home on personal projects as well as in professional work. Major features include tabs for all of your files that persist between sessions, a session manager that saves your tabs so you can switch between projects easily, syntax highlighting for quite a large number of languages, a macro system, an extensive plugin capability and much more.

I have two plugins that I use constantly. One is the compare plugin which will compare two files and show you differences between them. It can also compare a file to the last saved version of itself. This is very handy for seeing what changes have been made and can be used to normalize multiple revisions of a file.

The other plugin that I've started using fairly recently is the NppFTP plugin. It allows you to connect to sites that use ftp, ftpes, ftps, or sftp and read/save text files directly from within Notepad++. I've used this in my recent website work to edit the files directly on the webserver and then preview in my browser without having to do anything about copying files back and forth. One of the nice things is that with a very minimal configuration I can work remotely on my netbook just as well as on my main desktop. I currently have it configured to use sftp via ssh on my website development box which is an old Dell desktop running Ubuntu Server 10.04.

If you were to setup your router to let you access ssh and www externally then it would be possible to develop on the road.

The downside of NppFTP is that it is only good for editing files with Notepad++, you can't actually use it to transfer files like PDF, WAV, etc with it. At least, unless you use uuencode and somehow uudecode it on the remote end. I use coreftp to transfer files but you could use Filezilla or another client that supports the method you want to use such as sftp.

Tuesday, September 25, 2012

portfolio website Part 2

Portfolio project is going very well. I'm highly expecting to be able to launch it before the end of next week and perhaps as early as this week. Most of the content is entered into the database and I'm putting some finishing touches on the PHP code for some features I'd like to have. Some of my information is in PDF files which are as of now displayed in an iframe. There's a link above it for devices and systems that can't support showing PDF files like that. I also have a little PDF icon setup next to the link so you can see what the file type is before downloading it.

Created a simple breadcrumb functionality as well using a session variable.

Sunday, September 9, 2012

portfolio website

I'm currently working on a rewrite of my portfolio website. Started working on it Friday, September 7 and worked through the weekend. Originally, the website was written in pure HTML with CSS for styling and a little bit of Javascript. The Javascript isn't really an integral part of the website, I had a couple of samples of code running. I ought to add to that, since I've done more since then. The new website I am working in is written in PHP backed by a MySQL database. I'm excited to deploy it and I'm expecting I will before the end of the month.

My current site uses frames to separate the header and links from the content, my new one will not use frames at all. Links will be generated from a database table and the header is built into the php file I'm writing. Content from all of my pages will be transposed to the database and then the PHP file will read it and generate the page live. I know I could do this with a CMS like Drupal or Joomla, but I do like to learn new things.

The generated pages, and link to the content was very easy to do. I'm currently working on the code to pull link data from the database and generate a list of links. I've run into a couple of roadblocks and may actually redesign my table, but what I've done so far is fairly neat if I can say so.

I hope to put this knowledge to work on a couple of private projects in the future. One of the major ones I'm thinking about is a medication tracking system that I can operate from my phone's browser. Probably to track headaches. (Actual headaches, not IT headaches... I don't get those) I expect that I will learn a bit about how to write a mobile capable site and how to use forms in PHP. The other idea I had was a gas tracking system for my car. Of course, both of these will probably be behind a login screen on a private server.

Wednesday, August 29, 2012

MSP430 Morse Code in Energia

I'm cross-posting this from my Ham Radio blog: n9xlc.blogspot.com It may be of interest to anyone viewing this, my professional blog.


 Just a small project I worked on this past weekend 8/24-8/25. I have several of these cheap MSP430 Launchpad dev kits from TI. What a deal they are too, $4.30 each. I intended on configuring it to further my Kenwood TM241a project, but got sidetracked and made a program to send my callsign in Morse Code. I ended up using Energia, which is a port of the Arduino IDE but this one makes MSP430 programs. It seems most of the same commands are supported, but not all.

I really need to get setup to program in C or even try my hand at ASM. I tried ASM on the PIC microcontrollers a couple of years ago but gave up on it fairly quick. Maybe I'd do better now? I'm not sure the Wiring language would produce code fast enough to bit bang 1200 baud serial with a clock.

Code for my project is below. It would be fairly easy to modify this to make a beacon, or foxhunting cpu, or even an ID for a repeater or standalone rig. If you do something with it, I'd appreciate a link back to my radio blog, n9xlc.blogspot.com and maybe drop me a line to let me know. I'd probably write an entry about it and link to your site.

It's not technically hard to add other characters and I think it's fairly self-explanatory. I'm not 100% happy with using the IF statements to cycle through the letters. I'd be happier with an array and a For loop with an index number but this works. I tried to set up a constant type like an UIntTable to store the characters, but I only received error messages when I tried to use that. It may not be fully supported in Energia yet, or probably I didn't fully understand it.

I know I'm not the first person to do this by a long shot, but it was a fun challenge and it did help me familiarize myself somewhat in Energia, maybe next time I'll rewrite this in C? I see there are videos of others who have written Morse Code projects for the MSP430 on Youtube with a little more pizzazz than mine, such as audio out and a serial terminal for input.
/*
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

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.

 http://www.arduino.cc/en/Tutorial/BitMask
 http://wiring.org.co/reference/bitwiseAND.html
 http://wiring.org.co/reference/bitwisebitshiftleft.html
 */
 #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 = 100; //100ms is a little slower than 20wpm (60ms) so maybe 13-15wpm?
// 10 dot, 11 dash, 00 end
// unsigned int is 16 bits
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
byte testbyte;
  
void setup() {                
  // initialize the digital pin as an output.
  // Pin 14 has an LED connected on most Arduino 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;
  int callsign = 1;
  
while(callsign) {
 if (callsign == 1) {cwout = cwN;}
 if (callsign == 2) {cwout = cw9;}
 if (callsign == 3) {cwout = cwX;}
 if (callsign == 4) {cwout = cwL;}
 if (callsign == 5) {cwout = cwC; callsign = 0;}
 callsign++;

    while (cwout) {
     testbyte = cwout & mask;
       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
}