Get current remote connections with LiveCode on MS Windows XP/Vista/7

This is a script to check the remote desktop connections to your computer. Syntax:

rdConnection([false]|true|”User”)

where User is the name of a user with an account on that particular computer (or server).

Paremeters:
false: returns true if connections have been established, false of not
true: returns the names of the currently logged in users
user (in quotes): returns true if that particular user is logged in, false otherwise

function rdConnection theName
   if the platform is not “Win32” then return empty
   set the hideConsoleWindows to true
   put shell(“qwinsta”) into myConnections
   filter myConnections with “*Active*”
   if theName is empty or theName is false then
      repeat for each line myLine in myConnections
         if word 4 of myLine is “Active” then
            put myLine & cr after myNewList
         end if
      end repeat
      delete last char of myNewList
      return (myNewList is not empty)
   else if theName is true then
      repeat for each line myLine in myConnections
         if word 4 of myLine is “Active” then
            put word 2 of myLine & cr after myNewList
         end if
      end repeat
      return myNewList
   else // theName is not empty
      if word 2 of myLine is theName then
         put myLine & cr after myNewList
      end if
      delete last char of myNewList
      return (myNewList is empty)
   end if
end rdConnection

Installer Maker Plugin 1.5.1 for LiveCode has been released – Happy New Year!

Hello! Happy New Year to all of you! I wish you all success in business and carreer and happiness in your family!

Economy-x-Talk has released a new version of the Installer Maker Plugin. This update fixes a problem that prevented Linux users from registering and several other smaller problems. More info can be found at http://rrinstallermaker.economy-x-talk.com/ .

Screen_shot_2010-12-13_at_16

This update is free for everyone who bought a (new) license during the past 3 months. Upgrades are available at half the original price.

Make PHP and MySQL communicate on Mac OS X 10.6 Snow Leopard

I write this blog post because every few months I need make PHP and MySQL work on Mac OS X and every time I have to figure it all out again. Time to write it down…

The following instructions consider Mac OS X 10.5 and 10.6 (Leopard and Snow Leopard).

Almost always people start shouting “MAMP!” as soon as people have problems with PHP and MySQL on Mac OS X. It is nonsense to install MAMP on a Mac because almost everything is already installed on your Mac. Why would you install all necessary server software twice? It just takes away hard disk space. You really don’t need to use MAMP. All you need is to figure out how to configure PHP and MySQL.

Obviously, before PHP can work with MySQL, you need to install MySQL. You can download MySQL for Mac OS X here http://www.mysql.com/downloads/mysql/ . Install MySQL and don’t forget to install the preferences panel that comes with it.

Now you can activate PHP. Type command-shift-G in the Finder and type /etc/apache2/ in the little window that appears. Click on Go en find the file httpd.conf in that folder. Copy this file to the desktop and create a backup copy named httpd.conf.old.

Open the file httpd.conf in TextEdit and search for the line containing

#LoadModule php5_module libexec/httpd/libphp5.so

Remove the # and save the file. Copy the modified file to /etc/apache2/ en cofirm if you are asked whether you want to replace the existing file.

When PHP tried to communicate with MySQL, it uses a socket file to contact MySQL. PHP expects o find this file in /tmp/mysql.sock while MySQL puts the file into /var/mysql/mysql.sock. It has been like this for year and I really don’t understand why the two parties involved don’t solve this.

The “temporary”solution is to tell either PHP or MySQL to create or search the socket file somewhere else. The easiest way (in my personal opinion) is the following.

1) open TextEdit and type the following four lines:

[mysqld]
socket=/var/mysql/mysql.sock
[client]
socket=/var/mysql/mysql.sock

2) Save this text file at the location: /etc/my.cnf

You may be unable to save the file in /etc right-away. In this case, you can save the file on your desktop first. Type command-shift-G (in the Finder) and type /etc in the little window that appears. If you click on Go, you will see a Finder window displaying the content of folder /etc. Now you can copy the file my.cnf to the folder /etc. You may need to enter your admin name and password when you copy the file.

Now you need to turn off and on Web Sharing in the System Preferences. You may need to turn off and on MySQL too, which you can do in the MySQL preferences panel.

PHP should now be able to use MySQL.

An AppleScript alternative for the HyperCard flash command

Remember the HyperCard flash feature? It would invert your screen for a split second and then return to normal. Here’s how to do exactly the same with AppleScript.

tell application “System Events”
    tell application processes
        repeat 2 times
            key code 28 using {command down, option down, control down}
            delay 0.2
        end repeat
    end tell
end tell

Store the script in a custom property of your LiveCode stack, for example cInvertScript. Then run the script as follows:

do (the cInvertScript of this stack) as AppleScript

