Archive

Archive for the ‘.CodeSlayer’s Posts’ Category

Windows 8 won’t wake up from sleep mode & Power Off goes into sleep mode after BIOS update

January 31, 2014 Leave a comment

windows 8

 won’t wake up from sleep mode – Microsoft Community.

Apparently this is a common issue with Windows 8. Here is what I know from my own experience:

windows 8 won't wake up from sleep mode - Microsoft Community

  • It does not help to upgrade to Windows 8.1
  • No Windows Update has fixed this issue
  • The problem seemed to start about 2 months after I bought the laptop, after a BIOS update (update must have been around October 2013).
  • Tech support was not able to fix it, even after trying different driver configurations and a BIOS rollback.

They want me to send it in, but I have online classes and need my laptop until  April. Guess I’ll try to see if disabling sleep mode fixes these issues.

-CodeSlayer2010

Advertisements

Merge and Combine Multiple PDFs Into One Document wit PDF Binder

January 9, 2014 Leave a comment

PDFBinder - A simple tool to merge several PDF documents into onepdfbinder – A simple tool to merge several PDF documents into one – Google Project Hosting.

A great free tool for combining multiple pdfs into one. Allows you to change the order before combining.

Google Docs spreadsheet script: compare dates, highlight past dates, highlight weekends, and highlight today

October 30, 2013 Leave a comment
screenshot of Google spreadsheet with 3 custom highlighting functions applied

A Google spreadsheet with my 3 custom highlighting functions applied

ORIGINAL PROBLEM

I spent hours tonight struggling with this Google Apps script I wrote to serve as custom functions or advanced macros. I adapted it from this StackOverflow post. The main issue I ran into was comparing dates. Here is my research path, and hopefully, some indicator as to why it took so long:

STEPS and MISSTEPS TAKEN TO SOLVE

  • Looked for built-in function in Google spreadsheet to do conditional formatting on weekends. No weekend selector and no built-in way to conditionally format the whole row based on the contents of one cell. (time: 35 min)
  • Discovered the only way to do this was to write a Google Apps script. I’ve never heard of Google Script until today. Now I had to look up basic Google Script tutorials. (time: 1 hr 30 min)
  • Wrote and tested code to highlight weekends. Date functions worked fine. (time: 1 hr)
  • Wrote code to highlight dates older than today. Worked, but highlighted today’s date also, which is incorrect. Investigated this issue for almost 2 hours. (time: 1 hr 38 min)
  • Discovered that Google Apps script is based heavily on JavaScript. Was then able to research from a JavaScript perspective. Ok, I should be almost there right?-Wrong! The major stumbling block I ran into has to do with how JavaScript handles date comparisons. There were two main problems:
    1. The new Date() object was not comparing correctly to today’s date. The issue, I found, is well-known to many JavaScript developers: comparing two Date() objects includes the time component, down to the millisecond, so they are never going to be equivalent. (it’s issues like these that make working with libraries like jQuery and Backbone more desirable than raw JavaScript coding.)The solution to this problem was to remove the time component with toDateString(). (time: 30 min)
    2. But that still didn’t make the comparisons work. The issue had something to do with comparing two objects. The solution was given on StackOverflow as essentially converting date objects to strings before comparing. I found the way to do that was with the dot operator and the non-intuitive getTime() function. (time: 15 min)
  • There was still one more snag though. Apparently you can’t assign the getTime() component in a variable like this:
    var today_noTime = new Date(today.toDateString().getTime());
    

    because it just fails. I’m not sure of the technical reasons for this, but it is very annoying in practice.The ultimate solution was to use getTime() as a dot-method on your Date() objects in the direct comparison statement, like this:

    if (today_noTime.getTime() == date_noTime.getTime()) {
        Logger.log("****** Dates are EQUAL ******");
    }

    (time: 15 min)

CONCLUSION

It took around 5 hrs to finally find all the answers. Along the way, I struggled a bunch, learned a lot and am grateful for the experience. However, my one real frustration was that there was no one clear website saying “known issues with comparing time and date in JavaScript”–there was just no such thing. I hope that this post has explained some of these issues precisely enough that it will save you some time.

FINAL SCRIPT

Here is the final complete script:

