10
Jan
2012

New site, new year.

Well its a start of a new year. What better way than start it off than a new design. I am slowly working on the design of the site as I have time. So keep checking back for more updates.

15
Oct
2011

Posting JSON with jQuery and PHP

After looking around the net some, and having this issue before, I decided to put this up for anyone who might be having the same trouble as I once had. Posting JSON with PHP can be a bit tricky if it’s your first time doing this.

So for starters, lets download some scripts we’ll need to make this work.

  • https://github.com/douglascrockford/JSON-js/blob/master/json2.js
  • http://code.jquery.com/jquery-1.6.4.min.js

json2.js

This file will be used for taking a javascript object and converting it to a string.

jQuery

This is my javascript library of choice. So for this example I will be using this.

Javascript Time!

So lets get our hands dirt with some javascript. Here is a simple AJAX post using javascript and using the JSON.stringify to convert our object to a string so we can post it. While I don’t actually show it. Make sure to include the json2.js file and in this case, jQuery on the page.


// Declare a variable
var jsonObj = {demo: 'this is just a simple json object'}

// Lets convert our JSON object
var postData = JSON.stringify(jsonObj);

// Lets put our stringified json into a variable for posting
var postArray = {json:postData};

$.ajax({
    type: 'POST',
    url: "http://somedomain.local.com/phpfile.php",
    data: postArray,
    success: function(data){
        // Do some action here with the data variable that contains the resulting message
    }
});

PHP in The House

In our php file, we can process the post variable. First we check and see if we actually have post variable. Next, we need to strip the slashes out of the string which were put in for transport. Then we just run the json_decode php function. After that we can access the php object and use it however we like.


if(isset($_POST["json"])){
    $json = stripslashes($_POST["json"]);
    $output = json_decode($json);

    // Now you can access your php object like so
    // $output[0]->variable-name
}

This is a pretty basic and watered down example but hopefully it will help you.

29
Jul
2011

Posting form data with Curl

So this is something I struggled with for whatever reason. Taking form data that  was posted and re-posting to another server. I am just going to post up the code first and then kind of step through it.

$ch = curl_init();

// Lets setup the data we need to pass
$postValues   = array('postedData' => $someArrayOfData);

// define the URL for upload file
curl_setopt($ch, CURLOPT_URL, 'http://yourdomain.com/api/somefile.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postValues);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
$response = curl_exec($ch);
curl_close($ch);

header ("Content-Type:text/xml");
echo($response);

So basically what is happening is at first we build an array of all the values we want to post. Then we pass that variable into the config for Curl. At that point we set, the URL, and the “RETURNTRANSFER” setting, letting Curl know we want any response back from the server that we posted to. Once that is done, we can just set the header and echo out the results, or we could pass that info back into a variable to be used elsewhere.

While this is pretty brief, it was more so just to get a couple thoughts down for myself. if you have any questions though, please feel free to leave a comment or jsut email me.

28
Jul
2011

Still around…

Been so damn busy the past 3 months, I almost forgot I have a website!

I have a ton of things I should add on here but I keep forgetting. I will try to add some new things soon.

Ok, back to working, or sleeping I guess.

8
Apr
2011

CSS word-wrap on a legend

Legend elements are extremely tricky to get styled right across browsers. I’ve come across the issue on several occasions where I need the text inside the legend to wrap lines when it’s too long. Here is an example:

<fieldset>
  <legend class="someclass">Some text that needs to wrap because its too long.</legend>
</fieldset></code>

All we need to do now is just wrap the text inside the legend within a span tag like so:

<fieldset>
  <legend class="soemclass"><span>Some text that needs to wrap because its too long.</span></legend>
</fieldset>

Add some css to target the span:

legend.someclass span {
  word-wrap: normal;
  white-space: normal;
}

That’s it!

15
Dec
2010

Shelby GT500 Fog Light Replacement Bulb

This is more of a post to myself so I have someplace to keep it, but if you are looking to replace a burnt out fog light bulb on your 2007-2009 Shelby GT500 then this might come in handy for you.

The bulbs are completely different from the regular Mustang GT, so if you go into AutoZone, their little computer will tell you that you need a 9145 Light bulb which is incorrect. As far as I know you can only get them from Ford for like $30 a piece.

Part Number: 8L8Z-13N021-A (One Bulb and Socket Assembly)

If anyone else knows of where to get replacement ones besides Ford, please let me know.

26
Oct
2010

Migrating Coda from one Mac to another.

So you use Panic Software’s Coda for all of your web development. Trouble is you just bought a shiny new Mac and you want to transfer over your sites. Well fear no more. Just locate the following file…

/Users/YOUR-USER-FOLDER/Library/Preferences/com.panic.Coda.plist

Then on your new Mac, make sure you have coda installed. Then copy the com.panic.plist file to the same location you found it, but on the new machine, and then you are all set.

30
Sep
2010

LESS Syntax Highlighting in Coda

UPDATE: Over at http://goo.gl/sn74C, someone has created a plugin for LESS in Coda that has more features than mine. I haven’t checked it out yet but it looks promising.

First of all, LESS is insanely awesome to use on large sites that require thousands of lines of css. I’ll let a snippet from their site explain it a little better.

LESS extends CSS with: variables, mixins, operations and nested rules. Best of all, LESS uses existing CSS syntax. This means you can rename your current .css files to .less and they’ll just work.

So back to the syntax highlighting. I wanted to use LESS in Coda and have all the CSS syntax highlighting to work correctly. After a little Google searching I found the easiest solution was just to copy the “CSS Mode” out of the actual app and rename it so it works for LESS.

So in an effort make my life easier and hopefully yours I am hosting it up here for download.

LESS Syntax Highlighting for Coda Version 1.0 (Just fixed it so it doesn’t overwrite the CSS in the syntax option menu)

Installation:

Just download the zip, unzip it, and copy the “Less.mode” folder to /Users/YOURUSERNAME/Library/Application Support/Coda/Modes.

22
Sep
2010

Google Chrome crashes form submit with auto-fill on.

At work today we ran into a unique issue with Google’s Chrome web browser. With auto-fill turned on, and submitting a web form, it would cause the browser to crash instantly as soon as you pushed the “red button” to submit the form.

To handle this issue it took some web surfing and a little help with fellow co-workers. Turns out there is a bug with Chrome and the auto-fill functionality in the browser. To combat this problem you have to set a autocompelte attribute on the form input to disable Chrome from even turning on the “auto-fill” feature in the first place.

<input name="input-field" type="text" autocomplete="off"/>

Once we made this change, no more crashing!

Special thanks goes out to Travis from work.

3
May
2010

New Site

Working on getting a site back up to use finally. Its been a while. This isn’t my design, but right now I just wanna focus on getting some of my information up instead of worrying about some of the details. More to come!

flickr

    • IMG_3484
    • IMG_2167
    • IMG_2163
    • IMG_2154
    • IMG_2153
    • Moon & Lake
    • Getty

twitter