Isn’t that cool?!

Installer Maker Plugin 1.5 for LiveCode is now available!

Economy-x-Talk is pleased to announce a big update of the now well-known Installer Maker Plugin for LiveCode.
The Installer Maker Plugin is the easiest way to wrap your LiveCode standalones in an installer. Just create your standalones and drag them into the Installer Maker Plugin window. Without being complicated, the Installer Maker Plugin offers you sufficient options to install your software on almost every Windows PC or Mac.

The new update contains more than a dozen bug fixes and new features. Most of the implemented new features were requested by our customers. Some important changes are: deletion of pictures from the Appearance section is now possible, more and improved language options, parenthesis are now allowed in file paths, more built-in checks and fail-safes to avoid mistakes.

Screen_shot_2010-12-13_at_16

With this new release, we are adjusting our licensing policy to make continuation of this project possible. We provide everyone who buys a (new or upgrade) license with free updates for three months. Currently, everyone can buy an upgrade, regardless of when you bought your license. Soon, you will be eligible for the upgrade price only if you bought your original license less than 1 year ago.

If you bought your license more than a year ago, you might want to buy an upgrade right now, while you can still pay the upgrade price. Upgrades cost EUR 16.95, new licenses cost EUR 39.00. (You can see when your license was created by hovering your mouse over the version number in the bottom-left of the Installer Maker window. The license creation date will appear in the tooltip.)

The new version of the plugin and forms to buy a new license or an upgrade can be found at http://rrinstallermaker.economy-x-talk.com . If you have any questions, please go to http://qurl.tk/du and fill out the web form.

MySQL Licenses: The Do’s and Don’ts of Open Source, or What’s All the Fuss About?

MySQL Licenses
The Do’s and Don’ts of Open Source, or What’s All the Fuss About?

copyright ©2010 by
Mark Schonewille and Economy-x-Talk
Nijmegen, the Netherlands
this version: 1.3 (26 Nov. 2010)

1 Introduction

In reply to a question on the LiveCode User Mailing List, I argue that MySQL is one of the best freely available (open-source) databases. A number of subscribers to that mailing list reacted quite strongly, saying that open-source doesn’t mean free. Apparently, they use the word “free” as in “free beer”, while I use it as in “free speech”. They argue that one needs to pay Oracle Corporation a lot of money if one uses MySQL, despite the fact that MySQL is open-source and freely available.

This was enough reason for me to call Oracle Corporation. After 30 minutes of searching for the right person, I was connected to a friendly Oracle Corporation employee. I asked this employee three questions: 1) do I have to pay Oracle Corporation if I use MySQL at home, 2) do I have to pay Oracle Corporation if I make commercial software that works with MySQl and 3) do my customers have to pay Oracle Corporation if they use MySQL in combination with my commercial software? His answer was a resounding and clear threefold “No!”

One doesn’t need to pay Oracle Corporation. It should be clear, though, that MySQL’s license, specifically the GNU General Public License (GPL for short) requires it to stay open-source. The GPL poses a few limitations on the use and distribution of MySQL, but creates opportunities at the same time.
In the text below, I explain the implications of the GPL for users of MySQL. In doing so, I will discuss a number of typical examples.

2 Unpaid Without Redistribution

You can freely download the MySQL software from the website . You can install it on your laptop for your own personal use, to test your website with a MySQL server. You can upload those websites to a web hosting server. You don’t need to pay Oracle Corporation anything in this situation.

A web hosting company can offer the MySQL database engine as an extra service on their servers. They can freely download the MySQL database engine from the MySQL website and they don’t need to pay for it. The customers of the web hosting company also don’t need to pay for using MySQL with their websites.

As another example, a printing company wants to manage a large customer database and has MySQL installed on an internal (local) server after downloading it from the MySQL website. The printing company is allowed to use the MySQL database for free without paying Oracle. The same company can ask me to make software for them, which will talk to their MySQL database. That company still doesn’t need to pay Oracle Corporation and I myself don’t need to pay either.

In a third example, I make commercial software, which needs to have MySQL installed. My customers can use my commercial software, for which they do need to buy a license, in combination with the MySQL database engine, for which they don’t need to pay. Because the MySQL engine is not embedded in my commercial software and I don’t redistribute MySQL together with my software, I don’t need a commercial license for MySQL and neither do my customers.

The next situation is a little tricky. I make commercial software and need a special version of MySQL to make it work. I adjust the MySQL engine and distribute it as open source software. I offer the source code for free to everyone who uses my adjusted MySQL database engine. I simultaneously distribute my commercial software accompanied by a note that it needs the adjusted version of MySQL. I make sure that the original GPL applies to my customised version of MySQL. I tell my customers to install my version of MySQL on their servers and to install my software on their client machines. I don’t need to pay Oracle Corporation because I distribute the adjusted version of MySQL under the GPL and it is not embedded in my commercial product.