/*
 * Creator: Eric Hepperle
 * Date:    10/29/13
 * Purpose: Google Script for Spreadsheet.
 *           - Shades rows with weekend dates in (column 2) light gray.
 *           - Shades rows for past days with dark gray.
 *           - Highlights today with yellow background.
 *
 * Notes:   Adapted from code found here:
 *           http://stackoverflow.com/questions/15730638/
 *           google-doc-spreedsheet-conditional-formatting-script
 *
 * Colors:
 *           #B8B8B8 = med gray; past dates.
 *           #E8E8E8 = light gray; weekends.
 */
function colorAll() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var startRow = 6;
    var endRow = sheet.getLastRow();

    for (var r = startRow; r <= endRow; r++) {
        colorRow(r);
    }
}

function colorRow(r) {
    var sheet = SpreadsheetApp.getActiveSheet();
    var dataRange = sheet.getRange(r, 1, 1, 5);

    var data = dataRange.getValues();
    var row = data[0];

    // eric's vars
    var date = row[1]; // 2nd column
    var dayOfWeek = date.getDay();

    Logger.log("*** Logging dayOfWeek " + r + " now ***");
    Logger.log(dayOfWeek);

    // if dayOfWeek is Sat or Sun:
    if (dayOfWeek == 0 || dayOfWeek == 6) {
        if (row[0] === "") {
            dataRange.setBackgroundRGB(255, 255, 255);
        } else {
            dataRange.setBackground("#E8E8E8");
        }
    }

    var today = new Date();
    Logger.log("*** today ***");
    Logger.log(today);
    Logger.log("*** date ***");
    Logger.log(date);

    // remove time component from date for comparison
    today_noTime = new Date(today.toDateString());
    date_noTime = new Date(date.toDateString());

    /*
	Logger.log("today_noTime:");
	Logger.log(today_noTime);

	Logger.log("date_noTime:");
	Logger.log(date_noTime);

	if(today_noTime.getTime() == date_noTime.getTime()){
		Logger.log("****** Dates are EQUAL ******");
	}
    */

    // if date is older than today, mark it as such
    if (date_noTime.getTime() < today_noTime.getTime()) {
        dataRange.setBackground("#B8B8B8");
    }

    if (date_noTime.getTime() == today_noTime.getTime()) {
        dataRange.setBackground("yellow");
    }

    SpreadsheetApp.flush();
}

function onEdit(event) {
    var r = event.source.getActiveRange().getRowIndex();
    if (r >= 2) {
        colorRow(r);
    }
}

Quick Link: Headers and Footers in Word 2003 – Unlinking To Remove Header From Only One Page

October 11, 2013 Leave a comment

Linking and Unlinking Headers and Footers In Microsoft Word 2003:

Here are instructions on how to remove headers or footers from any single page in a multi-page Microsoft Word document.  This applies to Word 2003, but may work with other versions as well.

[Excerpt]

You can link and unlink headers and footers as long as your document contains section breaks.

Unlinking Word headers (courtesy: techforluddites.com)

Unlinking Word headers (courtesy: techforluddites.com)

  1. Insert a Next Page section break at the end of the section where you wish to start a new section.
  2. Click the Link to Previous button on the Header/Footer toolbar.
  3. Watch above the header or footer to see if the “Same as Previous” text is there, if it is click the Link to
  4. Previous button again to detach the new header or footer from the old one.

(courtesy: northlandcollege.edu)

How Many Spaces Should I Put After A Period In A Sentence?

October 7, 2013 Leave a comment
Underwood Keyboard (Courtesy of: Wikipedia)

Underwood Keyboard (Courtesy of: Wikipedia)

I don’t remember who it was for certain, but some person of authority in my life, during my adolescence told me that 2-spaces was the correct spacing to put at the end of a sentence, right after the period. I felt that was wrong, but they must be right because they had credibility in the area of proofreading and technical writing. Thus for almost 20 years I believed that two-spacing was the correct way and the one-spacers were wrong, or just plain weird. But, alas to my dismay I recently found out that all these years I have been the one who was wrong. However, according to Farhad Manjoo of Slate.com I’m in good company; many doctors, lawyers, and other successful professionals who rely on frequent written communication have also mostly been doing it wrong.

