May 6

It’s here!

Woot.com doesn’t always have stuff I want. In fact, typically it’s only a couple times per year I see something I’m interested in. Last week for the low price of $75, I saw the Flip Ultra. I’ve played around with Brandon’s flip and have wanted one for a while but didn’t really want to spend the $150 on it for fear of it sitting in my laptop bag doing nothing.

Guess we’ll see what happens with this one. Hopefully it turns out to be more than a $75 paperweight. It doesn’t weigh much even with batteries so it probably won’t be a good one.

As a byproduct, who knows maybe I’ll even start posting videos here.




Dec 11

PHP Objects and Sessions

Tags: , ,
Posted in:Tech | 3 Comments »

We stumbled across an interesting issue at work today with the Zend Framework and objects.  We’re working on a filter for a series of reports that carries over from page to page and in the process of development, decided it would be best to move this from page to page within an object.

The error we were receiving while doing so however was “The script tried to execute a method or access a property of an incomplete object.”  Doing a bit of reading up on php.net, it turns out that php serializes an object, then when the session is started, it unserializes the object.  You won’t actually find out there’s a problem until you call a method that is supposed to reside within the object.

The work around for this problem is loading the class into memory before starting your session.  In our situation, we’re running the Zend Framework which start’s the session on it’s own and it seems unsensible to modify the Zend libraries but we still had a problem with an incomplete object.  Thus on my path to finding a way to work around this problem, I created class.cow.php.

Read the rest of this entry »


May 13

Google really rules my life.

Posted in:Tech | 1 Comment »

I think I’ve made mention before just how much Google has changed my life. So many times during the day a quick command-K or ctrl-K gets me any of the data I’m looking for. It’s odd to see myself search Google versus other users, it seems as if my brain has learned which keywords work best for my query, without me needing to think.

Unfortunately, lots of the world isn’t like me. Most people don’t think in queries, and which words are most likely to be indexed. Enter, Powerset, a company that is working on developing a search engine targeted towards parsing the human language. While I can applaud them for trying, I have to admit I was skeptical if they can knock google down. It’s time to do a comparison.

Read the rest of this entry »


Jul 29

Fun with SQL and in line queries

So I’ve grown to not like the coding style of the guy before me at all. Some of his methods are quite, recursive and hellish when it comes to SQL. Several times, the easy way was taken rather than the correct way. To give you a bit of background, the main application I support controls at outbound call center. Agents log into the system and dial out with it. In order to track what a current agent is doing there is a table called actions. Everything from logging in, logging out, and more is logged here. Over the past 2 years, this has led to over 7 million records in the table. If you’re not a tech person, it’s about to get deep.

In order to determine if a user is logged in, the previous programmer would do the following. Query the database for all users with a type of 2 (call center agent). After that for each user in the database of type 2 (call center agents, currently ~120 agents exist), he would query the actions table for the users last action, whether it’s action type 1 (login) or 2 (logout). If the first returned row is of action type 1, the user is logged in. Lastly, the code queries the actions table to see what the last campaign a user logged into. (action type 20). After throwing in some basic code to track the queries and time of this (and thanking John Davis along the way for teaching the importance of big O notation) I learned that an average check of who’s logged in totaled around 150-200 queries along with taking 45 seconds to a minute. So this was one of my goals in Nashville last week, to write one massive query I could use to get the results I’m looking for. To assist me in the insanity, I called master of all that is shoes, Brian Schumacher. We worked together back at Irresistible Ink as data developers and since he’s gone on to be a DBA in Klamath Falls, Oregon. Well he quit last week but that’s his story not mine.

So after about 45 minutes of being on the phone and utilizing the greatness that is pastebin, we worked out a viable solution. I present to you, possibly the most complicated query I’ve written to date.

SELECT
loggedIn.lastname, loggedIn.firstname, campaigns.cpnname, DATEDIFF(ss,[actions_4].[actionwhen],getdate()) AS LoggedIn, DATEDIFF(ss,[actions_3].[actionwhen],getdate()) AS CampaignLogin
FROM
(
SELECT
employees.unqempid, employees.lastname, employees.firstname, ActionIDLoggedIn.actionID
FROM
(
SELECT
unqempid, MAX(actionid) AS actionID
FROM
actions
WHERE
(actiontypeid = '1')
GROUP BY unqempid
) AS ActionIDLoggedIn
INNER JOIN
(
SELECT
unqempid, MAX(actionid) AS actionID
FROM
actions AS actions_2
WHERE
(actiontypeid = '2')
GROUP BY
unqempid
) AS ActionIDLoggedOut
ON
ActionIDLoggedIn.unqempid = ActionIDLoggedOut.unqempid AND
ActionIDLoggedIn.actionID > ActionIDLoggedOut.actionID
INNER JOIN
employees ON employees.unqempid = ActionIDLoggedIn.unqempid
WHERE (employees.type = 2)
) AS loggedIn
INNER JOIN
(
SELECT
unqempid, MAX(actionid) AS actionID
FROM
actions AS actions_1
WHERE
(actiontypeid = '20')
GROUP BY
unqempid
) AS maxCampaign
ON maxCampaign.unqempid = loggedIn.unqempid
INNER JOIN
actions AS actions_3 ON maxCampaign.actionID = actions_3.actionid
INNER JOIN
campaigns ON actions_3.actioninfo = campaigns.cpnid
INNER JOIN
actions AS actions_4 ON loggedIn.actionID = actions_4.actionid
ORDER BY
loggedIn.lastname, loggedIn.firstname

