Richard Castera - Explorations in Software Development
Richard Castera - Explorations in Software Development
Browsing Category
Resources Scripts

Make IE8 Emulate IE7

May 6, 2009 No Comments

By now you should know about the official release of Internet Explorer 8. This is a huge milestone for the browser that most Web Developers have come to hate.

XHTML
1
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

MooTools – Free Syntax Highlighting Class

May 5, 2009 3 Comments

Lighter.js is a free syntax highlighting class developed with MooTools. It was created with the MooTools developer in mind and takes advantage of many of the Framework’s features. Using it can be as simple as adding a single script to your web page, selecting the elements you wish to highlight, and Lighter.js takes care of the rest.

All browsers supported by MooTools are compatible with Lighter.js. It’s possible that it may work with earlier/other browsers but these are unofficially supported. The official list is:

  • Safari 2+
  • Internet Explorer 6+
  • Firefox 2+
  • Opera 9+
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

WordPress – List the most recent comments

May 3, 2009 5 Comments

Easily list the most recent comments in a sidebar or a tab. The code below will list the 10 most recent comments. You can change the number displayed by changing the value of the variable, $intCommentLimit to list more or less comments

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
function getRecentPosts() {
    global $wpdb;
    $intCommentLimit = 10;
    $strSql = "SELECT DISTINCT ID,
                      post_title,
                      post_password,
                      comment_ID,
                      comment_post_ID,
                      comment_author,
                      comment_date_gmt,
                      comment_approved,
                      comment_type,
                      comment_author_url,
                      SUBSTRING(comment_content, 1, 50) AS com_excerpt
               FROM $wpdb->comments
               LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
               WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $intCommentLimit";
    $comments = $wpdb->get_results($strSql);
    $strOutput = "<ul>\n";
    foreach ($comments as $comment) {
        $strOutput .= "<li>" . strip_tags($comment->comment_author)  . " Says, <br>" .
                      "<a href="\""" .="" get_permalink($comment-="">ID) . "#comment-" .
                      $comment->comment_ID . "\" title=\"on " .
                      $comment->post_title . "\">" .
                      strip_tags($comment->com_excerpt) . " ...</a></li>\n";
    }
    $strOutput .= "</ul>\n";
    return $strOutput;
}
echo(getRecentPosts());
?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

PHP – Generate a random password based on length

September 15, 2008 No Comments

Here’s a quick function to generate a password. All you have to do is call it passing the length of your required password as an argument.

PHP
1
2
3
4
5
6
7
8
9
10
11
12
<?php
function generatePassword($intNumOfChars) {  
    if (is_numeric($intNumOfChars) && ($intNumOfChars > 0)) {
    $strChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
    for ($i = 0; $i < $intNumOfChars; $i ++)  {
        $strPassword .= $strChars[rand(0, strlen($strChars)-1)];
     }
    }
    return $strPassword;
}
?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

PHP – Truncate a string to a given length

September 9, 2008 No Comments

This is a function I use to display the ellipses when I want to truncate and display a summary of a larger body of text.

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
function truncateString($intLength = 0, $strText = "") {
    if ($intLength == 0) {
        return $strText;
    }
    
    if (strlen($strText) > $intLength) {
        preg_match("/[a-zA-Z0-9]{0, " . $intLength . "}/", $strText, $strNewText);
        return ($strNewText . "...");
    }
    else {
        return $strText;
    }
}
?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Get the filename from upload form using Javascript

August 8, 2008 11 Comments

I needed a way to access the filename of a file being uploaded or attached using the input file from a form. So, I created a nice little function to achieve this. Hopefully it comes in handy for someone.

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
<script>
function getNameFromPath(strFilepath) {
    var objRE = new RegExp(/([^\/\\]+)$/);
    var strName = objRE.exec(strFilepath);
    if (strName == null) {
        return null;
    }
    else {
        return strName[0];
    }
}
</script>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Javascript – Capitalize Each Word in a String

July 26, 2008 3 Comments

This is a great little function that I whipped up and use to capitalize every word in a string. I can’t tell you how many times I’ve had to use this. Hope you find it useful as I have!

JavaScript
1
2
3
4
5
6
7
8
9
<script>
function wordToUpper(strSentence) {
    return strSentence.toLowerCase().replace(/\b[a-z]/g, convertToUpper);
    function convertToUpper() {
        return arguments[0].toUpperCase();
    }
}
</script>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources

Brusheezy – index of Free Photoshop Brushes

July 22, 2008 1 Comment

Brusheezy is the place to share your free Photoshop brushes and other Photoshop-related resources. Here you can explore and discuss the creations of other artists from around the world, or just find that perfect little freebie for your next Photoshop project. Brusheezy makes it easy to explore thousands of resources created by artists from all over the globe. All the resources are free to download and, depending on the license, free to use in your projects.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources

Vecteezy – index of Free Vector Graphics

July 21, 2008 No Comments

Vecteezy is the place to share your free Vector Art and other vector-related resources. Here you can explore and discuss the creations of other artists from around the world, or just find that perfect little freebie for your next project. Vecteezy makes it easy to explore thousands of graphics created by vector artists from all over the globe. All the graphics are free to download and, depending on the license, free to use in your projects.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Datejs – An Open-Source JavaScript Date Library

July 21, 2008 2 Comments

Datejs is an open-source JavaScript Date Library. Comprehensive, yet simple, stealthy and fast. Datejs has passed all trials and is ready to strike. Datejs doesn’t just parse strings, it slices them cleanly in two.

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script>
// What date is next thrusday?
Date.today().next().thursday();
  
// Add 3 days to Today
Date.today().add(3).days();
  
// Is today Friday?
Date.today().is().friday();
  
// Number fun
(3).days().ago();
// 6 months from now
var n = 6;
n.months().fromNow();
  
// Set to 8:30 AM on the 15th day of the month
Date.today().set({ day: 15, hour: 8, minute: 30 });
  
// Convert text into Date
Date.parse('today');
Date.parse('t + 5 d'); // today + 5 days
Date.parse('next thursday');
Date.parse('February 20th 1973');
Date.parse('Thu, 1 July 2004 22:30:00');
</script>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Page 9 of 11« First...«891011»

About me

Hello, my name is Richard Castera. I have more than 12 years of experience architecting, implementing, leading and launching large scale, high performance software products in a fast-paced agile environment.

Popular Posts

Magento – Display new products on the home page

May 20, 2009

How to Fix “Internet Explorer Cannot Open the Internet Site- Operation Aborted” Error

May 9, 2009

PHP – Convert Array to Object with stdClass

July 5, 2009

Categories

  • Home Automation
  • Resources
  • Scripts
  • SEO
  • Thoughts
  • Web Server

Tags

Apache Apple Bash CSS Drupal Free home automation htaccess Java Javascript Magento PHP raspberry pi SEO SQL thoughts Wordpress

© 2019 copyright Richard Castera // All rights reserved