Get distinct (unique) month and year of records in a mysql table

February 16, 2012 by · Leave a Comment
Filed under: Code Snippets 

Here is a quick snippet to pulls the month and year from any date field in a MySQL table…

SELECT DATE_FORMAT(date_added, '%b %Y') AS sDate, COUNT(post_id) AS iCount FROM blog_posts GROUP BY sDate ORDER BY sDate DESC
sDate iCount
Jan 2012 4
Dec 2011 16
Nov 2011 0
Oct 2011 12

Mostly for my reference, but hope it helps someone else ;)

Reset Gallery3 Admin Password using phpMyAdmin

January 27, 2012 by · Leave a Comment
Filed under: Code Snippets 

Just a quote note in case I need to find it again later…

If you forgot your admin password for Gallery3 by Menalto, open the users table via phpMyAdmin and replace the existing encrypted password with the following.

$P$DyhWrqfmMF/XKPf3CtPn0pIQDZpQKu

Now, you can log in using 12345 as the password. Make sure you change this immediately after logging back in!

Horizontal icon (footer) layout for Facebook chat contacts window… kind of like the Mac OSX app bar

January 19, 2012 by · Leave a Comment
Filed under: Code Snippets 

If you came here looking for the code, that will be a bit further down the road. Here is the plan…

Take this…

Note: The above screen has my hide offline users mod applied ;)

And make it look more like this…

This is a “for fun” project and will be completed as time permits. So check back soon for progress updates.

 

Hide offline contacts from Facebook chat

January 18, 2012 by · Leave a Comment
Filed under: Code Snippets 

If you’re like me, you stay logged into Facebook throughout the day. I work online so this is not uncommon.

One thing I have always hated is that there are no preferences for how you want to filter that list. Personally I find it pointless to show you offline contacts in an instant chat interface. I know some people use it to leave messages, but I am not one of them.

Assuming you know how to modify your browser’s custom style sheet, this is all you need to add and those offline users will no longer be visible!

.fbChatOrderedList li.item,
.fbChatOrderedList li.separator {
    display: none !important;
}
.fbChatOrderedList li.active,
.fbChatOrderedList li.mobile {
    display: block !important;
}

Feel free to post questions, comments or even improvements.

IMPROVED: Open all external links in a new window using jQuery

January 17, 2012 by · Leave a Comment
Filed under: Code Snippets 

In the original post I covered how to use jQuery to automatically make external links open in a new window. The method however was slightly flawed in my opinion since…

  1. It did not check form action attributes
  2. It assumed ANY link starting with “http[s]://” was external

Here is my new and improved method for making all external site links open in a new window. It now includes form tags, one less selector for secure and non-secure link urls, AND excludes any of those which link to an internal page where the full url may have been specified.

$('a[href*="://"], form[action*="://"]').not($('a[href*="://'+location.host+'"]')).attr('target','_blank');

A quick breakdown…

  1. a[href*="://"] and form[action*="://"] matches the elements where a full url has been specified
  2. .not($(‘a[href*="://'+location.host+'"]‘)) excludes all matched items that include the current host (eg: http://www.robertmullaney.com/)
  3. finally we update the target attribute of the the remaining links open in a new window

Why this is important:

Once you have a user on your site, the worst thing you can do is send them away. Also, you will easily annoy them if all links open in new windows and cause them to leave anyhow. This way, only the links that pull them away from site site are opened in new windows. When they are done on the external sites, they close the browser and there your site remains.

Next Page »

  • Pages

  • Categories

  • Contact Me

    Your message was successfully sent.
    Thank You!