Posts

Showing posts from 2011

Apache2 configuration for embedded PHP in HTML files

If you want to use PHP scripts on your web server it is a simple thing to add a script inside a page and save it as a .php file extension. Listing of phpinside.php     <?php        echo "Hello PHP World!"     ?> When this file is browsed if looks like this: Hello PHP World! With the default installation of Apache2 and PHP, however, Apache2 does not know to render an html file as a PHP script. If you name the above file phpinside.html, you will instead see elements of the PHP code when you view the file in a browser. There are thousands of (old) posts for Apache configuration of PHP by editing the httpd.conf file to include HTML as an application/x-http-php type. However, few make note that Apache2 has a new config file structure for Debian (Ubuntu). Refer to the page that I found for a better explanation: Control Escape - Configuring Apache2 on Debian, Ubuntu Now the "AddType application/x-http-php" directive is in the php5.conf file in the &qu

Free CAD/CAM Options

There was a time when CAD and CAM software was simply not available for anyone without paying a substantial sum of money.  The version of AutoCAD 10 (which came on 10 floppies) that I used for a year at MFJ Enterprises to do product documentation cost almost $1000. Even low quality programs cost upwards of $99 or more.  However, in the past few years there have been many new free versions of software available that are high and even professional quality. Sketchup Arguably the first really free CAD software that was good quality was Sketchup . Sketchup was written by a company called  @Last Software which sold the software for $495.  The company wrote a plug-in for Google Earth and soon afterward Google bought the company.  In 2006 at Google Developer Day the developers of Sketchup were there presenting the software and giving away free Sketchup socks.   An important feature of Sketchup is that users can write short snippets of code in Ruby to configure or extend the application

Python and MySQL

Although PHP is used a lot for SQL scripts, Python is a fine alternative. The commonly used SQL library in Python is MySQLdb.  MySQLdb is an thread-compatible interface to the popular MySQL database server that provides the Python database API. ( from the documentation ) An example showing the guts of a Python MySQL script. import MySQLdb conn = MySQLdb.connect (host = " localhost ", user = " root ", passwd = " admin ", db = " databasename ") db = conn.cursor() db.execute ( " SELECT * FROM table1 ") data = db.fetchall() #do something with the data db.close () conn.commit () conn.close () Looking over the code example : After the import is a connect request to an SQL database.  The database in on the localhost and has the default username and password.  The the actual database name must be specified.  MySQL databases can have multiple databases on one host. Note that on all the code accessing data or running commands on the data

Setting up a Python CGI Sandbox on Windows

It makes sense sometimes to set up a sandbox for development of CGI.  By sandbox I mean a computer isolated from the web running all the programs needed to develop for CGI.  If you have a Windows machine there are fewer resources available online for setting up Apache, etc than for a Linux box. Note that installing a Apache server does take some resources but I noticed no difference on the 3 GHz Pentium D machine with 1 Gb RAM that I was using. follow these steps in setting up a windows machine: Install Python If you are going to put scripts on a server at an ISP such as 1and1 or GoDaddy you should be aware of the version of Python available to your hosting package.  For 1and1 I installed Python 2.5.  Also be aware that neither 1and1 nor GoDaddy use modpython at this time.   Install Apache Use a standard install of Apache.  It should take only a few minutes to install and configure.  When you are setting up make it "localhost". Add python as a CGI by modifying the foll

CamSoft System CS-209 - $1991.00

Image
When I bought my Bridgeport CNC Mill, it came with a CNC CS-209 control package made by CamSoft.   Here is a description from the CamSoft Website: CNC Lite software, AS3000 3D CAD/CAM system, USB Jog Stick Handheld Controller, CS 14000 - 4 axes stepper motion board, cables with user provided computer. CNC Lite Software AS3000 Cad/Cam System USB Jog Stick Motion Boards Limited time special offer starting at $1,991 I was excited about using this to retrofit the mill.  Considering the kit had never been installed I thought that it should be pretty easy to get the mill up and running.  The kit even comes with CAD software which is a big expense for CNC machining. The CAD software is called Advanced System 3000 and requires a hardware key (I think).  The software was on the computer that came with the mill but it was not very intuitive.  I have used AutoCAD and Solidworks extensively so I was surprised that I could not really just start drawing. The package also comes wit

Simple User Settings in a C# Windows Forms Application

There is a lot of confusion and long programming blog posts on application settings for a Windows Forms Application in C#.  I needed a quick and simple way to save a few user specific settings such as com port settings and names of labels on a customizable GUI. I have used the Python config package written by Vinay Sajip in a previous project.  The nice thing about the package was that it opened a config file and made an object which could be accessed as config.ports.baudrate .  Since Python is not typed the config file, which is simply Python code without any punctuation marks, is flexible, fast and easy to create. I had hoped that C# would have an easy way to build something similar.  I found an post early on suggesting using app.config.  After reading MANY posts on configuration and trying a lot of code that would not work on Visual Studio 2011 I had about given up and started writing my own. Luckily I found a simple solution. A settings file is already included in a Windows

Setting up Ubuntu for Automatic Turn-on in Emc2

After booting Ubuntu, logging in, and starting up Emc2 for the past year, I am getting lazy. So I setup Ubuntu to automatically log in to my main account and start the EMC2 program. It is different than doing the same thing on Windows but possible (all thing that are possible in Windows are so in Linux usually with MANY more options...) Setting up the computer to automatically log in to an account: NOTE: This should probably not be done if the machine is on a network. This one is simple and easy to find with a Google search: Click on System -> Administration ->Login Window Click on Security The click on "Enable Automatic Login" And select the name of your user in the box below it. Setting up the machine to run a program like Windows "Start Menu" My first thought was to modify the .login file which is the old school way to start programs outside of a windowing environment (back in 1987...) With Ubuntu you have to start a program after the wind

C# Textbox - Enter to go to next control

I was building a Windows Form Application in Visual C# Express 2010 and had a problem that needed a lot of searching to figure out.   I could not get a value to "enter" and tab to the next textbox when I hit the  Enter key. After much trial and error (most of which would work but I still got a bell when I hit Enter ) I found this. Enter this as the KeyDown Event. Note that KeyPress uses KeyChar return types. private void textbox1_KeyDown( object sender, KeyEventArgs e) {       //checks for Enter, suppresses it and sends a tab       if (e.KeyCode == Keys .Enter && e.Modifiers == Keys .None)     {         e.SuppressKeyPress = true ;  //eliminates the enter key *BELL*         SendKeys .Send( "{TAB}" ); //changes focus to the next control     } }