Tagged: Tech

Cleaning iPhone 5 Holes

My iPhone 5 stopped charging the other day.  My employer just upgraded me from the 4 not too long ago, and I knew they wouldn’t be happy with me telling them my new phone wasn’t working.  I peeked into the charging cable hole and saw roughly 5 tones of pocket lint within.  After rooting around a bit I found the perfect device with which to get it all out.

IMG_0744

GUM Soft Pick.  Normally I would never, ever support these things.  They’re a waste of material, and the ocean is probably littered with them already.  I hate – HATE – single use shit like this.  But we had a couple laying around from a dentist visit.  I snipped off the pointiest bit of one and used the remainder to dig around in my phone (which I’d turned off of course).  The rubberyness of the pick grabbed the lint and drug it out no problem.

HP OfficeJet Pro Plus 8600 time date problems

I got this new printer/fax/scanner/toaster the other day.  It’s a cheap home version of an office multifunction copier.  So far it’s nifty enough for the price.  One giant complaint I found online is people being unable to accurately set the date/time on it, which effects time stamps for emails and faxes.  After fiddling I believe I’ve figured it out.  It is, perhaps unsurprisingly, completely unintuitive.

printerAbove is the time setup in the web config.  You can hit this with it on wireless – no need to have your computer physically plugged into the printer. Set the Current Device Time to actual GMT using the Date field and stupid drop downs for Time.   No, not the current time in your zone…. GMT.  Check the box for Use the same time zone set on this computer and Apply it. This should make the device subtract or add the correct amount of hours from the GMT setting to correctly time stamp correspondence sent from it.  When you return to this page the Current Time will continue to show GMT, not your zone’s time.  I know, I know, that’s stupid too.   An easy test to confirm things are set up correctly is to go into the scan/email set up and send a test page.

Sending an email with Task Scheduler using Powershell

Today at work I had a need to query a bunch of databases for a particular, er, thing, and then send that thing, if found, to myself via email.  I needed this to happen every morning. I decided, since we’re talking about a MS SQL and Windows 2003/2008 environment, that Powershell was the way to go.  And it was – until I popped it into scheduler.

When executed as a scheduled task, the email didn’t send.  Things before and after the email routine worked – the arrays populated, the log file filled – but the email didn’t go.  Firing it from a Powershell manually, everything went fine.

Being the stubborn arse I am, rather than get to Googling I started ripping things apart.  I had the query dump its results into a temp file that a separately scheduled script would open, parse, email and then clear.  Same result: run manually everything worked peachy. Scheduled, no email.

In the end the problem was irritatingly simple.  For some reason, when run as a scheduled task the script didn’t keep the socket open to the SMTP server long enough for a successful transmission.  I added a Start-Sleep -s 5 right after the SMTP command to give it a 5 second breather before continuing on.  Voila – email success.  How silly.

I think I’m going to like Powershell just fine.  Other than quirks like this, and getting used to the syntax, it’s easy enough – and it seems a lot of Windows specific stuff is streamlined, at least in comparison to my old go-to admin scripting languages.

Modified page of categories in WordPress using “Page of Posts”

I hate it when I fail to document.  About a year ago I solved a problem I was having on a client site involving customized pages of categories.  I didn’t document my solution, and not unexpectedly as the months ticked by it slipped out of my brain.  Fast forward to now and I need the solution again.  After too much time spent poking at my own mess, I have the solution again.

My problem was this: I want a page that shows all posts of a particular category, and I want the ability to format those posts into a custom view.  No links in titles, no thumbnails, etc.

Find the Slug of the particular category you want to display.  This is in the Category edit page.  Then create a .PHP file named SLUG_page_template.php.  Populate the file thusly:

