Geany PHP Beautifier

Saturday, August 16th, 2014

PHP Beautifier Support for Geany

Geany is by far one of the best text editors I have come across that works on both Windows and Linux.  It is also one of the most aesthetically pleasing editors to look at right out of the box.  I do a lot of PHP scripting, and as such, it is nice to have a "beautifier" script that will automatically format my code for me so that it looks nice.  Geany can also call the php executable and check your script syntax. You can achieve both of these features by installing both PHP for Windows and the PHP Beautifier PEAR addon.   

Install PHP for Windows:

If you code your PHP scripts in Windows, you'll want to use syntax checking and the PHP_Beautifier script.  To do so, you must install the PHP5 Windows package, which includes the main PHP binaries.

To get the files, download the latest version of PHP 5.3.

Extract the contents of the archive to "C:\php5"

Go into C:\php5 and rename "php.ini-development" to "php.ini".

PHP BEAUTIFIER WILL NOT WORK ON ANY NEW VERSION OF PHP FROM 5.4.X and UP!

Install PEAR for Windows:

PHP_Beautifier relies on PEAR functionality.  To install pear, save this file using a browser and place it in the "C:\php5" directory.  

Start command prompt, change directory into "C:\php5", and run the phar script:

C:\
cd C:\php5
php go-pear.phar

Install everything and keep default options.

Install PHP_Beautifier:

Now, install PHP Beautifier by running the following commands:

pear install PHP_Beautifier

Integration in Geany:

For PHP Syntax Checking:

In Geany, click on "Edit" in the menu bar and choose "Preferences".

In the "General" and "Startup" tabs, under the "Paths" section, paste "C:\php5" (without the quotes) into the "Extra plugin path:" field.

For PHP Beautifier:

Start the Geany text editor program.  Open a PHP script file.

Select the code you want to format, right click on the selected text, and choose "Format" –> "Send Selection to" –> "Set Custom Commands".

For command, use the following:

php C:\\php5\\php_beautifier -s4 -l "ArrayNested() NewLines(before=T_COMMENT:for:switch:foreach:T_CLASS:function:T_CLOSE_TAG,after=T_ENDIF:T_CLOSE_TAG:T_OPEN_TAG:T_ENDSWITCH:T_ENDWHILE:T_ENDFOR:T_ENDFOREACH)"

For "Label", use "PHP Beautifier"

Hit OK.

Now, select the code you want to format, right click on the selected text, and choose "Format" –> "Send Selection to" –> and pick "PHP Beautifier".  The code should now be formatted using the options specified in the command line arguments above.

For more filter options and commandline parameters, please read this PHP_Beautifier document.

 

How to Make MATE Look Like Windows XP using the Luna Theme

Sunday, April 14th, 2013

Make MATE or GNOME2 Look Like Windows XP Using the Luna Theme

If you want your Linux installation to look like the original theme used in Windows XP, you can do that! This guide will walk you through the process of easily making any MATE or GNOME2 Desktop Environment look like the Windows XP GUI. The Luna Theme can be downloaded here and installed using our simple installation script. If you already have MATE installed or are already running GNOME2, skip to the Luna Theme install instructions.

Install MATE on Ubuntu:

Run the below commands for your matching Ubuntu version in a terminal to install MATE.  To find out which version of Ubuntu you're running, use this command:

lsb_release -a

For Ubuntu 12.04:

sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu precise main"
sudo apt-get update 
sudo apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring 
sudo apt-get update
sudo apt-get install -y mate-desktop-environment

For Ubuntu 14.04:

sudo apt-add-repository ppa:ubuntu-mate-dev/ppa
sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y mate-desktop-environment-extras

For Ubuntu 16.04:

sudo add-apt-repository ppa:ubuntu-mate-dev/xenial-mate
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y mate-desktop-environment

For Other Distributions (Distros):

http://wiki.mate-desktop.org/download

Installing the Luna Theme:

Our version of the Luna theme has been converted and ported over to GTK3, so it should work with all newer flavors of Linux running MATE while still working on older Linux installs running GNOME2.To install the Luna Theme which will make Linux look like Windows XP, run the following commands. The theme files will be downloaded and saved in your Downloads directory.

cd ~/Downloads
wget -O linux_xp_luna_theme_install.tar.gz http://dinofly.com/files/linux_xp_luna_theme_install.tar.gz
mkdir Luna
tar -zxvf linux_xp_luna_theme_install.tar.gz -C Luna
cd Luna
sudo rm -rf /usr/share/themes/Luna
rm -rf ~/.themes/Luna
sudo bash install.sh

