jquery php

Custom Google Maps Pin with Numbers or Letters on v3 API

I recently worked on a Google maps project that needed to have a typical list of locations with corresponding pins on the map.  There were a ton of recommendation for using the now deprecated google charts or layering custom InfoBoxes, etc..

While these would technically work, they are limited solutions.  After thinking about it for a while, I came up with a pretty simple solution that works well for the project.  Basically, it’s just rolling your own light Charts tool..

To start, make a transparent PNG as your pin background – here is the one for this project:

Next, load a very simple PHP (or any language) script (im calling mine mappin.php) that renders simple text on top…


// Import the image to use $originalImage = "mappin.png";
$im = imagecreatefrompng($originalImage);
imagesavealpha($im, true); // important to keep the png's transparency
$black = imagecolorallocate($im, 0, 0, 0);
$width = 36; // the width of the image
$height = 36; // the height of the image
$font = 12; // font size
$digit = $_GET['id']; // digit
$leftTextPos = 15 - (strlen($digit)*3);
imagestring($im, $font, $leftTextPos, 6, $digit, $black);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);

See where this is going?

Next up, in my google maps generation, I add a custom pin with the url “/mappin.php?id=1″ – where 1 is your count iterator..


var image = new google.maps.MarkerImage('/mappin.php?id=' + $(this).attr('data-count')...

Obviously, this isn’t the full code – at some point I may package it all up with the code – but, if you are messing with custom map pins, I hope this helps.

General Internet Stuff php

IIS PHP cURL Authorize.net SSL

I’ve been working on a checkout system for a client site… Everything works well on our local and dev servers, but when we launched to the production box, which happens to be IIS, the checkout bombs.

After digging, cursing, googling, complaining to the ISP, etc… I finally found out that apparently, IIS windows servers do not verify the connection… In fact it times out if you try to.

So, im posting this to help save someone else hours of frustration…  In your cURL call to an https url, you just need to add the following

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //

Personalized User Vanity Url’s in Codeigniter

General Internet Stuff

Asinine Publishers Killing Kindle and other E-Books

I know this has nothing to do with programming, but this is one of those things that drives me crazy. I have a Kindle, I love my Kindle, I love reading before bed on My Kindle, then picking up where i left off on my Droid when I’m standing in line at Disney.

Unfortunately, I think that e-books will not make it. At least not without some major changes in publishers attitudes. A while back, Amazon started letting publishers (not by choice) set pricing for Kindle editions. Now, In my pessimistic point of view, they are beginning to strategically kill the media.

read more »

codeigniter

Personalized User Vanity Url’s in Codeigniter

This may seem an obvious solution, but after doing some digging, i didn’t find anyone else writing about it.

What I tried to accomplish was personalized urls like http://www.site.com/philpalmieri.  First i tried to use a pre_controller hook, but the url was being interpreted to quickly…  So i came up with a simple solution – hopefully it can help someone else out.

First step is to create an ‘aliases’ controller (and module if you are using them)..  Create a method in the aliases controller – something like check()… This is what we will be passing the personalized url to to figure out what to do.

How this works is that we check for any modules or controllers that would normally be called in uri->segment(1).  Then, dynamically account for each one in your routes file….  finally, we route everything else to aliases/create/*

So.   for the code

add & customize the following to your routes file (before any other custom routes).

$handle = opendir(APPPATH."/modules");
while (false !== ($file = readdir($handle))) {
  if(is_dir(APPPATH."/modules/".$file)){
    $route[$file] = $file;
    $route[$file."/(.*)"] = $file."/$1";
  }
}

/*Your custom routes here*/

/*Wrap up, anything that isnt accounted for pushes to the alias check*/
$route['([a-z\-_\/]+)'] = "aliases/check/$1";
codeigniter matchbox & modular extensions php

Codeigniter Simpletest Modular Extensions Suite

Update…

I am still having issues with MB  - and apparently others are too view thread.  So, I am once again switching back to HMVC / Modular Extensions.. With that switch I am also converting the Simpletest module as well as my Tag and Template libraries over as well..

I’ll release them soon (this month…. really)

—-

So, I am primarily writing this pre-post as incentive for myself to have a deadline and accountability.

After reading Jaime Rumbelow’s post on Codeigniter and Simpletest I realized I needed a way to do TDD in my Matchbox modules without having to set everything up each time.

I have an almost ready matchbox simpletest module that scans other modules for tests and auto runs them.   Each module you want to build with TDD only needs to contain its tests (which can  run on their own by loading the simpletest lib from the simpletest module) or can be auto loaded in batch from the main simpletest module.

If you are interested in helping me beta test, let me know – i plan to release a beta somewhere around Feb 1.

General Internet Stuff wordpress

Moved to Mediatemple

As of today, this site is now hosted on MediaTemple’s GS!

I found a coupon code online for 20% for life, so now i’m only paying $16/month for all my personal hosting needs (up to 100 domains). The admin panel and server are surprisingly fast and easy to configure too.

I know a few people who weren’t happy with the GS when it first came out, but so far so good.

To migrate over this site, i just shelled in and rsynced my www folder (took about 1 minute – including my personal large uploads folder). Then, just turn on the database, tweak the wp-options and I was online.

If you are considering a new, inexpensive, reliable host, i would highly recommend them.

codeigniter php

CodeIgniter Textmate Bundle

I Know this is a few days old already, but its just too good of a tool to not post in as many places as possible.

There is now a CodeIgniter Textmate bundle avaialable! If you are like me, you have a bunch of snippets already available for common CodeIgniter code. Well, David Ferguson wrote a CodeIgniter Textmate bundle that has snippets and shortcuts for every helper and class available in 1.7.2

jquery

jQuery Plugin/Widget Quick Screencasts

I have been toying with the idea of putting up a series of 5-10 minute screencasts.  To start I am going to focus on the default jQuery UI widgets, and then pick and choose the most commonly used plugins. Although the widgets are pretty self-explanatory the documentation may be confusing to a new jQuery user in regards to settings, effects, or anything beyond the default demo.

I am going to start with the simple defaults of Tabs or Dialog, then go in depth with effects, and different options and uses for the widget(s).

Which of these jQuery UI Plugins / Widgets would you be interested in seeing a screencast on?  (select as many as you would like, or add your own answer from a 3rd party plugin)








codeigniter matchbox & modular extensions php

Matchbox is Back! So Long Modular Extensions…

So, for once, my procrastination has paid off! A while back i was complaining, in the most polite way of course, about the lack of development of matchbox. A few days ago Zacharias released Matchbox RC1.  He completely re-wrote it from the ground up and has made it 100% compatible with the latest Codeigniter release.

I downloaded the release candidate from http://codeigniter.com/wiki/Matchbox/, dropped it into a new branch of some projects that use the old version, and was off and running.

As i play with it more i plan to release some of our code like the AMFPHP library as self contained modules that can be dropped into an application.

Thanks again to Zacharias for all your hard work.

Phil

codeigniter mysql php

Snow Leopard / MAMP Pro mySQL woes

After wiping my computer and installing 10.6 from scratch, my local php/mysql would not work at all.  The biggest problem was that I was receiving an error when trying to connect to mySQL “Lost connection to MySQL server at ‘reading initial communication packet’, system error: 61″.

It turns our that in MAMP Pro 1.8, they left out the local bind-address declaration, which for some reason freaks out the default PHP/Apache setup.

So, if you are running Snow Leopard and MAMP Pro and can’t connect to your mySQL, it’s an easy fix.  In MAMP Pro edit your my.cnf template (File > Edit Template) .  Add this line somewhere after the “[mysqld]” declaration (and reload) – Everything should be good.

bind-address = 127.0.0.1