{code type=php}
<?php
/*
Template Name: PageOfPosts
*/
get_header(); ?>
<div id=”content” class=”narrowcolumn”>
<?php
if (is_page() ) {
$category = get_post_meta($posts[0]->ID, ‘SLUG’, true);
}
if ($category) {
$cat = get_cat_ID($category);
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$post_per_page = 4; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
‘category__in’ => array($cat),
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘paged’ => $paged,
‘posts_per_page’ => $post_per_page,
‘caller_get_posts’ => $do_not_show_stickies
);
$temp = $wp_query; // assign orginal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if( have_posts() ) :
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>
<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2>
<small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
<div class=”entry”>
<?php the_content(‘Read the rest of this entry »’); ?>
</div>
<p class=”postmetadata”><?php the_tags(‘Tags: ‘, ‘, ‘, ‘<br />’); ?> Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>
</div>
<?php endwhile; ?>
<div class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
<div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>
</div>
<?php else : ?>
<h2 class=”center”>Not Found</h2>
<p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
<?php get_search_form(); ?>
<?php endif;
$wp_query = $temp; //reset back to original query
} // if ($category)
?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
{/code}

On line 9 change SLUG to the appropriate slug of your category.  Update this file to represent the changes you want reflected on the category page.

Determine the cat number of your category.  This is easily done by going into Categories and hovering over View.  Then you can test by going to http://www.yoursite.com/?cat=#  where # represents the category.  Category pages can also be added to menus easily.

0 Day Java Exploit. How to disable Java in your browser.

A JRE exploit has reportedly hit the wild. Context here.  Some kind Redditor has posted instructions on disabling the JRE in various browsers:

  • In Firefox : Press Firefox button -> Add-ons, go to Plugins and click the “Disable” button next to anything named “Java”.
  • In Chrome : Type in: “chrome://plugins/” into the address bar (no quotes). Scroll down to Java and click disable.
  • In Opera: Type in “opera:plugins” into the address bar (no quotes). Scroll down to:
    • Java(TM) Platform <click on> Disable.
    • Java Deployment Toolkit <click on> Disable.
  • In Internet Explorer:
    • Disable UAC (if enabled) and restart.
    • Open the Java app in Control Panel.
    • Go to advanced tab.
    • Expand Default Java for browsers.
    • The checkbox next to IE is grayed out.  Select Microsoft Internet Explorer and press spacebar. Click OK.
    • You can re-enable UAC and restart now.

 

“Expanding” a vmdk in VirtualBox

When I created my vmdk for my work virt in VirtualBox I made the mistaken assumption that by “dynamic” they meant the drive size would expand as necessary.  What they really meant was that the drive would expand as necessary within the limits of the initial drive size setting – which I stupidly set to 20 gig.

Expanding your vmdk for VirtualBox is really a misnomer.  You have to create a new one of the size you want and then clone your old one over to it.  It’s a little time consuming, but not hard.  Disclosure:  My host is running Windows 7 64 and my VM is running Windows 7 32.  Why bother?  It’s a security thing.

  1. Shut down your VM (obivously)
  2. Within the VirtualBox Manager, open the Settings for your existing VM, then choose Storage.
  3. Add a hard disk to the controller.  Make it the same type as your current disk, and make it the size you need.
  4. Once it’s created open a command prompt and head to the directory containing vboxmanage.exe – typically in C:\Program Files\Oracle\VirtualBox\
  5. Run the following, altering the paths to match your current and new vmdk files: 
  6. Twiddle thumbs.
  7. Once that’s complete, reopen the VirtualBox Manager and head back to Settings > Storage.  Add an existing hard disk to your controller, choosing your new drive.  Disconnect your original drive.
  8. Fire up your VM, from within it navigate to disk management, and expand away.

 

Mapping drive with a system account

I needed to do this to test Crashplan.  I keep my photos archived on an external drive hooked to, and shared off of, my router.  Since Crashplan’s client runs as a service under the Service account, this was the solution to get it to see these shares.

psexec from the sysinternals suite is required.

Open a command prompt as administrator.

Path to psexec’s location and enter psexec -s cmd.exe.

Mount the drive via its UNC: net use DRIVELETTER: \\server\\folder /persistent:yes

The share will probably show as disconnected.  Click it – it isn’t.  It should also show up for all users of the machine it’s mapped on.

 

(Killing the share requires the same steps, only with net use DRIVELETTER: /delete