Next, Right Click on the Desktop, and choose "Change Desktop Background".  Click on the "Themes" tab.  Select "Luna".  Click on the "Background" tab.  If you want the default XP wallpaper set as your background, click on the "Add" button.   Select your "Pictures" folder.  Select "luna_background.jpg".  Click "Open".  Click on "Close" to change it. 

Now, MATE or GNOME2 looks like XP!  Enjoy!  This theme was copied from Ylmf OS 3.0.

WinRar Create SFX Self Extracting Installation Wizard and Add Registry Settings

Saturday, January 19th, 2013

Creating a SFX Installation Wizard with WinRar that Can Modify Registry Settings

WinRar's "SFX options…" dialog does not contain any information or guides that help you modify registry settings after the files for your installation have been extracted.  This is a hinderance, but it is extremely possible to modify registry settings by running a batch file after the installation has been completed.  First, make sure the .bat file is included with the rest of your installation files that you selected before making the SFX archive.  In the "Advanced SFX options" window, click on the Setup tab.  Under "Run after extraction", type in just the name of the .bat file you're going to be running.

The Batch File Itself:

This template batch file checks to see if the operating system is 32-bit or 64-bit.  This is an important distincting as it will affect how you setup keys for each type of operating system.  64-bit system keys are usually placed in the Wow6432Node key, so it is important to make this distinction so that your registry settings will work properly.  This batch file called "Program Registry Adder 1.0" provides examples on how to add and modify registry keys depending on the operating system type.

Download Program Registry Adder 1.0

Adding Keys with a .bat (batch) File:

To add specific keys, you use the following parameters:

REG ADD "HKLM\SOFTWARE\My Proggy\" /f /v "InstallDir" /t REG_SZ /d "%PPROG%

The first parameter specifies which hive and key should be created.  The /f flag forces the addition.  The /v flag is the name of the key that should be created.  The /t flag specifies what type of Registry key should be created.  The example uses REG_SZ, which is just a string.  The possible types are:

Value Type (Use this in the batch File)
Binary REG_BINARY
DWORD REG_DWORD
Expandable String REG_EXPAND_SZ
Multi-String REG_MULTI_SZ
String REG_SZ
Binary REG_RESOURCE_LIST
Binary REG_RESOURCE_REQUIREMENTS_LIST
Binary REG_FULL_RESOURCE_DESCRIPTOR
None REG_NONE
Link REG_LINK
QWORD REG_QWORD

 

Check out more information here.

The /d flag contains the value of the key.

Conclusion

Using both a self extracting installation wizard and a batch file for registry key settings makes for the perfect free to use professional looking installation script. You can always run the batch file silently by removing all pause statements in the script. 

Open Game Panel Windows Installation Guide

Saturday, July 28th, 2012

Open Game Panel Windows Installation Guide

Open Game Panel (OGP) is a free, open source game server panel.  OGP allows server administrators to manage multiple game servers and assign users to those servers.  These users are then allowed to login and manage their rented game servers.  Users can stop, start, restart, and edit command line parameters for their servers.  FTP management is also included in the Linux version.  OGP does have a Windows version, however, it is difficult to setup.  However, this guide will walk you through everything you need to know.

General Information and Notes

  • Some links used in this guide will only work from your local server.
  • I installed ZPanelX and OGP on a Windows 7 server, and yes, they are working.
  • OGP is short for Open Game Panel, if you didn't already know.

Step 1:  Download and Install Prerequisites

Open Game Panel works in conjunction with a web hosting control panel and requires web server software.  To make this guide as simple as possible, it is recommended to install the ZPanelX package, which includes everything you'll need to run Open Game Panel.  Download both the Core and Stack ZPanelX packages here:

ZPanelX Hosting Control Panel & Software for Windows

Install the Server Stack version first, and then run the Core version to setup your web panel and login information. It's really as simple as running the installation executables and following the installation prompts.

After ZPanelX has been installed, download the SVN version of OGP from here: http://hldstart.svn.sourceforge.net/viewvc/hldstart/trunk/.  From the SVN page, just click on "Download GNU tarball".  This will download a compacted zipped file which can be open using 7-Zip or WinRar.  Extract the files.  From the extraction directory, copy the upload folder to the C:\zpanel\panel directory. Rename the folder to opengamepanel.

