Saturday, May 28, 2016

Dark Fiber as a model to bring competition back to high-speed Internet and other services.

I'm really excited about this idea. Remember the 90's when competition was fierce with dial-up ISPs? There was a huge factor that helped make that possible and it was commonly available lines to run the services over. Everyone had telephone lines and you could change your ISP simply by getting a new account and calling a different number. Each ISP didn't have to run an entirely new network to provide service to a population. They ordered a number of lines with telephone numbers, hooked up some modems and got a high-speed connection to the Internet and they were in business.

Dark fiber is so named because Fiber Optic cable carries data as light over its length. When it is "dark", that means there's no equipment hooked up to that line. If an area runs dark fiber to all of its homes and businesses, then they can in turn lease those lines to various companies who want to provide services over them. We can again have a ton of competition in Internet service without requiring each provider to run their own lines. Right now competition is very limited due to that simple fact. Here in Richmond Indiana choices are limited. Comcast provides cable modem service over their lines. Frontier and Parallax provides DSL service over telephone lines. Parallax has a limited roll-out of Fiber Optic as well. Then there's Bridgemax over a wifi-like wireless connection.

Internet service is not the only service that could run over Fiber Optic. TV providers and phone could also be run.

Why provide for competition instead of restricting it to a single provider? Not everyone will want the service from a single provider. That would slow down how fast a network could grow. It's not economical to roll it out to every house if only a few wants it. If the same network could be used for people who want service from Company A and people who want service from Company B then it can economically grow. Not to mention, with the added competition prices will go down while at the same time companies will also have to work on their customer service! It also opens the door for smaller companies to offer a service that would be simply impossible to offer if they have to build out their own infrastructure. The exceedingly high cost of building out infrastructure severely limits the possible competition.

Think of roads. Do we have Ford roads that only Fords are allowed to drive on? Do we have Chevrolet roads that only Chevys are allowed to drive on? No! So why not have a common infrastructure for all of our data services, such as Internet, Phone and TV?

Please note that I'm talking about Dark Fiber here. The service providers can bring their own equipment. If newer equipment comes out that is faster, then they can hook that up to the lines. Much like in the modem days when we went from 2400 baud to 56.6k. If Google offers service with 1Gbps equipment and newer equipment comes out that's faster, then they should be able to hook that up.

I've read an article recently about Google working with Huntsville Alabama to put this sort of idea into practice. It's not even the first place it's been tried and I'm very excited to see what happens. If Comcast & AT&T don't kill it off in court anyways. You can read the article here: You Didn’t Notice It, But Google Fiber Just Began the Golden Age of High Speed Internet Access

Tuesday, March 22, 2016

Solar Panels grown on the Moon could power the Earth.


This is a neat idea but I object to the premise. The article states:
"To power entire world with solar power, we would need to cover an area that's 92 percent the size of Nevada in solar panels, and that's not even counting the batteries," says Lewis-Weber. "To me, that's just not feasible."
To power the entire world, we'd only need to cover an area 92% the size of Nevada. Not we'd need to cover Nevada, just an area of that size. There's no need to have a single continuous array to power everyone. There'd be tons of transmission losses that way anyways. Not that the article above mentions what the losses would be using microwaves to transmit energy from the Moon. Given the inverse-square law, I'd have to imagine the losses would be pretty great. It'd be better to have solar arrays directly above where they are needed. I have no idea, currently, how much area is available for rooftop solar. If every home and business had rooftop solar, it's entirely possible we'd have most of the energy we'd need. Of course it depends on many factors such as what latitude you live at and quality of panels used. If the grid was entirely distributed then areas with an excess of sunlight can power areas that are cloudy. Or even include wind which will also provide power in the absence of sun.

Not that the article is entirely without merit. If someone can come up with a way to build an entirely automated factory that can be sent to foreign bodies to mine and build stuff with local resources.. that would change a lot of things. It'd also make it possible to have such machinery build bases and other resources on the Moon, Mars or even on an asteroid. Rather than spend billions of dollars to send equipment, we can cut the costs of space exploration without making it more dangerous.

The article doesn't mention how that would be accomplished. Just the idea of sending equipment that would replicate itself. Really more like Science Fiction than fact at this point.


Saturday, February 13, 2016

Some Javascript based PC and old computer emulators:


PCE http://www.hampa.ch/pce/about.html
PCEjs https://jamesfriend.com.au/pce-js/ The above ported to Javascript by using Emscripten
  • Atari ST
  • IBM PC 5150/5160
  • Mac Plus - Emulates Macintosh 128K, 512K, 512Ke, Mac Plus, Mac SE or Mac Classic
  • rc759 Regnecentralen RC759 Piccoline, which I guess was a computer made in/for Denmark specifically
PCjs http://www.pcjs.org/
This one is specifically an IBM PC 5150 emulator. Has several disk images, mainly DOS but there's a Windows 1.0 too.