This is about as far as you can stretch the GPL. In the situations described in the above, I don’t act as an OEM (Original Equipment Manufacturer), an ISV (Independent Software Vendor) or a VAR (Value Added Reseller) and I, my customers and my (internet) service provider can use MySQL without paying Oracle. (Note that redistributors are not limited to OEM’s, VAR’s and ISV’s only).

3 Redistributing the MySQL Software

The next step would be to adjust the MySQL engine in such a way that it can work with my commercial software product without distributing the code for the adjusted engine. This causes a dependency between the MySQL software and my commercial product and violates the GPL directly. The GPL can no longer apply and I will need to buy a commercial license from Oracle Corporation in this case.

I could download the MySQL engine and embed it into my product, e.g., by letting my installer install MySQL automatically together with my own product. I don’t want to disclose the source code of my entire product. Because I am selling my commercial software product together with the embedded MySQL engine, I have become an ISV and I need to buy a special commercial license to do so.

It should be obvious that I also need to buy a commercial license, if I want to use the MySQL source code libraries, rather than compiled binaries, in the source code of a commercial product without revealing the source code. Selling this commercial product violates the GPL and requires that I pay Oracle for a license.

However… as long as I have no desire to sell the embedded MySQL source code commercially, I can let the GPL license apply. For example, if the aforementioned printing firm asks me to create an in-house tool to manage their database, they might require that the tool includes the MySQL server (either by embedding the source code into mine or by combining the binary with the final product). If I make the tool, include MySQL in it and license it to the customer under the GPL, my customer has no obligation to reveal the source code to anyone, as long as he doesn’t redistribute my work. The customer still doesn’t need to pay Oracle Corporation for a MySQL license, nor do I.

However (again)… I have to offer my customer the source code as required by the GPL. If the customer doesn’t want the source code, I don’t need to give it to him. If the customer wants to redistribute the product, he needs to ask me for the source code, because he has to make the same offer to those who receive the redistributed software from my customer as I had to.

The interesting point here is that my customer still can (or rather has to) pay me for my services. I made the software for him and he already agreed to pay me for my efforts. When he redistributes the software under the GPL, he can offer his own customers a similar service.

4 Then What’s All the Fuss About?

It is quite obvious that Oracle Corporation doesn’t write on the MySQL website “please don’t pay us”. However, the goal of MySQL isn’t only to generate money. By supporting MySQL, Oracle Corporation makes sure that a large community of software and database developers continues to exist. This community creates new ideas that Oracle Corporation might use —reverse engineer, if you want— in their commercial products. Another reason to support MySQL is that some customers might prefer the commercial Oracle database over the non-commercial MySQL database at some point.

If you decide to pay for a MySQL license, you don’t actually pay for the software. The software is open-source after all and can’t be sold without offering the source code. If Oracle Corporation would ask loads of money for the software only, someone would decide to compile the binaries and offer them for free, together with the source code. Anyone could do so.

Also, Oracle Corporation can do exactly the same as you and me: sell a service connected to MySQL. Oracle Corporation provides support to anyone who wants to pay for it. This way, MySQL is a source of revenue for Oracle Corporation.

Finally, there are the licenses for OEM’s, VAR’s and ISV’s. Everyone who wants to sell MySQL software as part of their proprietary software or hardware product needs to buy a commercial license. This is another source of revenue for Oracle Corporation.

For most small businesses, MySQL is the least expensive (or even completely free) and often the most efficient database available, provided that they don’t need support from Oracle Corporation. For example, being a small company with all necessary skills available in-house and not having huge databases that require continuous monitoring, Economy-x-Talk doesn’t need to buy support from Oracle Corporation.

5 Conclusion: Redistribution Is Key

The conclusion of this story is twofold. First of all, as long as you don’t redistribute the MySQL software, you don’t need to worry about licenses, even if you make money by providing database-related services or products that need MySQL to be available. Second, even if you redistribute MySQL under the GPL, you can still make money with it, as long as you offer the source code of your project, which your customer might not even want to have.

To clarify the second conclusion, keep in mind that it is not obligatory to redistribute your compiled software. When you offer the source code, your customers are not obliged to accept the offer. Because you are the one who provides the service of maintaining and improving the software and your customers are actually already paying you for this service, they might not care about the source code. Only if you ever decide to stop providing this service, your customer might have an interest in the source code.

