Adding Strict Standards, (Or Removing)

I have been developing on a Debian Apache system for a long time, for one of the projects I have been working on I had to run on a Windows Server. After installing XAMPP I noticed that by default, XAMPP sets the developer settings of Strict Standards. Meanwhile the Linux system didn’t have that enabled. I went out wanting to set the Linux server to have the Strict settings to force me to code properly. I found many places that would tell me how to disable strict standards (because users found it bothersome), but after a little searching I didn’t find a clear guide so I thought I would write one for PHP5.

  1. Find “php.ini”
    • Windows (XAMPP): The file is kept under C:/xampp/php/php.ini
    • Linux: For php5 (at least in debian) /etc/php5/apache2/php.ini
  2. Open the file and scroll to;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Error handling and logging ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. The line you want to edit iserror_reporting =…
  4. Copying the line below will enable strict settings, while other combinations listed below will enable different values.
    • Development Value: E_ALL | E_STRICT

My Linux box configured itself as  “error_reporting = E_ALL & ~E_DEPRECATED”, which is the standard for production.

Here is the description that comes with php.ini,

;Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting

Time Tracker

Recently I have been working on an hour keeping system for my work at RPI; we have an old time card system that is running on a Windows 2000 server. The code no longer works, as in the JavaScript is not supported by modern browsers. The old system has been running for over 11 years, and it is time to let it retire.

The new system is at version 0.1 right now, with basic functionality working. The system is split into groups, so while one server runs separate departments can run a “group” and have their employees under there. Once a user is given privileges to one group in the system, when that user logins in, that group will automatically come up.

The old system had a html page that managers could edit, to give announcements to workers. This was a bit of a tedious process to go in and manually edit these pages, now there is a field for the manager of each group to drop html to edit their page. The system has two levels of accounts and privileges, there is the privilege within a group, and the privilege for the entire system. While a user can be administrator of a group and edit their group, they may not have administrative rights over the entire server. By having administrative rights to the entire server, a user can change the splash page before a user is logged on, or create new groups in the system.

The system allows for templates to be made of weeks, so if a student worker works the same hours every week, then they can save it and deploy it easily. I am working on integrating email reminders by using a .Net application that integrates with MySQL. By having the application read who has yet to enter logs this pay period  I can use the students CAS login to get their email.

Below are some photos of the system, and it is all open source at the attached link.

Source: https://github.com/daberkow/RPI_timetracker

Recovering WIM Images

A user came in to helpdesk with a laptop that had a dying hard drive. A coworker was able to recover part of the LENOVO_RECOVERY partition to a new drive that was installed in the laptop, with a intact .WIM image, yet the partition would not boot. We tried rewriting the MBR, rebuilding BCD and other tricks but nothing would work. To make a very long story of us trying everything to get this drive to restore with no avail; we were able to manually make a partition then use GImageX to recover the image.

The new hard drive had the 10gb recovery partition we had copied over, and nothing else on it. So first using DiskPart, we made our new partition for windows.

  1. Boot from a Windows Vista, or 7, or later installation disc
  2. Go to Recovery Mode, and then get to the command prompt (dont do a system restore)
  3. Run diskpart
  4. “list disk” and then “select disk #” for the disk you want
  5. “list partition” will list what is on the hard drive, we then did “add” to make a new partition
  6. “select partition #” will select the new partition if you put the correct number in
  7. Finally “assign” will give the new drive a drive letter

Now that the new partition exists, we used http://www.autoitscript.com/site/autoit-tools/gimagex/. This tool will recover the standard WIM windows images to a partition. To make life easy we copied it to a thumb drive and then launched it on the recovery disc. If your windows disc is 64 bit, you will need the 64 bit version of the app. Once we had the app it was just a matter of launching it and going to the second tab of “Apply” to install the image. The laptop we were working on had the recovery image hidden, in a folder called “FactoryRecovery”. By running “dir /AHS” the computer will list all files in a directory, including hidden and system files. While navigated to the directory you know the images are in, running “attrib -S -H /S /D” will remove system and hidden attributes from the files and folders. Now GImageX can see the image and recover it.

That was the end of a long recovery, if anyone has questions post a comment.

Windows Sudo

I am back at RPI, finishing up my degree. Recently I have been working on hour tracking software for several departments at RPI.

Recently I have run into a minor annoyance where I am in the command line in Windows and need to elevate a command or program so that I can do a administrative task. (Such as moving a file to the system32 folder), the normal solution is to right click command line short cut and “Run as Administrator”. While that works its not fast, I’m sure there are other solutions out there, but I wanted to quickly build on in .Net. I did this a while ago for Vista and called it elev, but never saved it and since I am trying to make the transition between Windows and Linux easier I called it sudo.

All you do is put this in your %windir%\system32\ folder, and then at the command line type “sudo cmd” or whatever command you want. Commands like “dir” are actually part of cmd not a separate file called so “sudo dir” wont show anything, it will output the .Net error.

Link to exe: https://github.com/daberkow/win_sudo/blob/master/sudo/sudo/bin/Release/sudo.exe

Link to project: https://github.com/daberkow/win_sudo

Quick Compare