jslinux http://bellard.org/jslinux/
This one is an x86 emulator written in Javascript that loads up a very simple Linux system when you visit the page. It seems pretty responsive. The guy that wrote it said it should be about the level of a 486 but without a floating point unit. No network support.

v86 http://copy.sh/v86/
This is another x86 emulator written in Javascript. This one has several disk images of Linux, DOS and even Windows 1.01.

Em-DOSBox https://github.com/dreamlayers/em-dosbox
DOSBox is a x86 emulator that comes with it's own DOS like environment. The development has been mainly focused on getting games running, but it can also run other applications. It's possible to run Windows 3.1 and even Windows 95 on it. However, Windows 95 isn't super stable. Em-DOSBox is a port of DOSBox to Javascript using Emscripten. Emscripten can compile C/C++ code to Javascript.

Internet Archive DOS and Windows games
DOS https://archive.org/details/softwarelibrary_msdos_games
Windows https://archive.org/details/softwarelibrary_win3
Windows 3.11 in your browser https://archive.org/details/win3_stock
Here's the thing that blows my mind. I ran Windows 3.1 on a 486sx 20Mhz in the early 90s, so about 23-24 years ago. Now it's in my browser and it's not even slow.
This Em-DOSBox generally has a better interface than the other x86 emulators above.

Windows 95 in your browser https://win95.ajf.me/
I'm not sure about the legality of this one. From all accounts it is buggy and tends to hang. I'm sure the Internet Archive version of Windows 3.11 above is legal. For one thing, they don't let you download it. All you can do is stream it from their website.

It's conceivable that someone could make an adventure game set in the 90s with fully working emulated computers from the era, given that all of this stuff works in the average browser these days. Even better if they can simulate a modem and let you dial up to a virtual BBS. It'd be great if Microsoft came out and said that MSDOS and old versions of Windows, such as 3.1 and 95, would be freely available for this sort of thing. After all, "It's a new Microsoft."

Friday, January 8, 2016

Javascript support

This is a neat Github repository that is a page discussing all of the new features in ES6, also known as ECMAScript 2015. Basically all of the new features in Javascript.
https://github.com/lukehoban/es6features

Here is a Github.io page that shows a support matrix of which browsers, servers and compilers support which ECMAScript features. It shows ES5, ES6, ES7 and non-standard. It even shows what the currently used browser supports.
http://kangax.github.io/compat-table/non-standard/

Wednesday, October 14, 2015

500GB SSD drive for only $134.99

Holy cow prices on SSDs are dropping like a rock this year!
I just found this deal on Slickdeals on a 500GB Crucial BX100 SSD. It's only $134.99 with free shipping. If you look on camelcamelcamel, this drive was $200 back in January.

It was only about 4 months ago I picked up a 180GB Intel drive for my laptop for around $80.. but you regularly see 256GB drives for under that now. I wonder what kind of deals will show up for Black Friday this year? Maybe by next spring we will see 1TB drives for under $200?

Exciting times for sure.

Tuesday, January 6, 2015

GULEEK i8 Windows 8.1 mini pc


This is probably the neatest thing I've seen in a while. This is a full computer with a quad-core Intel Atom processor, 2GB RAM and a 16GB SSD. The power connection is a MicroUSB port. It has HDMI, audio out, 2 USB 2.0 ports, built in wifi and a port to add a MicroSD card. All of this for $104 from dx.com. [Link]
From what I've read, the version of Windows 8.1 it runs is a special Bing version that is either free or really cheap for the manufacturer. It is from China so it's nice that it's not a pirated version at least. The word on Linux compatibility is that it isn't, so far.
This device has a 3,000mah battery integrated as well so it can run for a time without being plugged in. I'm not sure what the run time is at this point. The dx page shows it being run headless with an Android tablet controlling it. I'd assume you can do the same thing with IOS and Windows tablets using a remote desktop application.
This liliputing.com article about this device mentions a Vensmile iPC002 system that is very similar but with a larger capacity battery and double the built in storage. This is typical for Chinese products to have a lot of nearly identical looking products from different companies that may or may not have different specifications.
It'd be pretty nice if one of these companies brought out one with the ability to upgrade with a M-SATA or similar SSD card.
I could think of a number of uses for a device like this:

  • Low power NAS device with external hard drives.
  • Thin-client replacement.
  • Kid's first computer.
  • Backup system, in case your main one breaks.
  • Wearable computer, possibly useful with the Oculus Rift headset.
  • Robotics.
  • 3D printer computer.
Intel Atom processors aren't known for their processing performance. This is still limited compared to even a Celeron, but in many cases it might have enough horsepower to do a necessary task.

Friday, May 30, 2014

Update Grub 2 options

As a follow up to my previous post Ubuntu Server 14.04 fun I was asked how to update the Grub2 file. It's really very easy. Use a text editor to open /etc/default/grub like so:
sudo nano /etc/default/grub
Then find the line that says GRUB_CMDLINE_LINUX_DEFAULT="" and add nomodeset inside the quotation marks.
If you do use nano then you can press Ctrl-o and Ctrl-x at this point to write and exit.
Then run this command:
sudo update-grub
and that should do it.