Oracle Corporation seems to stick not closely, but completely, even literally, to the GPL. All the fuss about Oracle Corporation no longer supporting MySQL and not caring about small companies who use the MySQL database engine is sheer nonsense. Oracle Corporation continues to support MySQL for now. Even if they decided to terminate their support, anyone could take the MySQL engine and continue to develop and redistribute it under the GPL.

Note:

Please, feel free to comment on this article. Keep in mind, however, that I asked Oracle Corporation for their opinion on this matter and, although not in as many words and not that specific, this was their answer. I would like to thank Björnke von Gierke and Judy Perry for their comments.

The author owns the software development company Economy-x-Talk and gladly offers his services. Need help with LiveCode, PHP or MySQL? Let me know

The author accepts no responsibility for any consequences of business decisions based on this information. It is the reader’s responsibility to read the actual license conditions on Oracle Corporation’s MySQL website and consult with Oracle Corporation if in doubt. This article represents the personal opinion of the author, is not endorsed by RunRev Ltd. and has not been authorised by Oracle Corporation.

Integral reprint in physical and electronic form is herewith granted, on the condition that the copyright notice, the version number, the date, the URL’s and this sentence are included. If you publish this text on a web site, please embed the URL’s in a sensiblel way.

A One-Liner to Keep Track of User Preferences in LiveCode

I have kept this a secret for a long time, but after using this in many projects, it is now time to publish my user preferences library for LiveCode/Revolution.

Below follow the scripts without comments. I will write more about it in a future blog post.

function saveGlobalsToVar theGlobals
  do “global” && theGLobals
  put theGlobals & return into tempVar
  repeat for each item x in theGlobals
    do “put urlEncode(” & x & “) & return after tempVar”
  end repeat
  return tempVar
end saveGlobalsToVar

on readVarToGlobals theVar
     — breakpoint
     put line 1 of theVar into myGlobals
     delete line 1 of theVar
     do “global” && myGlobals
     repeat with x = 1 to number of items of myGlobals
          put “put urlDecode(line x of theVar) into” && item x of myGlobals into myScript
          do myScript
     end repeat
end readVarToGlobals

on writePrefs theGlobals,thePrefsFilename
  put saveGlobalsToVar(theGlobals) into myPrefs
  put prefsFile(thePrefsFilename) into myPrefsFile
  set the filetype to “sysppref”
  open file myPrefsFile for binary write
  write compress(myPrefs) to file myPrefsFile
  close file myPrefsFile
end writePrefs

on readPrefs thePrefsFilename
  put prefsFile(thePrefsFilename) into thePrefsFilename
  if there is a file thePrefsFilename then
    open file thePrefsFilename for binary read
    read from file thePrefsFilename until EOF
    close file thePrefsFilename
    put decompress(it) into myPrefs
    — put myPrefs
    readVarToGlobals myPrefs
  else
    return “Error: File does not exist.”
  end if
end readPrefs

function prefsFile theFilename
     if gU3App is true then
          put $u3_app_data_path & slash & theFilename into myFilePath
          replace backslash with slash in myFilePath
     else if the platform is “MacOS” then
          put specialFolderpath(“preferences”) & “/” & theFilename into myFilePath
     else if the platform is “win32” then
          put specialFolderpath(26) & “/” & theFilename & “.ini” into myFilePath
     else if the platform is “Linux” then
          put $HOME & slash & dot & theFilename into myFilePath
     else
          put stackToFilename(theFilename) into myFilePath
     end if
     return myFilePath
end prefsFile

Create short URL’s to your WordPress blog posts (with link to PHP code)

This is a very simple hint for those who have at least a minimum amount of knowledge about PHP programming.

Qurl.tk is a service to create short URLs. For example, it allows you to replace a very long URL such as http://paulocoelhoblog.com/2010/11/18/falling-in-love-takes-a-fifth-of-a-second/ into a very short URL like http://qurl.tk/kr. Both URLs lead to the same internet page.

It is incredibly easy to add a small Qurl.tk button to your WordPress blog to create short URLs to your blog post. Such a button makes it much easier for your readers to copy a URL to include it in their e-mails, chat sessions and Facebook pages. Here’s how to do it.

WordPress’ source code consists of PHP files, containing a mixture of JavaScript, plain HTML and PHP. Just find the right place in WordPress’ PHP files. You will want to put the button either in a sidebar or in a footer.
Now insert the following line, which is a combination of HTML and PHP, into the location of your choice (unfortuantely, I have to insert the code as a picture because Posterous doesn’t allow for including any html syntax in a blog post):

Screen_shot_2010-11-19_at_11

For your convenience, there is a file with the same code available here.

That’s all! Now you can just click the little button on your WordPress blog and Qurl.tk will let you create the short URL to your blog post right-away.