1 Nov, 2011
What is the difference between Decimal and Float datatypes in SQL? Well you can accomplish the same with both but there are advantages to each.
First off the syntax is quite different.
Decimal(total_length, length_right_of_decimal)
So you can see with decimal you may get more precision as it will never round. If you need some major finance calculations, decimal is the preferred route.
However if extreme precision is not needed and you have varying lengths of decimals, floats certainly make it easier.
31 Oct, 2011
Visual Studio is one of the most comprehensive IDE’s on the market and the 2012 version adds a heap of features to be discussed. Â The most interesting feature I’ve found was adding a “Google it!” button to visual studio error dialogs.
Clicking the Google It button launches a Google search in your default browser for the string of the error message. Â From there, generally trimming down the error message yields better search results, but this frees developers from copying and pasting, washing out the current contents of their clipboard and saves from rekeying error messages which cannot be copied and pasted.
Another interesting note is the button is a “Google It!” button and not a “Bing It!” button. Â Perhaps the Visual Studio team realizes that Google has better search than Microsoft; or, Bing hasn’t been around long enough to be used as a verb.
30 Oct, 2011
Updating to a new version of Expression Engine gets harder as the amount of version dependant Add-Ons increase. I just successfully updated an expression engine site that had version dependencies.
Tip: In most cases, when you buy an add-on you will receive both versions. It is important that you keep the original files. Just because your site is in EE1 now, doesn’t mean you will not need access to the EE2 files in the future… So make sure the account you use to buy and access your site’s Add-Ons are continually transferred to someone that can access them. If not, you will need to buy all the Add-Ons again, which can get pricey.
Some EE Add-ons that will not work with the update and my solutions:
1.) Field Frame Module - In EE1, this module was used to create custom fields for the data. The functionality of this module is now part of the core functionality of EE2.
If you also have the Matrix module installed, I had a lot of errors showing up. These were corrected by implementing the most recent versions of the Matrix Add On.
2.) Ngen field type - This was used together with the field frame module. After updating to EE2, just change the ngen file types to be the EE2 “File” field type that automatically comes with your new EE2 installation.
3.) Find and replace - The EE2 version of this plugin is Low Replace (template tag usage must update to new plugin)
4.) In Segments - The EE2 version of this plugin is Segment Search (template tag usage must update to new plugin)
5.) SL Google map - The EE2 version of this plugin is MX Google Maps. This one is a little more tricky to convert as MX google maps stores the long/lat values in it’s own table. This is unlike the SL google Map module that stores all data in one table field. The next version released will have more support in conversion steps, but until then you need to write your own script to update the tables.
30 Oct, 2011
I was a former Action Pack subscriber and recently signed up again. The main reason I hadn’t maintained my subscription to the action pack was it became more difficult to acquire. Â Microsoft has since made it much easier, requiring you take an intuitive 10 question quiz about the benefits of the action pack in order to get valid action pack (among other business requirements which are easily met by companies where the action pack is applicable).
There are two versions of the action pack — the solution provider version and the development and design version. Â Both provide exceptional value. Â Here are some of the features of each:
Microsoft Action Pack Solution Provider
- Three internal use software licenses for Windows 7, Windows Server 2008, SQL Server, Exchange, Sharepoint, SBS and more
- TechNet subscription
- Technical Support
Microsoft Action Pack Development and Design
- For those organizations who do software design and development
- Internal use software licenses for Windows 7, Windows Server 2008, SQL Server, Exchange, Sharepoint, SBS and more
- TechNet subscription
- Technical Support
- One limited MSDN subscription
Overall, the action pack is absolutely worth it, if not for the MSDN subscription alone. Â Our company is the appropriate size and was able to take immediate advantage benefits of the action pack well above the cost of the subscription.
19 Oct, 2011
I needed to take a day number of the year and be able to manipulate that to get other dates associated to it. Let’s take today, October 19th. This is the 292nd day of the year. We can convert this into Unix seconds:
$seconds = date('U',strtotime(date('Y').'-01-01 +'.(292-1).' days'));
As you can see it isn’t a completely obvious solution but it works as needed. Now since we have the timestamp, we could get the Monday before the 180th day.
$seconds = date('U',strtotime(date('Y').'-01-01 +'.(180-1).' days'));
$week_begins = date('Y-m-d', strtotime( 'Last Monday', $seconds));
16 Oct, 2011
This problem didn’t take a lot of time to figure out, but i did notice that I couldn’t find any blog post about this particular problem when in need of a quick answer.
Basically the problem was that when I made a template for an Expression Engine site, the channel I wanted was not showing up.
Turns out, when in the “channel management” page, the channel had an assigned status group other than the default “open/closed/pending”. Expression Engine templates are set to default only the posts with the status of “open”. < not an intuitive template setting if your semi-new to EE >
So, the fix was very simple. In the template file, have the channel set the status attribute to be the custom status that was created:
{exp:channel:entries status="customStatus"}
... content
{/exp:channel:entries}
15 Oct, 2011
I’m using this snippet to get the current url. It’s fairly thorough, and needed it for a WordPress plugin I’m working on for startup weekend.
function get_real_current_url() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
$pageURL .= $_SERVER["SERVER_NAME"];
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= ":".$_SERVER["SERVER_PORT"];
}
$pageURL .= $_SERVER["REQUEST_URI"];
return $pageURL;
}
4 Oct, 2011
The Google Maps API is heavily biased to xml but what if you’d rather get your markers in json from an ajax call? Since we will be using jquery for the call you will need to include the library into your page.
First set up the code that will serve the json. We will put this at /get_markers and will be using Kohana 3 but any code will work aslong as it returns json.
//get markers from database
$lastpoints=ORM::factory('markers')->where('timestamp','>',$this->request->post('date'))->order_by('timestamp','DESC')->find_all();
if($lastpoints->count() > 0)
{
echo json_encode( array_map( create_function( '$obj', 'return $obj->as_array();'), $lastpoints->as_array() ) );
}
Now we can grab that data and use it.
$.ajax({
type: "POST",
url: '/get_markers',
dataType: 'json',
data: 'date=' + dateText,
success: function(data){
locations.length = 0;
for (p = 0; p < data.length; p++) {
locations.push(Array(data[p].latitude,data[p].longitude,data[p].timestamp));
}
initialize();
}
});
In the example above we would be reloading only the new markers onto the map. If you would like the markers to just be added to the markers that are already on the map, you will need to remove the loop and the locations length reset in the success function and just have the array push. The initialize function is the code that sets up the map and is found in most examples and tutorials on the API.
Of course you will need to set the ajax call to an event.
2 Oct, 2011
The Microsoft technology Clickonce is technology that enables clicking a link on a website and installing software. It has been a component of the .NET framework since version 2.0. ClickOnce is similar to Java WebStart and GNU/Linux ZeroConfig.
ClickOnce is supported natively by Internet Explorer and Firefox via a Firefox plugin.
There is also a provision in the ClickOnce architecture to automatically update applications. Applications can be configured to check for updates automatically at startup or after startup. ClickOnce also provides API’s for further controlling the update process.
ClickOnce is enabled in the Visual Studio project settings area.
30 Sep, 2011
I needed to order a mysql result but in a somewhat custom way.
Say there is a field “id” and rows of values of 8, 4, 2, and 19.
SELECT `id` FROM `table_name` ORDER BY `id`;
This would obviously return the order: 2,4,8,19.
But what if you needed the 4 to be first and then order by integers?
SELECT IF(`id` = '4','0','1') AS `custom_order` FROM `table_name` ORDER BY `custom_order`;
This would return 4,2,8,19.
Simple and can be really helpful.