Uncategorized | October 14, 2009

Radio Buttons in CakePHP the Right Way

<?php
$options=array('Business'=>;'Business','Consumer'=>'Consumer', 'Both'=>'Both');
$attributes=array('label'=>false, 'type'=>'radio', 'value'=>'Both', 'options'=>$options);
echo $form->input('who_to_include',$attributes);
?>

CakePHP, MySQL | October 8, 2009

CakePHP and Encoding Problems – Solves International and Word Special Chars

So, embarrassingly I have been putting up with this for years and just never could quite put a finger on how to handle it.  The situation is this: You have some sort of content management system (CMS) setup for your client that you have made homebrew (or not maybe).  You’ve painstakingly put time into security, format, ease of use, etc and you hand them the rains. Two hours later you get a call that they have some ‘weird code’ on their about page. You look and you realize they have copied and pasted some special chars from Word.  What to do?

Maybe this is the jerk way of handling it but I always had users copy and paste from word into a flat text file, then copy and paste into the form.  Or, I would use TinyMCE in the CMS and have their Cleaner plugin handle it. Most of the time that seems to work but not always. Today, I hit the wall on this problem with CakePHP and had to figure it out. Essentially, it all comes down to page and database encoding.

The short explanation: Set everything to UTF-8 at the beginning of your project. The long explanation (which is just a rehash of this awesome post at missingfeatures.com):

  1. Set your mySQL database up with UTF-8 encoding.  This includes:
    1. The database itself
    2. The tables
    3. Every field (watch out for this one in phpmyadmin because if you have already created your table you’ll need to specifically change the collation for all text, varchar, and char fields)
  2. In your layouts:
    1. Put this at the top:<?php header(’Content-type: text/html; charset=UTF-8′); ?>
    2. Put this in the head: <?php echo $html->charset(’utf-8′); ?>
  3. In your database configuration file (app/config/database.php):
    1. Add this to your default database array: ‘encoding’ => ‘utf8′

This puts everything on the same encoding plane and allows for characters like: ü ß ☠ ☮ ☯ ♠ Ω ♤ ♣ ♧ ♥ ♡ ♦ ♢ ♔ ♕ ♚ ♛ ⚜ ★ ☆ ✮ ✯ ☄ ☾ ☽ ☼ ☀ ☁ ☂ ☃ ☻ ☺ ☹ ۞ ۩

Uncategorized | September 2, 2009

Converting a Tire’s Size to Wheel Height

example

265/70R17

(2*({sidewall (ex: 265)}/25.4)*({ratio (ex: 70)/100))+{wheel size (ex: 17)}

JavaScript | July 31, 2009

Great Lightbox Comparison Table

This is a great comparison table for lightboxs that get you just what you need. Personally, I’m currently a prototype guy and go with lightbox++ 90% of the time. Next site I do I’m forcing myself to use some jquery to get more of a taste.

http://planetozh.com/projects/lightbox-clones/

Flash AS3 | July 29, 2009

Adding and Manipulating Sound in AS3

For some reason I had a really tough time finding a quick and easy tutorial on how to add a .mp3 to to an AS3 project and lower the volume.

First, import your .mp3 to the library and set a linkage classname.

Linkage Screenshot

Right click on the .mp3 you have imported to your library and select 'Linkage'. Essentially, this allows you to address the .mp3 as a class.

You can then address it with the following code:

var snd:neonstart4 = new neonstart4();
var sc:SoundChannel = snd.play();
var st:SoundTransform = sc.soundTransform;
st.volume = .2; // set to 20% volume
sc.soundTransform = st;

Uncategorized | July 23, 2009

Smarty crashing with JavaScript Curly Braces

If you ever need to use curly braces in a Smarty template use the following code:

{literal}
<script>// <![CDATA[
<!--
function getPrompt() {
// js function here
}
//-->
</script>
{/literal}

… or …

<script language="javascript">
<!--
function getPrompt() {ldelim}
// js function here
{rdelim}
//-->
</script>

Apache | July 22, 2009

Block Users During a Site Launch with .htaccess

Ever need to block everyone but you from seeing a site you’re working on.

RewriteEngine On
RewriteCond %{REMOTE_HOST} !^76.97.206.111
RewriteCond %{REQUEST_URI} !/maintenance\.html$
RewriteRule .* /maintenance.html [R=302,L]

Just remember to change the IP above with your IP so you can see what you’re doing! :)

