Setting Default Slider Value – jQuery UI

Had a bit of a muck around with jQuery sliders today, just though I’d post the code I used to set a default value in case anyone else has a use for it:


//Create sliders
$(document).ready(function() {
   $(".slider").slider("option", "value", 100);
});

Just sub whatever you want your default slider value to be in place of the 100. The jQuery documentation is also pretty useful if you’re chasing any more info: jQuery Slider Documentation

Cheers

Copying Text from Notepad++ to Microsoft Word

In the middle of doing up some documentation I realised that the formatting and colors aren’t kept when you copy and paste from Notepad++ to Microsoft Word. Luckily Google was able to help out by showing me default plugin that lets you keep all the syntax highlighting etc.

1: Hightlight any of the text you want copied
2: From the menu select Plugins > NppExport > Copy all formats to clipboard
3: Paste into Microsoft Word
Highlight code
Highlight code
Select NppExport
Select NppExport
Paste in Word
Paste in Word

And that’s it – all done!

How to Edit a Message Catalog Definition – PeopleSoft

Editing a message catalog definition in PeopleSoft is pretty straight forward, simply browse to the following menu path:

PeopleTools > Utilities > Administration > Message Catalog

Enter your message set number into the prompt. Note that if you do not know your message set number you can use the following to find it:

SELECT *
FROM PSMSGCATDEFN
WHERE MESSAGE_SET_NBR = '12345'
      AND MESSAGE_NBR = '12345';
      
SELECT *
FROM PSMSGCATDEFN
WHERE MESSAGE_TEXT LIKE '%what your message is%';

Once you have your message simply edit the text and description appropriately then save!

Error when trying to Edit a SharePoint Document – SharePoint

Ran into the following error when trying to open a word document stored on SharePoint today:

The document could not be opened for editing. A Microsoft SharePoint Foundation compatible application could not be found to edit the document.

Unfortunately this appears to be an issue with Chrome, once I switched to IE it all worked fine.

Uncaught TypeError: Object # has no method ‘toggle’ – jQuery

Ran into a bit of a problem with jQuery today, not entirely sure what the issue was but apparently it did not like me using the .get() function. I received the following error:

//Enable toggling of sub_order display
$(document).ready(function() {
    $('.expanding_header').click(function(){
      $(this).find('.expanding_content').get(0).toggle('slow', function() {
      });
    });
});
Uncaught TypeError: Object # has no method ‘toggle’

By substituting the get function with a :first selector the error does not occur:

$(document).ready(function() {
    $('.expanding_header').click(function(){
      $(this).find('.expanding_content:first').toggle('slow', function() {
      });
    });
});

Flash Notice Appearing Twice – Ruby on Rails

Ran into another flash notice issue, my messages were not disappearing after the first view. My code was as follows:

#Create flash warning
flash[:warning] = ("This product has been replaced: " +new_product.title + "").html_safe

It turns out that all you have to do to fix this issue is the following:

flash.now[:warning] = ("This product has been replaced: " +new_product.title + "").html_safe

This blog gives a brief overview of when to use flash.now[notice] and when to use flash[:notice]. A basic rule of thumb is that if you’re using a redirect, use flash[:notice], if you’re simply rendering a view, use flash.now[:notice].

Sleep Function Within PeopleCode – PeopleSoft

While at work today I discovered that there doesn’t appear to be any built in functionality to allow for a delay to be implemented within PeopleCode. Thankfully there are a couple of roundabout way you can go about doing this:

#1: Works if you are sitting on an Oracle DB

/* The following code creates a 5 second delay using DBMS_LOCK.SLEEP */
&s = 5;
SQLExec("exec DBMS_LOCK.SLEEP(:1)", &s);

#2: Note that this method is not as efficient as DMBS_LOCK.SLEEP()

/* The following code creates a 5 second delay using the java sleep method */
&s = 5;
GetJavaClass("java.lang.Thread").sleep(1000 * &s);

Validating Boolean Value of False in Rails

I came across a bit of a weird one this afternoon when trying to validate. Several of my fields appeared to be incorrectly flagged as not having a value.

This is the validation I was using:

#Define validation
validates :order_id, :user_id, :acknowledged, :completed, :presence => true

 

The fields that were flagging as not present were :acknowledged and completed. After hardcoding the values and still not getting anywhere I realised that while values were being provided, they were boolean values of false. Apparently :presence will treat a value of false as not being present.

After another Google search I came across this post which shows how to validate a boolean value.

When implemented within my app, the new validation looks like this:

#Define validation
validates :order_id, :user_id, :presence => true
validates :acknowledged, :completed, :inclusion => {:in => [true, false]}

Hopefully that’ll be able to help a few of you out as well.

link.smartscreen.live.com – Google Analytics Referral

Well, today I was looking through the Google Analytics overview of the WhatIBroke.com and I noticed a referral I hadn’t seen before from link.smartscreen.live.com.

I did a bit of Googling and it turns out that this is actually something Microsoft uses within IE and MSN. Apparently, whenever someone clicks on a link in msn the service will check the link against a list of unsafe sites and warn the user if anything is amiss.

It just so happens that I’d sent a link to the blog to a friend on msn – so I guess everything checks out. Here’s a bit of a blurb from the FAQ on Microsoft’s Site:

SmartScreen Filter is a feature in Internet Explorer that helps detect phishing websites. SmartScreen Filter can also help protect you from downloading or installing malware (malicious software).

SmartScreen Filter helps to protect you in three ways:

As you browse the web, it analyses webpages and determines if they have any characteristics that might be suspicious. If it finds suspicious webpages, SmartScreen will display a message giving you an opportunity to provide feedback and advising you to proceed with caution.

SmartScreen Filter checks the sites you visit against a dynamic list of reported phishing sites and malicious software sites. If it finds a match, SmartScreen Filter will show you a warning notifying you that the site has been blocked for your safety.

SmartScreen Filter checks files that you download from the web against a list of reported malicious software sites and programs known to be unsafe. If it finds a match, SmartScreen Filter will warn you that the download has been blocked for your safety. SmartScreen Filter also checks the files that you download against a list of files that are well known and downloaded by many Internet Explorer users. If the file that you’re downloading isn’t on that list, SmartScreen Filter will warn you.

 
Anyway, that’s all I’ve got for now – Good Luck!
 

Errno::ECONNREFUSED in – Ruby on Rails

First problem of the morning – Errno::ECONNREFUSED in ProductsController#create. This one was actually a little bit tricky – for me anyway. The error seemed to imply a database issue, so I started by checking all the common problems there however no luck unfortunately.

After a bit of a Google I came across a post mentioning that a few people had encountered this after installing Solr. I had previously setup Sunspot, which just so happens to sit on top of Solr.

Manually starting solr fixed the problem – just using the code below:

chris@chris-VirtualBox:~/site$ rake sunspot:solr:start

 

I’m not really sure what triggered the error as I’d been using the exact same functionality all morning without any changes or issues. Thankfully it’s a quick fix. If anyone has anymore info on the problem please let me know.

Anyway, that’s all I’ve got for you for now, Good Luck!

UPDATE: I had this problem again this morning and realised that it was the models with search fields still defined that were triggering the error. Removing this code seems to have completely resolved the issue.