Archive for Uncategorized

Flash Builder: How to Add a Spark Group Background Color

Ideally, things would be a lot simpler if spark groups had a background color property that could be set.  But of course, that is not the case in Flex / Flash Builder.  However, there is a minor work around that one can follow to obtain background colors for spark groups.

<s:Group>
    <s:Rect width="100%" height="100%">
        <s:fill><s:SolidColor color="0x336699" /></s:fill>
    </s:Rect>
    <s:VGroup>
        <s:Label text="group content..." />
        <s:Label text="group content..." />
        <s:Label text="group content..." />
    </s:VGroup>
</s:Group>

Since vgroup doesn’t have a background color property, you can make a rectangle behind it to have desired background properties.  Flex also isn’t very functional with rectangles unless they are in a group of some kind. (i.e. in a scroller tag)  So that is why it’s best to wrap both the rectangle and the vgroup in a regular grouping segment. (same applies to hgroup, tilegroup, and other sparkgroups)

*NOTE: Put the rectangle first.  Otherwise the rectangle will be covering the spark group before it.  In flex, the last element being produced is placed in front of the previous item.

Getting and updating a wordpress post from permalink

We’ve been working on a plugin and we needed to get a wordpress page from a given permalink. This is actually done pretty easily since there is a function wordpress uses deep in their system.

$post_id = url_to_postid($permalink);

This will give you the post_id which you will able to use to retrieve the post object.

$post = get_post($post_id);

Now that we have the object its pretty simple to manipulate it.

$post->post_content = $new_page_content;
wp_update_post( $post );

So all together:

$post_id = url_to_postid($permalink);
$post = get_post($post_id);
$post->post_content = $new_page_content;
wp_update_post( $post );

Updated Freeform Module in Expression Engine 2 No Longer Creates Entries

Having started out with a lovely expression engine buildfound yourself needing to upgrade to the newest version of Freeform. A lot of the time this will update correctly with no errors.

However, in cases like mine, it has been perfectly described as:
“I’m getting no entries entered into my Freeform control panel, no notification email, and the redirect goes to the home page.” (source)

The solution is more than likely having to do with your htaccess file. Reading the above linked forum conversation, it appears that with this version of Freeform, your .htaccess cannot have a  rewrite command to redirect non ‘www’ requests to the ‘www’ version.  There is a work around that I used located here.  Cheers!

The difference between Decimal and Float SQL datatypes

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.

Float(char_length)
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.

Visual Studio 2012 Google It! Feature

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.

Upgrading ExpressionEngine 1.7 to 2.3.1 Notes

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.

Why Should I Buy the Microsoft Action Pack?

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.

Using day number for date manipulation in PHP

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));

Channel Content Not Appearing in Expression Engine Template

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}

PHP Get Real Current URL

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;
}