Thursday, May 29, 2014

Make Raspberry Pi (and other SBCs) report it's IP address when it starts up.

You can also track power on events and other information in this way. First, create a script, let's call it reportip.sh:

#!/bin/bash
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  result = ""
  printf -v result "192.168.1.2/rpi.php?id=pi-R&ip=%s" "$_IP"
  echo "$result"
  curl -u username:password $result
fi


What's going on here?
First it gets the IP address and assigns it to a variable $_IP.
It displays a message so if you do happen to have a display plugged in then you'll see what the IP address is without logging in.
It builds a $result variable that is a url. In this case I have a fictional web server at 192.168.1.2, a PHP script called rpi.php runs on it that can take some values and log them to a database. This is a very simple script that is setup to log to a SQLite database but could easily be rewritten to point to MySQL or your favorite database.
It then uses curl to call upon that url in order to set things in motion. I'm using the -u switch to specify a simple digest username and password.

Then you can put this into your /etc/rc.local
This is wildly insecure if you leave it in a user's home directory since whatever is in the script will be executed with root privileges on startup so don't do that in your day job. You can run it with sudo -u username /home/user/reportip.sh to run it with lesser privileges or put it elsewhere.
Once this is setup then every time your pi starts, it will get an IP and then hit your server to report what IP it got. Then you can go to that page and see what it is.

I actually need to rewrite that PHP script, it was lost in a hard drive crash earlier this year. Look for it soon, I will put it up on my GitHub account.

Thursday, April 24, 2014

Ubuntu server 14.04 fun

Recently lost a system drive in the AMD E350 based computer I use for various file server, database, test web server and other roles in my home network. The new drive came in the mail today so I decided to try to install the new Ubuntu server to it. I used the built-in LVM support that exists in the CLI installer now. Last time I had to do that by hand so it was a nice improvement.

Long story short, on boot up I was encountering an apparent hang or freeze once it was trying to initialize the swap space.
[    3.490158] firewire_core 0000:06:02.0: created device fw0: GUID 001e8c000042dc3f, S400
[    3.616414] random: lvm urandom read with 30 bits of entropy available
[    3.671945] bio: create slab <bio-1> at 1
[    3.843667] EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)
[    4.026158] Switched to clocksource tsc
[    4.460003] init: plymouth-upstart-bridge main process (183) terminated with status 1
[    4.462054] init: plymouth-upstart-bridge main process ended, respawning
[    4.470931] init: plymouth-upstart-bridge main process (194) terminated with status 1
[    4.472846] init: plymouth-upstart-bridge main process ended, respawning
[    4.482749] init: plymouth-upstart-bridge main process (196) terminated with status 1
[    4.484555] init: plymouth-upstart-bridge main process ended, respawning
[    4.493858] init: plymouth-upstart-bridge main process (198) terminated with status 1
[    4.495605] init: plymouth-upstart-bridge main process ended, respawning
[    4.503723] init: plymouth-upstart-bridge main process (200) terminated with status 1
[    4.505317] init: plymouth-upstart-bridge main process ended, respawning
[    4.516120] init: plymouth-upstart-bridge main process (201) terminated with status 1
[    4.517821] init: plymouth-upstart-bridge main process ended, respawning
[    4.552321] init: plymouth-upstart-bridge main process (203) terminated with status 1
[    4.553990] init: plymouth-upstart-bridge main process ended, respawning
[    5.143395] random: nonblocking pool is initialized
[    5.480640] Adding 7970812k swap on /dev/mapper/ubuntu--vg-swap_1.  Priority:-1 extents:1 across:7970812k FS

The most frustrating part of this is that the only reference I found to someone having the same problem online wasn't any help at all.

Then I discovered that in the recovery console I was able to see an IP and it was on my network just fine. So on the next reboot I tried connecting to it over SSH after it "froze" on me. I was able to connect and login and even use it as if nothing was wrong! The dmesg log shows the boot process continuing on from the above point as well.

Some research later and I found that if you add nomodeset to the kernel settings before it boots then it will continue on to the login prompt normally. I'm sure, now, that when it appears to freeze that's when it is actually switching to a video mode that is not working correctly on my hardware. This is probably not a very common problem which is why I don't see many other people talking about it online.

tl;dr? If you're having problems with Ubuntu appearing to freeze during the boot process.. try booting with nomodeset in your kernel options!

There's a nice description of what nomodeset does here: link

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

Minesweepers
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]
"AllowNetworkLocations"=dword:00000001

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location0]
"Path"="N:\\database\\"
"AllowSubfolders"=dword:00000001
"Description"=""

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]
"VBAWarnings"=dword:00000001

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations]
"AllowNetworkLocations"=dword:00000001

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location0]
"Path"="N:\\database\\"
"AllowSubfolders"=dword:00000001
"Description"=""
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!

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.