The end result, we’ve shortened this down to 1 query that takes 2-3 seconds. Hopefully this post can only serve as help to some programmer stumbling along a similar problem as mine.


Jul 16

Hacking at work for fun and a paycheck

Posted in:Tech | 1 Comment »

So at the new job we have a few offices in different locations of country.  For example, next week I’m heading to Tennessee to experience the call center application I’m working on first hand.   I had just relocated one of our databases from the Michigan office to our sql server here in Minnesota and a report that a user from Michigan runs broke in the process.  The user called in to report the report had to be run but she wasn’t at her system.  I was told that remote desktop was disabled on these systems but the passwords I was given weren’t working properly.

After some failed attempts at remotely starting remote desktop, I started looking into ways to get into VNC.  They weren’t running the older vulnerable version of so that was out of the question.  After doing a bit of google searching I came across a utility called vncpwdump which allows you to dump the existing password from the registry.  Unfortunately the program was only giving me a portion of the password.  Instead I decided I was approaching this the wrong way.   I went ahead and changed my VNC password to a temporary password and then exported the registry key.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\WinVNC4]
“Password”=hex:aa,aa,aa,aa,aa,aa,aa,aa
“SecurityTypes”=”VncAuth”
“ReverseSecurityTypes”=”None”
“QueryConnect”=dword:00000000
“dummy”=”"

Then using Connect Network Registry option in the registry editor, I imported my registry file to the remote system.  Voila!  


Jul 11

Windows Vista and terminal service

Posted in:Tech | 2 Comments »

I actually stumbled across this a few days ago at work.  While trying to remote desktop into our terminal server,  I kept experiencing some odd slowdowns as if the connection was intermittently working.  The odd thing, is I had no issues while typing in my password or typing in a window when I turned up the command prompt.  After doing a bit of searching I came across some sites that explained what was going on.

With Windows Vista a new technology referred to as autotuning was introduced.  This feature enables the system to adjust the size of tcp packets beyond 64kb.  To do this, a SYN packet to negotiate a larger packet size is sent to the client.  This is all fine and dandy except that some routers think this is something else and strip the acknowledgment packet so the server starts running with the new packet size, and the client sits dumbfounded.

To make a long story short, I disabled autotuning with the following command:

netsh interface tcp set global autotuning=disabled

After which, I was able to remote desktop to my hearts content.  The reason this only occured with our 2003 server was that our 2000 servers don’t support autotuning.  Go figure.


Jul 10

MSSQL to MySQL migration

Posted in:Tech | 2 Comments »

Well today I start the initial steps of migrating our MSSQL databases to MySQL.  One of the first tasks here at the new job was to determine where our MSSQL licensing was at.  We’re currently running a version of MSSQL 2000 Personal edition so we either need to migrate or get our servers legal.  <rant> Our existing setup is 2 servers, 1 IIS server, and another dual processor system running MSSQL.  Due to Microsoft’s awesome licensing setup, in order to be legal we need to purchase 2 MS  Windows Server Unlimited Connector licenses.  The part that makes no sense, is one is for the IIS server, the other is for the SQL server.  I can understand one, but the second is ridiculous.</rant> So in the end, it’s pay $17,000+ to be legal, or move MySQL, which in the benchmarks I can find, smokes MSSQL.

After this, I went ahead and installed the MySQL migration tools on the MSSQL due to the application crashing on the CentOS box.  I had to modify the grant tables to allow root to remotely connect to the system.  After this, I ran into a small pitfall of the Migration tool.  The default value of some of the fields in my table refer to MSSQL functions, which aren’t compatible with MySQL so I had a compatibility error.   For example:

`beginningdate` DATETIME NULL DEFAULT convert(datetime,(convert(varchar,datepart(year,getdate())) + ‘-’ + convert(varchar,datepart(month,getdate())) + ‘-’ + convert(varchar,datepart(day,getdate())))),

Since getdate() and datepart() aren’t acceptable functions, I removed the default value for now.  After that all of the data migrated fine except for a few truncated records.  When I move this to production though I’ll be sure to solve that problem.


HEY! Did you eat my pickle... or did I?
-Kyle Berg

  • Josh
  • Nothing to Say
  • Plastic Metal
  • Shoe False Fiction