I wrote a quick little program to solve a problem for me. If you have two algorithms in webpages and want to benchmark them to see the difference, the program will work for you. You add the the below code to a PHP page, or do he same thing in other languages, then the app will run as many times as you tell it to and find the result in time. To lower the time it takes to get a result, you can up the thread count. Averages are not returned till all threads return information.

Start of PHP Page:
$time = microtime(TRUE);
End of page:
echo "seconds " . (microtime(TRUE) - $time);


Download:
https://github.com/daberkow/QuickCompare/blob/master/WebTest/bin/Release/WebTest.exe
Git:
https://github.com/daberkow/QuickCompare/

Windows 8 Update

Windows 8 is just around the corner, and I have been using it for a few weeks. Most people look at it and don’t to try the new interface; but after using it for a while, I find that I am faster, and that my computer is faster on it. The Task Manager is much better for those who want to use it, you can get all data at a glance, and drill down to what apps are using which resources. I was told that if you have a screen under about 1300×700 then you can’t do the split screen action that larger machines can. Office 2013 preview is out, it allows users to install office over the internet in about 20 minutes, but it is usable in about 2. This is useful when setting up a new computer.

I was forced to reinstall my laptop, Toshiba Portege Z835-P330, the settings that the built in metro apps had automatically came back. Going back to the Windows Store and telling it to reinstall all the apps I had earlier in Metro was seamless. All the apps that were install in the desktop, including chrome, which bleeds over to metro, has to be reinstalled manually. The year is 2012, and by using Dropbox/Google Drive and logging into chrome reinstalling was painless.

The last note I want to make is that I ran into a weird Toshiba software bug, my laptop has an Eco program that tells the user how much power the laptop is using to the watt. I tried to install it and got “Unsupported Bios”; you have to first install “The Toshiba Value Pack”, then that puts core Toshiba files in and all of a sudden the eco tool will work.

Friend Blogs & IT Jobs

Blogs

Two friends of mine at Rensselaer Polytechnic Institute (RPI) have blogs as well, one is about college food, http://collegefoodie.com/; the other, is for Wine and related foods, http://quintessenceofmediocrity.blogspot.com/. The college food blog run by a contributor for this blog, Kevin Ung, @kevinung.

Jobs

Now that it is senior year of college for me, the job hunt has started. This year there was a good turn out for the Information Technology (and Web Science) program at the RPI career fair. There seems to be two types of companies at the career fair for IT, some know they want IT and what that entails; the other are companies that want Comp Sci but say they want IT. The latter, in their interviews tends to ask questions such as algorithms.

Many companies have rotation programs for IT students, these are designed to start with a generic student and train them in the organizations method and technologies. These programs tend to be 2-4 years, with 6-12 month rotations; ranging from databases to networking. Most of these programs also focus on creating managers out of these students, going back and forth between technology classes as well as management skills.

To any new IT students, I would recommend knowing what path you want to go down early on, do you want to be closer to general (broad) IT, or focus on the computer science components

OpenAFS @RPI Client

Recently I was told “I can’t remember anyone getting OpenAFS to work on their own”, by a staffer at my school. I took it on myself then to figure out how to get this working for students. And in the end I wrote an app that will automatically download and install the AFS client, then configure drives for you. This was an experiment in threading and using WPF instead of Windows Forms.

First the app goes and downloads the OpenAFS client, if it is a 64 bit machine it grabs the 32 bit tools first then the client. While downloading and installing these things it connects via SSH to a school server to get the location of the user’s home folder as well as verify the credentials given.

Once installation is complete the program runs ‘klog’, this goes to the AFS server and requests tokens in the cluster using the credentials given earlier. Once we are past the installing point all these actions need to be run on the campus network. When the program starts it tries to ping a couple internal servers, if it can hit more than half of them in under 75 milliseconds then it considers itself on campus; if it thinks it’s off campus, then it notifies the user. One small problem with the first release is sometimes this system gets confused by vpn taking slightly longer.

Now that we have working token the system recommends drive letters that are not in use as well as AFS spaces to mount including the users folder and ‘dept’ to start. The configure button will activate these drives, they are not set to persistent at this time.

Below is the github link, as well as the direct exe link:

Github: https://github.com/daberkow/RPI_OpenAFS

EXE: https://github.com/daberkow/RPI_OpenAFS/blob/master/OpenAFS%20Installer%20WPF/bin/Release/OpenAFS%20Installer%20WPF.exe

C#/.Net SSH Framework

I needed a SSH framework for a program I am writing for my school. There are quite a few out there for .Net but I ended up going with the one from http://sshnet.codeplex.com. It requires .Net 3.5 or 4.0, but its ease of use makes this not a problem. Below is a example of code using the pre-built binary for .Net 3.5, this code connects to a SSH server, then runs a command and stores the result in a string called ‘temp_holding’.

Renci.SshNet.SshClient MysshClient = new Renci.SshNet.SshClient(server, username, password); //these are varibles of strings
try{
MysshClient.Connect();
}catch{
//Something in here failed
return;
}
Renci.SshNet.SshCommand MyRanCommand = MysshClient.RunCommand(“pwd”);
lock (locker){
string temp_holding = MyRanCommand.Result;
}