What is the reason for this pervasive technical composition error? Blame the typewriter, and more specifically monospace fonts. Manjoo explains that because each character on typewriters originally took up the same amount of space, the double-space sentence termination was developed as what we in the tech industry call a “workaround”–“a method for overcoming a problem or limitation in a program or system” (Google define: workaround)–which usually is just a band-aid, rather than a real fix. Such was the case with the typewriter.

“In the middle of the last century, a now-outmoded technology—the manual typewriter—invaded the American workplace. To accommodate that machine’s shortcomings, everyone began to type wrong. And even though we no longer use typewriters, we all still type like we do.” – Farhad Manjoo, Space Invaders

According to Manjoo the single-space termination became the typography standard in the early 1900’s. But when the typewriter became prevalent as a communication tool in the 40’s and 50’s the two-space workaround became the new standard to overcome the limitations of monospace. With the advent of proportional fonts the double-space solution was no longer needed, but old habits die-hard!

The kicker of it is, this habit is so ingrained in those of us who were taught this way, that it is a hard one to break. Personally, I believe, after reading Manjoo’s excellent article that one-space is the correct method. The MLA doesn’t currently take a stance one way or the other except to say that “there is nothing wrong with using two spaces after concluding punctuation marks unless an instructor or editor requests that you do otherwise.” Double-spacing makes the composition longer and really serves no practical purpose with today’s technology. Therefore, I will be doing my best to develop the habit of ending my sentences with one-space, not two.

CodeSlayer2010’s Code: jQuery Fancy Paragraph Styling (manila background, rounded-rectangle, drop-shadow, orange border)

screenshot of Eric CodeSlayer2010 Hepperle's jsfiddle jQuery -- fancy paragraph tag style 01

Jsfiddle Screenshot (07/13/13)

I wrote this jQuery in about 5 minutes. It is really simple, but amazingly powerful at the same time. The purpose of this is to instantly style paragraph tags. Here are the style parameters:

Background color: Manila (light beige-ish/yellow)
Border color: Orange
Drop-shadow: Yes
Rounded-rectangle: Yes

I want to make the code easily available to everyone, so I’ve provided the jQuery here in case you want to quickly add this style to your project. Cheers.

-CodeSlayer2010

/* Add manilla background, rounded-rect, orange border,
 & shadow to paragraphs.
 (Press F12 in your browser to see the results)

 @Creator: Eric Hepperle (CodeSlayer2010)
 @Date: 07/13/13
 @Version: 1.0

 @Purpose: Puts a fancy style on paragraph <P>
 tags to make them 'pop'.

 @Updates:
 07/13/13
 8:30 - Created initial code.

*/

console.clear()

$('p').css({
 'border': 'solid #FFB819 3px',
 'border-radius':'15px',
 'box-shadow': '10px 10px 5px #888888',
 'background-color':'#FFFBCC',
 'padding':'15px'
});

Fix Your Broken AVI Files For Free With FIX PLAYER from Movie Toolbox

Move Toolbox with Fix Player

Move Toolbox with Fix Player

Just a quick note.  One of the the things you can spend days researching is HOW TO FIX BROKEN VIDEO/AVI FILES?  I tried various utilities.  For those new to to this topic let share what my experience has been:

  1. DivFix and VirtualDub (NanDub) are the venerable standbys that folks in the know have been using for a very long time.  They are either free or shareware.  There are some known bugs in both of these but basically DivFix used to hang and crash on certain file types and VirtualDub is easy to use once you’ve figured it out.  It helps to follow tutorials and RTFM.  If you are new to Video editing software, VDub is not very intuitive.
  2. DivFix++ –> I have used this.  It is the updated version of DivFix, and seems to have resolved many of the bugs –> no issues with hanging.
  3. I tested Video Fixer.  It was a trial edition (10 days).  Last update was in 2006!  It said that it fixed several avi files, but when I tried to run the with VLC, VLC reported that the file was still broken.  VERDICT:  Video Fixer is garbage.  Don’t even bother.
  4. Fix Player –> I was able to consistently repair broken AVI files with this software today (MAY 6, 2013).  It has a simple interface.  I can’t tell you if there are any bugs, because I didn’t run into any.  All I can say is it worked for me all day long today. 🙂

Ultimately, I recommend you check out Fix player.