Skip to main content

Posts

Consuming Microsoft .NET SOAP server datasets in PHP

Microsoft Just Clowning Around Again If you're impatient here is the link that this article leads to SOAP is generally understood to be a simple method for systems to exchange data in a standard manner. This allows for remote systems to make calls on a server application. This sounds like a Good Idea. Microsoft, however, does not appear to fully understand the concept of SOAP when it comes to providing a SOAP server based on "datasets". Apparently the use of these datasets make it much easier for programmers using Microsoft languages to consume web services.  Unfortunately it makes it inconvenient for everybody else. So we have a standard way of doing things, but Microsoft decides to "improve" it and thereby forces everybody else to manually parse their XML responses. What is the point of having a standard method of accessing server methods if Microsoft then makes their implementation inoperable to Java, PHP, Ruby, Python, developers?  Isn...

Questions for mid-level PHP developer candidates

I often get CV's from developers applying for positions. Some colleges give people a certificate without really giving the candidate any problem solving skills or real understanding of theory. Here are some standard questions that I ask candidates to complete with pen and paper without access to Google. They cover basic OOP theory, logic, basic PHP syntax, and try to get some idea of the candidates passion for learning. In the rare occasion that a candidate actually bothers to investigate the company and finds my blog they will naturally be expected to do well on this quiz.  I guess that's bonus marks for being prepared :p PHP quiz ======== 1) Explain what SQL injection is and give TWO ways to combat it 2) If you type hint an interface name in a function argument what sort of variables can you pass? 3) What is an abstract class? 4) How would you call the construct method of a parent class inside  a child of that class? 5) Given two variables $a and $b which c...

Reverse Engineering an MS-SQL database without Visio

The splash screen for Squirrel SQL I'm working on a project that draws from a Microsoft Sql Database.  Unfortunately there is no project documentation which means that it takes longer to become familiar with the design.  I particularly wanted an ERD of the database but this wasn't available.  So I looked for open source reverse engineering tools and found Squirrel SQL .  This is a very handy tool as it supports a variety of databases and client operating systems. Installing the Microsoft JDBC ( available from the Microsoft site ) was a snap: Just download the archive, extract it somewhere meaningful (I put mine as a directory in Squirrel). Edit the Microsoft SQL driver in your driver list Add an extra class and point it to the JDBC4 jar file (version 4 is required for newer versions of the JDK) The driver should load now Then proceed to add your connection alias per normal and you're connected to your MS-SQL database. The plugin to reverse engineer your dat...

Online file resizer

Kraken  is an online image compressing utility that compresses  jpeg, gif, and png formats using a new algorithm.  It claims that the compression on existing files can be losslessly improved. Does it work? I tried it on a random file on my hard-drive and the algorithm reduced the size from 853kb to 729kb (about a 14% reduction). Here is the original file (click to view full size): And here is the reduced file:

Screen capture in Android 2.2.1 "Froyo"

My Android Desktop snapped with this method I took a screen capture by mistake once but then struggled to repeat the behaviour.  After Googling for a solution I found some very complicated solutions.  Probably the best way to do this is to buy an application on the Market, but I don't want to spend money on a toy. If you look in your "Settings » Applications » Running Services" menu you should see a service called "ScreenCaptureService". This allows you to take a screenshot by pressing the "Back" and "Home" buttons simultaneously. What works for me is to press and hold "Back" and then to press and release "Home" (while holding "Back").  This makes a snapshot noise and displays a message.  Files are saved to the ScreenCapture directory on your SD card and should appear in your gallery. Of course this is a problem if you try to take a snapshot of a running application because pressing "back" c...

Listing event handlers tied to DOM elements with jQuery and Firebug

I'm busy hacking a template from an existing source to fit into a new Cake backend.  The template is pretty well written but I need to update the way in which content is being loaded and displayed.  Currently the site loads the *entire* site into one page and then flipping the visibility of elements in order to simulate dynamic loading.  Of course this works fine for the demo site the template loads, but is not going to fly for a production site. I ran into the problem of having to work out where the event handlers are being declared for various elements on the page.  I was faced with the task of trekking through 15 files of Javascript.  Okay some are obviously not candidates (like jQuery.js itself) but that's still a mission. Luckily jQuery has an extra bit of goodness that made the task trivial.  It stores event handlers in the data attribute (read up about that here  http://api.jquery.com/jQuery.data/  ). Using Firebug you can open y...

Caching your Twitter feed on your website in PHP

Instead of reinventing the wheel I'm going to copy the script found at css-tricks.com ( click here ) function getTwitterStatus($userid){ $url = "http://twitter.com/statuses/user_timeline/$userid.xml?count=1"; $xml = simplexml_load_file($url) or die("could not connect"); foreach($xml->status as $status){ $text = $status->text; } echo $text; } //my user id kenrick1991 getTwitterStatus("kenrick1991"); I'm leaving the original author's Twitter ID in there, but obviously you'll change this to yours. This function will retrieve the most recent Tweet from your feed (see the "count=1" variable in the URL). But it will request this every time the page loads. The most simple caching strategy is to write your Twitter status to disk, and when your page loads check the timestamp of the file against the value returned by time(). If it exceeds whatever threshold you deem appropriate you ...