Uncategorized | July 21, 2009

CSS Properties To JavaScript Reference Conversion

Found this uber-useful table for CSS -> Javascript conversions over at hardwar.org.  I copied it here because it was kinda buried and just in case it disappears.

CSS Property JavaScript Reference
background background
background-attachment backgroundAttachment
background-color backgroundColor
background-image backgroundImage
background-position backgroundPosition
background-repeat backgroundRepeat
border border
border-bottom borderBottom
border-bottom-color borderBottomColor
border-bottom-style borderBottomStyle
border-bottom-width borderBottomWidth
border-color borderColor
border-left borderLeft
border-left-color borderLeftColor
border-left-style borderLeftStyle
border-left-width borderLeftWidth
border-right borderRight
border-right-color borderRightColor
border-right-style borderRightStyle
border-right-width borderRightWidth
border-style borderStyle
border-top borderTop
border-top-color borderTopColor
border-top-style borderTopStyle
border-top-width borderTopWidth
border-width borderWidth
clear clear
clip clip
color color
cursor cursor
display display
filter filter
font font
font-family fontFamily
font-size fontSize
font-variant fontVariant
font-weight fontWeight
height height
left left
letter-spacing letterSpacing
line-height lineHeight
list-style listStyle
list-style-image listStyleImage
list-style-position listStylePosition
list-style-type listStyleType
margin margin
margin-bottom marginBottom
margin-left marginLeft
margin-right marginRight
margin-top marginTop
overflow overflow
padding padding
padding-bottom paddingBottom
padding-left paddingLeft
padding-right paddingRight
padding-top paddingTop
page-break-after pageBreakAfter
page-break-before pageBreakBefore
position position
float styleFloat
text-align textAlign
text-decoration textDecoration
text-decoration: blink textDecorationBlink
text-decoration: line-through textDecorationLineThrough
text-decoration: none textDecorationNone
text-decoration: overline textDecorationOverline
text-decoration: underline textDecorationUnderline
text-indent textIndent
text-transform textTransform
top top
vertical-align verticalAlign
visibility visibility
width width
z-index zIndex

Usage

Internet Explorer

document.all.div_id.style.JS_property_reference = “new_CSS_property_value”;

Older Netscape’s (4.7 and earlier)

document.div_id.JS_property_reference = “new_CSS_property_value”;

Netscape 6.0+ and Opera (and other Mozilla)

document.getElementById(div_id).style.JS_property_reference = “new_CSS_property_value”;

Note the use of parentheses instead of square brackets in newer Mozilla’s “getElementById()” reference.

Geocoding, MySQL | June 30, 2009

Professional GeoCoding Service

If you have more than a couple thousand records you want to geocode all at once we found a great service from USC’s GIS department that allows you to geocode records in an Access database.  It’s not terribly fast but we were able to geocode nearly 200,000 records in a couple of days. Just make sure your computer isn’t set to go to sleep an hour after you step away from the computer…. :/

https://webgis.usc.edu/Default.aspx

MySQL |

Deleting from multiple tables in mySQL

DELETE users.*, profiles.*
FROM users u, profiles prof
WHERE u.id = prof.user_id
AND u.created < '2009-01-01'
Older Posts »

Buy clomid online
Buy zovirax online
Buy cipro online
Buy nexium online
Buy diflucan online
Buy lasix online
Buy neurontin online
Buy synthroid online
Buy flagyl online
Buy nolvadex online

American Crime full movie The Deer Hunter download movie Practical Magic download movie The Great Escape download movie Empire of the Sun download movie Austin Powers: International Man of Mystery download movie Charlie Bubbles download movie The Deer Hunter download movie Practical Magic download movie The Great Escape download movie Empire of the Sun download movie Austin Powers: International Man of Mystery download movie Charlie Bubbles download movie