Can’t access Google Drive Folder Offline but can Online on Windows 7? [Fix]

Okay, so I have most of my files in a nice folder called Google Drive. Yep, all of em! I like the idea that my local copy will work just like any old folder and a copy of all my stuff will end up online as a backup. Yeah, I mostly like it as a backup, but I do use Google Docs alot, and it’s awesome that I can share loads of data with other Google users.

Well, today I go into one of my folders and, after a little syncing, I couldn’t access it. It basically gave one of those error messages like you see when you try and access a share when your offline. I wasn’t offline. So what the heck Google! Now, I could login online and access this folder, and (thankfully) it only had Google Doc stuff that Google Docs could handle.

Excuse my lazy hi-lighter job, but yeah, this was the folder acting up. I could access it online! So, I was able to work on the documents there anyways. So, after my meeting (yeah), I set out to fix it…. here’s what I did….

If you look, all I did was rename my folder (using Cygwin) with additional __ (underscores) at the end. I have no clue why this worked, but after I refreshed my Windows folder view…

Once I double-clicked it, it worked! If you are running into this, and trying to figure out if renaming the folder (has to be from Cygwin, Windows won’t let you) will kill your files….didn’t for me.

But, the really weird thing, so far, has been that, on Google Drive, the folder is still the same:

Go figure. As long as Google doesn’t delete my stuff, Google Drive has been awesome so far!

Sublime Text 2, Best Code Editor I Have Used!

Photo of Sublime Text 2 with code open

This is going to be short, but I’ve used a lot of editors in my time. I’m no pro, I need something lightweight, simple, cross-platform and inherently friendly with HTML, JavaScript, PHP and CSS. Sublime Text 2 has been all that and more. I’m no power user, I just need to type, make a few things easy (like autocomplete tags, quotes, etc), and just let me code dammit!

Check out Sublime Text 2

P.S. They just added text drag and drop, the only feature I ever griped about…

WordPress save_post being called twice (and in my case sending two emails)

I celebrated when I figured this out.

Okay, so you have function called mail_someone when a post is saved, like so

function mail_someone(){
    wp_mail($to,$from,$subject,$message);
}

And, you want it to run everytime a post is saved, like so (or so I thought)

function mail_someone(){
    wp_mail($to,$from,$subject,$message);
}

add_action('save_post','mail_someone');

Now, are you noticing that an email is sent twice!? It took me forever today to figure this one out. Turns out, the culprit is WordPress. Check this thread out, and this comment by Gonçalo Peres actually helped me solve the problem. Turns out you have to use another action filter, which is not documented, to get it to work, like so

function mail_someone(){
    wp_mail($to,$from,$subject,$message);
}

add_action('pre_post_update','mail_someone');

XAMPP Sendmail using Gmail account

This is how I did it:

Okay, today, the best answer did not work for me. But, this did:

in sendmail.ini:

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=****@gmail.com
auth_password=*******
force_sender=****@gmail.com

in php.ini:

[mail function]
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"

Based on port @: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287

@http://stackoverflow.com/a/11020314/1436129

WordPress Change Default Display Name Publicy As for all existing users

<?php

//Sets the user's display name (always) to first name last name, when it's avail.
add_action ('admin_head','make_display_name_f_name_last_name');
function make_display_name_f_name_last_name(){

    $users = get_users(array('fields'=>'all'));

    foreach($users as $user){
        $user = get_userdata($user->ID);    

        $display_name = $user->first_name . " " . $user->last_name;

        if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
            else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );

        if($user->display_name == '')
            wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
    }
}

?>

From: WordPress Change Default Display Name Publicy As for all existing users

How to filter / exclude posts by id in list of posts in WordPress Dashboard / Admin

Okay, so I’ve answered my own question. Here is some code on how I did it.

function exclude_list_per_function( $query ) {

    global $wpdb;

//gets all the post ID's, I know this is a bit of a hack
    $querystr = "
        SELECT $wpdb->posts.ID
        FROM $wpdb->posts
    "; $post_ids = $wpdb->get_results($querystr, OBJECT);

        //Go through each post and pass it to a function that returns true if the user_can, and false if the user_can't
        foreach($post_ids as $post_obj){
            if(!can_user_other_function_view_this_post(get_post($post_obj->ID))){
                //if they_can't, add them to the array to be excluded
                $posts_not_in[]=$post_obj->ID;
            }
        }

        //Set those posts to be excluded from the list.
        if(is_array($posts_not_in)) $query->set( 'post__not_in', array_merge($query->get('post__not_in'), $posts_not_in) );
}

add_action( 'pre_get_posts', 'exclude_list_per_function');

From How to filter / exclude posts by id in list of posts in WordPress Dashboard / Admin