iOS8 Set Navigation Bar Colors

Just posting this here as more of a personal reference but, hopefully this will help someone else as well. Basically I was trying to set the title color, nav text colors and the background of the main navigation bar.

// This sets the background color of the navigation
[[UINavigationBarappearance] setBarTintColor:[UIColorcolorWithRed:(32/255.f) green:(152/255.f) blue:(202/255.f) alpha:(1.0f)]];

// This sets the text color of the navigation links
[[UINavigationBarappearance] setTintColor:[UIColorwhiteColor]];

// This sets the title color of the navigation bar
[[UINavigationBarappearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColorwhiteColor]}];

Here is a quick screenshot of the navigation bar with the above set:
ios-navigation-bar-colors

CAUTION: Provisional headers are shown, Chrome on OS X Maverick

I cam across this issue recently when working on a Angular JS app and trying to hit a locally running api.

I was accessing my Angular App at http://developer.domain.local which in turn was hitting a development version of my restful api at https://api.domain.local. This was giving me the “CAUTION: Provisional headers are shown” error when making requests to the API. To solve this I had to run Chrome with web security disabled.

To do this, go to terminal on OSX

open -a Google\ Chrome –args –disable-web-security

Thats it, this should allow you to develop locally. Just remember to completely close the browser once done and reopen when you’re back to your regular web activities.

  • 3 - Z687U7P
  • 4 - PshDIDB
  • 5 - MbBVVqq
  • Rocker Replacement
  • 10 - bRS9zPQ
  • 11 - jTErEK8
  • Rocker Replacement
  • Rocker Replacement
  • Rocker Replacement
  • Rocker Replacement
  • Rocker Replacement
  • 1 - 8cUrNTd
  • 2 - ks0jPrs
  • Rocker Replacement
  • Rocker Replacement

SVT Contour Rocker Panel Replacement

These are some pictures of the process I took when replacing the rocker panels on my 1999 SVT Contour.

Git error on ‘git add’ on OS X 10.8.1

So you get the following error:

error: insufficient permission for adding an object to repository database .git/objects

Something has happened to the .git directory within your repository and the database can not be written to. So to fix this do the following command inside your repo.

sudo chown -R  username:staff .git/

Note: Change username to your OS X username.

Google Maps API v3 – Fit map bounds to all markers

This is a basic example of how to use google maps api v3 to fit a map’s bounds to all of the markers on the map. It’s almost an exact copy from Alexis Bezverkhyy’s site. I basically put this here for my own use, but hopefully it helps you out.

// Lets create our map
function initMap() {
    //...
}

// Setup markers
function initMarkers() {
    //...
}

var map;
var bound = new google.maps.LatLngBounds();
var markers = new Array();

// On dom ready, lets set things up
$(document).ready(function() {
    initMap();
    initMarkers();

    // Lets loop through the markers and get it's position and extend the bounds of the map
    for(var i in markers) {
        bound.extend(markers[i].getPosition());
    }

    // Now set the bounds for the map
    map.fitBounds(bound);
});

Simple Engine

So one of my pet projects is Simple Engine. Its kind of a cross between wordpress and static html files. It allows you to do nice seo urls and manage a global template, so making changes is not a pain. Anyways check it out, let me know what you think. It’s helped me with several sites big and small.

 

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.

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.

Lion on Rails

So I am always interested in working on a rails app, but I always run into the same issues. Hosting. I am hoping with my little know how, and my awesome abilities are hacking the the English language to pieces I can help guide you through setting up a rails environment on your OS X machine.

So for my setup, I am using a new Mac Mini with 8GB of Ram running Lion. Hardware requirements are not that important though, so even if you have a 5 year old machine, you’re good to go. We’re programing, not trying to play Crysis.

Here are a couple things you need to download.

Pow

http://pow.cx/

Is a self contained enviroment for running ruby on rails applications.

Powder

https://github.com/Rodreegez/powder

It is used for turning off and on POW with ease. This is especially helpful if you are wanting to run MAMP as well, since both of these apps like to play with your port 80 and hosts file.

Xcode

http://itunes.apple.com/us/app/xcode/id448457090?mt=12

Download and isntall the latest version of Xcode as we will need this to update your ruby version locally.

I ran out of time to finish this write up tonight, but I should be able to finish it over the course of this week. So check back here for a completed version soon.

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.