Open up the php.ini file located in C:\zpanel\bin\php and change the following line:

display_errors = Off

To:

display_errors = On

Keep the php.ini file open, as we'll need to change another setting after installing PEAR, a module required by OGP to run.

Step 2:  Installing PEAR For Windows

To install the PHP PEAR module for Windows, save this file containing the patched PEAR PHP installation script, and extract it to the C:\zpanel\panel directory.  Run the PEAR installation by following this URL from your LOCAL server: http://localhost/go-pear.php.  Read the prompt and go to the next page.  On the installation page under the Configuration section, you'll need to make the following changes:

For "1. Installation prefix ($prefix)", use the path of:

C:\zpanel\bin\php\pear

Keep the rest of the settings set to their default value. Click Install. After PEAR has been successfully installed, go back to your php.ini file and find your include path:

Change:

; include_path = ".;C:\php\includes;"

To:

include_path = ".;C:\zpanel\bin\php\pear\PEAR;"

Save your PHP.ini file. Now, before your changes will take effect, you must restart the Apache daemon. Do this by going to Start –> All Programs –> ZPanel –> Management –> Apache Monitor

When the Apache monitor loads, click Stop, and then click Start.

Step 3:  Creating Database and Users:

Login to ZPanel using your login and password that was created during ZPanelX installation. Under Database Management, click on MySQL Database. Create a new database with any name. Once the database has been created, go back to the main Admin page. Under Database Management, click on MySQL Users. Assign a user to the database you just created… this will be the login and the user's password will be generated after assigning the user to a database. Save the database name, login, and password, as you will need these values when installing OGP.

Start the installation of OGP from your LOCAL server:

Start OGP Install

After installing OGP, it's time we installed the Windows server agent program:

Windows OGP x64 Agent Install DownloadWindows OGP x86 Agent Install Download – (Create an account and login before you can access the download!)

Install the OGP Windows Agent program.  Run the agent_stop.bat file in the OGP installation directory after the installation has finished to stop OGP.  To run OGP without using the service account, simply use these agent start and stop scripts instead.

Start the agent. Login to OGP, create a server, use the encryption key you just created, and for the username use your Windows username.

The server should be added successfully and show up as online.  You can now setup and administrate game servers on your Windows server!

Windows XP, Windows Vista, and Windows 7 x86 and x64 .NET 4.0 Post Installation Slow Startup Network LAN Devices Fix

Thursday, March 29th, 2012

Windows XP, Vista, and Windows 7 .NET 4.0 Post Slow Startup Fix

I've been running my main machines on Windows XP x64 for several years, and I am a .NET developer.  There came a day when I needed .NET 4.0 for my development projects.  After installing .NET 4.0 in Windows XP x64 SP2, I noticed a slow bootup despite the fact that I have a solid state drive.  Windows would always boot up and freeze for about a minute before the network LAN and Wireless LAN computer icons appeared in the system tray.  At first, I never realized the problem was caused directly from the install of .NET 4.0.  For over a year I tried troubleshooting the problem.  I noticed that I had this problem on all of my XP machines after installing .NET 4.0.  I suspected video drivers, LAN drivers, wireless LAN drivers, and even my BIOS.  Nothing fixed this issue.  After further searching, I finally found a thread describing the same issues I was having.  Save yourself the read, and just run this batch file I wrote after installing .NET 4.0 on ANY Windows XP x64 or x86 machine:

set I=%windir%\
%I:~0,2%
cd %windir%\Microsoft.NET\Framework\v1.1.4322
ngen update
cd \
cd %windir%\Microsoft.NET\Framework\v2.0.50727
ngen update
cd \
cd %windir%\Microsoft.NET\Framework\v4.0.30319\
ngen update
cd \
cd %windir%\Microsoft.NET\Framework64\v2.0.50727\
ngen update
cd \
cd %windir%\Microsoft.NET\Framework64\v4.0.30319\
ngen update
sc stop "clr_optimization_v4.0.30319_32"
sc stop "clr_optimization_v4.0.30319_64"
sc config "clr_optimization_v4.0.30319_32" start= disabled
sc config "clr_optimization_v4.0.30319_64" start= disabled
@echo off
echo.
echo. All operations have been completed successfully.  The .net 4.0 framework services were disabled, as they are no longer needed.  This will not affect .net 4.0 applications, and your startup boot time should be back to instant!
pause

This script is useful on all versions of Windows.  If you have a slow startup, try running this to see if it improves the situation!