Author: johnro

  • SQL Server: SELECT INTO inside both IF and ELSE blocks

    I ran across this problem earlier today, and thought I should address this here in case anyone is interested in my solution.

    When doing a SELECT INTO command against the same temp table in both IF and ELSE blocks, you will quickly learn that SQL Server complains that there “is already an object named ‘#temp’ in the database”. What one can do to avoid this problem is declare the temp table before the IF/ELSE block and insert into the table afterwards, but what if you want to use SELECT INTO instead?

    if @var = 1
    	select 'abc' into #temp;
    else
    	select 'def' into #temp;
    
    select * from #temp;
    

    (more…)

  • PHP Warning: json_encode() [function.json-encode]: Invalid UTF-8 sequence in argument in god_i_hate_this.php

    Ever get the following error?

    • PHP Warning: json_encode() [function.json-encode]: Invalid UTF-8 sequence in argument in…

    Then you are in the same boat I was in, and unfortunately for me, the solution wasn’t as straightforward as I thought it was. The problem we are seeing is that the value being encoded to json is not UTF-8 encoded data. PHP function json_encode, unfortunately, will only accept UTF-8 as its parameter. (more…)

  • IRQL_NOT_LESS_OR_EQUAL BSOD could be a memory-related issue

    I recently built my wife a new computer, and right off the bat we started getting IRQL_NOT_LESS_OR_EQUAL BSOD (blue screen of death) problems. We researched high and low online for answers to fix this problem, but most sites accuse device drivers to be at fault, that most likely we installed the wrong driver for one of the installed devices or computer component. But the problem we were seeing was we’d get the bsod after a fresh new installation of windows, and one time even DURING the windows installation, so it couldn’t have been a device driver problem unless Windows 7 itself was installing a driver it should not have, which is usually not the case. (more…)

  • Easy way to lose weight and stay fit… for lazy people!

    I’m sure those who are interested in losing weight or slimming down have one point or another searched online for a way to lose their excess weight and stay fit. If you are one of them, you know the steps to fitness are complicated: watching your weight, grocery shopping for health foods, learning workout routines, etc. A lot of the times it’s a hassle and that’s something you don’t want in an already busy life.
    (more…)

  • Convert XML to array and vice versa in PHP

    As a developer, it is common to search the web for an existing (open source) code snippet to re-use for an application, but it is rare for the developer to just copy code online and use it straight in their application without modifying it first.

    I am one of many developers who like to save time if possible by using open source code if coding from scratch takes longer than a couple of minutes, but there are times when one cannot be found. I ran into such situation when I wanted a function that converts an XML string into an array. Unfortunately, most are overly complicated for what I wanted, so I decided to create my own and share with the world. The following function converts XML strings into a PHP array while retaining the level depths of the XML but all attributes are ignored. (more…)

  • Assembla: Project Managing

    I signed up for a free account at Assembla today for version controlling my codebase from hostmonster. Limited 2GB free svn repositories. Not bad

  • php.js

    If you are a PHP programmer struggling with javascript, then php.js is your answer.
    (more…)

  • Apple to Trump Microsoft?

    Apple’s reports vs Microsoft’s reports show that Apple topped Microsoft in 3rd quarter revenue (source).

    Back in May, it was announced the Apple surpassed Microsoft and became the 2nd largest U.S. company by market capitalization. I believe it won’t be long before Apple makes Microsoft the littler man it is like facebook did with myspace.
    (more…)

  • Steve Jobs Documentary

    Click here to watch a 48 minute documentary on Steve Jobs.

    I never really cared for the Apple company or any of its products until I bought my first mobile device: the iPhone 3G.  The phone was amazing, there was no device like it at the time, and I’d spend a good chunk of my free time fiddling with it or playing games. With the release of the iPad, which I have yet to purchase, it further perked my interest in the company. With just a few months shy from the release of the iPhone 4, I started checking up on Apple news and conferences on a regular basis. I found myself reading a lot about the company (e.g. Macrumors) and before I knew I was headed to Apple fandom.
    (more…)

  • PHP MVC framework war

    Back when CakePHP’s v1.2 was still in its beta stage, I started learning the PHP language using the MVC (model-view-controller) framework, and I grew to love the language. I became more fluent with the language as I grew more biased towards cake. I would often google MVC comparisons like “CakePHP vs codeigniter“, or “CakePHP vs symfony“, etc, but in my heart, I knew CakePHP was the one for me.
    (more…)