Wednesday, December 11, 2013

Chromecast Stereo System

Build a stereo system using Chromecast for less than $100

I was one of the first people to buy a Chromecast. Despite having a few different devices that provide the same services (Tivo, Roku, etc), the low entry point and potential for expandability made it an interesting toy.

However, I quickly noticed we only use it to play music. I have kids running around, and if I’m playing music through the TV they just stare at the TV - which is just an artist’s album displayed using the Ken Burns effect. I decided to hook my Chromecast to my stereo, which is what this article is all about.

A quick search online revealed that a few others had thought of doing this, but the issue was with the HDMI interface. Since HDMI is audio and video combined in one physical connection, I had to buy a special device to split the audio and video.

The Setup

Stereo

I had already been looking for a new stereo receiver. The one I had worked perfectly, but was very large and very heavy. I replaced it with a Lepai mini amp, which was a huge downgrade feature-wise, but I really only need a couple of inputs these days.
Lepai LP-A68 on Amazon.com
Cost: around $25

HDMI Audio/Video Splicer

I looked over a couple on Amazon, and settled on one that got some decent reviews.
HDMI Converter: HDMI to HDMI+Audio on Amazon.com
Cost: around $40

Chromecast

The Chromecast itself.
Google Chromecast on Amazon.com
Cost: around $35


A picture of my rat's nest setup


Currently my setup is a nest of wires on a table, and I noticed my cheap stereo gets some feedback if the Chromecast gets too close (due to the wifi signal, I think). I just push them apart whenever it happens. At some point I might organize everything into a box.

Usage

The good:

  • It's easy to play some music from my phone, tablet, etc, and to be able to control what's playing remotely

The not-so-good:

  • There is no true browser support for Google Music like there is for YouTube.  Therefore, you can only stream music on your laptop if you stream the full browser tab.
  • It's not as easy to switch between devices involves taking control in this weird paradigm-shift-hiccup way that isn't as easy as you expect it to be

Both of these downsides don't quite fit with Google's advertised "it just plays everywhere" motto. They don't seem like that big of a problem, which makes it depressing that they haven't addressed these issues yet.

Summary

This seems like a good base for Google to make other cheap single-use devices that do one thing well.  If they would create a music-only Chromecast with a dedicated audio-out instead of HDMI, I would buy it.


Tuesday, December 3, 2013

Visual Studio Time-Stamp

Earlier this year I wrote a post about how to insert a time stamp in Notepad++ (link).  I thought it might be helpful to share how I did the same thing in Visual Studio using a Macro.  I recently upgraded my hard drive, and had to stumble through setting everything up again, so I figured this was as good of place as any for a reminder.

It is a fairly simple process, the most annoying part is knowing where to look.  I don't have too much interest in knowing everything there is to know about Visual Studio, so I was thankful when I found it relatively straight-forward.  You may want to use this process in your research to build other macros.

A FEW NOTES:

  • You edit a Macro in an IDE for Macros, kind of like a sub-IDE inside Visual Studio
  •  You can test Macros on a file that is open in the main Visual Studio window, so you may want to have a file open for testing
  • Visual Studio comes with a bunch of sample macros, if you have them installed you should see them in the Macro Explorer. They may help you achieve what you are trying to achieve
  • I tested this in VS 2005, but the process should be similar in newer versions
 

THE PROCESS:

  1. Open "Macro Explorer"  Menu: View > Other Windows > Macro Explorer
  2. A small window (or side-bar) opens for Macro Explorer, expand the "MyMacros" and right-click and choose Edit
  3. This opens a the Visual Studio Macros IDE
  4. The default code to get you going is already there, so you should just need to create a Subroutine, here is the code I used:
    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports System.Diagnostics
    
    Public Module jmjMacros
        Sub InsertMod()
            Dim textSelection As EnvDTE.TextSelection
            textSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
            textSelection.Text = System.DateTime.Now.ToShortDateString() & " JMJ:"
        End Sub
    End Module
    
    (note that I have already renamed the "MyMacros" Module to "jmjMacros" in this example)

  5. Notice I used "jmjMacros" and appended a "JMJ:" at the end of the line, unless those are your initials you may want to change them
  6. You should be able to test your code. Make sure a file is open in the main Visual Studio window, and run the Macro to see if it inserts text.  If you don't have a file open, you may get an error message.  I had to switch back and forth between windows a couple times to confirm this was working
  7. That's it for the code!
The Renamed the Macro in Macro Explorer

Testing the Macro


KEYBOARD SHORTCUT:

If you want, you can map the macro to a keyboard shortcut:
  1. Under Visual Studio options (Tools > Options), choose Environment->Keyboard
  2. This just maps a keyboard shortcut to a chosen command:
    • I typed Ctrl+; into the "Press shortcut keys" field
    • Then I selected my Macro from the (ridiculously small) list of commands (see screenshot)
  3. Once I you have everything selected, click on the Assign button.  The command you set up should show under the "Shortcut currently used by" field
Setting the keyboard shortcut


If you are wondering why I use ctrl + ; (control key + semicolon key), that is the keyboard shortcut to insert the date in Google Docs.  I wanted to make sure I remembered it, so I made it the same for notepad++ and Visual Studio.

Thursday, October 24, 2013

Bookmarklet Reporting with dotProject

I’ve been using dotProject for keeping track of my hours on certain projects. It’s a bit of overkill for my needs, but it was easy to get started without worrying about trying to find the perfect tool. Over time I’ve found that going my own route has given me some perspective of what I want.

dotProject's interface is rather ancient by web standards, and it’s feature-set is a bit daunting. Some features seem overly complicated and others seem rather sparse. However, the simple html design lends itself to being very flexible to get what I need out of the system.

One particular report that is my bread and butter is the “Task Log”. All my projects have tasks, and I log hours to those tasks. At the end of the month I just want a list of all the logged hours for the month in a nice list.

However, the big issue I have is the default begin/end dates are useless to me. They load on a 2 week cycle, so the default end-date will be the current date, with the begin date set to 2 weeks ago. Changing them should be simple, but the date textboxes are read-only, and the only way to change them is with a popup widget that is cumbersome to deal with.

One day I had some inspiration and thought, if the dates are being sent as query parameters, why not just formulate those parameters myself? After a little bit of experimentation I ended up building 2 JavaScript bookmarklets: One runs the report for the current month, and the other opens a dialog asking for the month before running the report.

A bookmarklet is just a bookmark, but instead of a URL to a webpage, it contains JavaScript that instructs the browser to do something. In this case I'm instructing it to open the URL of the report using the dates that I want.


I’m going to show the main logic I used, followed by compacted versions. I'm not a huge fan of compacted code, but I was afraid that there might be a size limit for bookmark's URL. At the end I’ll show some examples in screenshots.


Full disclosure: this is my test code, some or all of it may not work correctly, you may need to make some tweaks.


Main code logic
Don’t forget to use your URL instead of the fake one used in this example 

//This is the URL before you add the date parameters
var BASE_URL = "http://dotproject.example.com/index.php?m=projects&a=reports&project_id=0&report_type=tasklogs&log_userfilter=0&do_report=submit";

//first day of current month
var begin_date = new Date();
begin_date.setDate(1);    

//last day of current month
var end_date = new Date(begin_date.getFullYear(), begin_date.getMonth() + 1, 0);

//open the URL, with the formatted dates
open( buildURL( formatDate(begin_date), formatDate(end_date)));

//format YYYYMMDD
function formatDate(dtDate) 
{
    var sDate = "";
    sDate += dtDate.getFullYear();
    sDate += pad2(dtDate.getMonth()+1);
    sDate += pad2(dtDate.getDate());    
    return sDate;
}

//pad 0 (zero) to single-digit date parts (i.e. 3/9/2013 = 03/09/2013)
function pad2(n) 
{
 var str = String(n);
 if(str.length < 2) { 
  str = "0" + str; 
 }
 return str;
}

//return the full URL (BASE_URL + THE date parameters)
function buildURL(sBegin, sEnd) {
    var str = "";
    str = BASE_URL+"&log_start_date="+sBegin+"&log_end_date="+sEnd;
    return str;
}



Task Log: Current Month (compacted)
Don’t forget to use your URL instead of the fake one used in this example
//open report for the current month:
javascript:(function(){
 var BASE_URL = "http://dotproject.example.com/index.php?m=projects&a=reports&project_id=0&report_type=tasklogs&log_userfilter=0&do_report=submit";
 function fd(d) {var s="";s=d.getFullYear();s+=pd(d.getMonth()+1);s+=pd(d.getDate());return s;}
 function pd(a){a=String(a);a.length<2 a="" amp="" br="" return=""> var m1 = new Date();m1.setDate(1);
 var m2 = new Date(m1.getFullYear(),m1.getMonth()+1,0);
 location.href=BASE_URL+"&log_start_date="+fd(m1)+"&log_end_date="+fd(m2);
 })(); 

Task Log: Ask for Month
Don’t forget to use your URL instead of the fake one used in this example
//ask for month (number), then open the report:
javascript:(function(){
 var BASE_URL = "http://dotproject.example.com/index.php?m=projects&a=reports&project_id=0&report_type=tasklogs&log_userfilter=0&do_report=submit";
 function fd(d) {var s="";s=d.getFullYear();s+=pd(d.getMonth()+1);s+=pd(d.getDate());return s;}
 function pd(a){a=String(a);a.length<2 a="" amp="" br="" return=""> var m1 = new Date();m1.setDate(1);
 var m = prompt("Enter Month: ", m1.getMonth()+1);
 m1.setMonth(m-1);
 var m2 = new Date(m1.getFullYear(),m1.getMonth()+1,0);
 location.href=BASE_URL+"&log_start_date="+fd(m1)+"&log_end_date="+fd(m2); 
 })();


Adding bookmarklets in pictures

Default report parameters, those dates won't help me
Start with a new bookmark, and paste the JavaScript into the Location field
Here's the result, the dates load correctly!
Creating a separate bookmark to ask for the month
Here is the bookmarklet asking for the month
The report showing the correct dates!


Wednesday, October 16, 2013

Download Adobe Connect Presentations

Download your own copy of an Adobe Connect 8 Presentation




The following are some methods I used to download offline copies of presentations given at a class I took at the University of Washington.  Adobe Connect 8 was the web meeting software used, and it should be noted that Adobe provides documentation on how to provide offline copies, but for various reasons our instructors weren't able to figure it out.

If you search the Adobe Connect user forums, you’ll notice it’s filled with people posting questions on how to export their presentation. I found some good information in the forums and other places, and this post simply lists the methods I used to achieve the goal.


The Easy Way Out: Throw money at the problem
Without a doubt, the easiest solution is to use a screen recording utility.  You may already have a favorite tool, but I payed for one called Screencast-O-Matic.  For what it’s worth, it did a great job for the price.  In hindsight, I would have just recorded the presentations as they became available.
http://www.screencast-o-matic.com



The Do It Yourself Method
Disclaimers:
  • You must be comfortable with the basics of editing and and video (I do you no favors)
  • Fail Early! If it’s not working out, don’t blame yourself and go the easy route

Software: FLV Editor Lite

I found a good free Flash editor called FLV Editor.  It’s free lite version will work fine if you stay under 4 input files, and honestly if you need more you shouldn’t use this method.  If you find the software useful, I’d encourage you to support the developer and buy the software.

The publisher also has a player called FLV Player, which is a pretty robust player despite its ugly interface.  It plays FLV files better than the VLC Player.

Download the presentation

You will have to download the presentation directly from the web software using these steps:  
1. View the Adobe Connect video on your browser like you normally would
2. Remove the extra parameters from the URL, and add this on the end: /output/filename.zip?download=zip
3. Reload page, wait for a download dialog to display and save the file


What is in that Zip file anyway?

The zip file you receive consists of several Flash (FLV) files that make up different parts of the presentation (audio/video/chat/etc); together they form the entire presentation.  The way I understand it, there is one file that controls all the others, called mainstream.

In the best case scenario, the presenter gives the presentation without stopping the recording. However, if they paused any part of the presentation at any time, a new file is created.  This is where the mainstream file steps in, it keeps track of which files should be “played” when, like a music conductor in an orchestra.  This file will not help us, but it’s important to understand how it works.

Extract Audio/Video

I only wanted the audio and the screen share.  Unfortunately the audio and screen shares are stored in separate files.  In the best case scenario:
  • The audio is stored in a file similar to: cameraVoip_****.flv
  • The screen share video is stored in a file similar to: screenshare_****.flv


Video can also be stored on the voip file (usually a web cam of the instructor), so we will need to separate the audio from the video in that file.  Then we will merge the audio to the video from the screenshare file.


Here are the steps to follow this best-case scenario:
  1. Open the FLV Editor
  2. Add the cameraVoip file  
    1. Drag the file into the editor section
    2. Choose the option to un-link the audio & video
    3. Delete just the video part, leaving the audio behind (this can be tricky)
  3. Add the screenshare file
    1. Drag the file into the editor section
    2. It should only have a video part, no sound
  4. Make sure the audio and video line up,and export to Flash
    1. There is an option to export to other formats with the pay version


If you have more than one of either the audio or video

The instructions are similar to the best-case scenario, except you have to get a little creative.  If you can watch the original presentation on the website, you may be able to figure out where the presenter paused.  You can then try to match up all the files in the editor appropriately.



Are there other options?
I originally tried an awesome command-line utility called ffmpeg:  
  • It can work with flv files, but isn’t so good with converting them, so stick to flv
  • If you have more than one of either the audio or video files, prepare for a difficult time
  • Sometimes the audio/video would be out of sync, usually because one of the files was ~5 seconds longer than the other.  
  • There are plenty of examples on the web on how to use this tool.
  • http://www.ffmpeg.org

My method was to extract the audio, then combine it with the video using a script.
Here are the 2 commands that were the heart of my script:

ffmpeg -i cameraVoip*.flv -vn -acodec mp3 output_audio.mp3
ffmpeg -i output_audio.mp3 -i screenshare*.flv -acodec copy -vcodec copy output_video.flv


If you can follow what’s going on in those 2 commands, you can try ffmpeg.  I found it a fun exercise to remind myself that I still have some command-line skills, and that was good enough to move on to something else that would get the task finished faster.


Conclusion
This are the methods I used to download copies of the presentations: I tried to piece the presentation together by myself, but if I ran into any issues I immedately went to the screen recorder.

Your presentation can vary wildly, so you might have to do some investigation with the various files in the zip archive to determine the best course of action.  Hopefully I have at least given you some inspiration.

Tuesday, August 27, 2013

Android Project: One Book Away

One Book Away
The Library App revisited

I have officially come to the end of my Android classes at the University of Washington!  The program consisted of 3 classes, each with their own project.  If you look back in my blog you’ll find the other 2 projects, which were: 
1st class: "Library Hold Wait", a sort of calculator for items waiting at the library  
2nd class: "One Step Further", a child developmental milestone quiz 

I’ll take a moment to mention that "One Step Further" is in the Google Play store.  It’s much more streamlined and polished than the one I presented in class.  You should check it out, and if you like it please give it a good rating!

My 3rd app took the same idea of the library hold calculator and extended it to make it much more useful.  Instead of manually entering your hold information in a calculator-style format, the app reads data directly from the Seattle Library and does all the calculations for you.

I am happy with the results, and I think it leaves the door open to add more features to eventually get the app into the Play store in the coming months.  I could even port this app to work with other libraries that use the Horizon system.


I've been working so hard over the past few months, that I let loose a little bit for the presentation.  You'll have to excuse the weird color combinations, HUGE cheesy images, and lots of in-page transitions. 




screenshots

Main Page

Loading Hold Data

Detail Page

Preferences

Update Checkout Periods




Tuesday, June 11, 2013

One Step Further, for Android


I've been taking a series of classes on Android development at the University of Washington.  You may have seen a previous post from my first project (Library Hold-Wait).

Compared to the last project, I spend much more time developing this project than the last.  It's a day after my presentation, and I'm completely exhausted.  Luckily I have a couple weeks before I start taking the 3rd and final course of the series.

I've included the video of the presentation, and some additional screenshots and slides below.  The app was developed for class, but I hope to get a variant of it up on the Google Play store at some point.  At the very least it can be a good resume-builder.



Notes:
  • The app has some features that were required for class: an RSS reader, links to other services, both a Map in a webview and a Map using Google Maps APIv2
  • I have had a version of this idea for a few years now; so it wasn't too much of a stretch to adjust it further to fit with the requirements of the class

Screenshots:


Landing Activity
Fairly standard screen

Assessment section
Choose which behaviors your child is displaying

Results of the Assessment
Always consider talking to a doctor

More Information Section
Extra information


Slides:















Friday, May 10, 2013

20130508

This is meant as a list of things that have interested me lately.  Some of it is from best-of lists from other blogs (best of, best of?), and a lot of it I found in my Evernote trashcan.

Personal Status

I'm waist deep in my second Android class (of three).  I'm really enjoying the platform, but I am getting a little frustrated with not being as well-acquainted with Eclipse and Java as I'd like to be.  At some point the best way I'm going to learn is to apprentice with a more experienced Android developer.

Headliners

Stop reading the news
http://www.guardian.co.uk/media/2013/apr/12/news-is-bad-rolf-dobelli
I found it ironic that a story about not following the news looks a lot like a news article.  I also found it funny that I got the lesson out of this article by only reading the title and all the bold subtitles.

You should blog even if you have no readers
nathanmarz.com/blog/you-should-blog-even-if-you-have-no-readers.html
It's like they were talking directly to me!

Android: Handling configuration changes with Fragments
http://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html
(i.e. using AsyncTask when the user changes the phone's orientation)
I'm to the point where I feel comfortable researching Android topics on my own, I still feel like I can't really give advice to others as to the best way of doing something.  Even so, I found this post especially useful for handling AsyncTask threads. 

The battle between flat design and skeuomorphism
http://sachagreif.com/flat-pixels/
Skeuomorphism is the word you use these days to signal to others that you are smart, hip, and with it.  It's one of those words that reminds you what it feels like to be a Freshman - everyone around you hates being made fun of, but then the next year you make fun of everyone the new Freshman class.  I never understood the lack of empathy in these situations.

The Exceptional Beauty of Doom 3's Source Code
http://kotaku.com/5975610/the-exceptional-beauty-of-doom-3s-source-code
A nice little analysis of Doom's source code.  This is a summary of another article, but there is a link to the original analysis that I also enjoyed.  I'm not hot on debating the position of a curly bracket, but some of the other stuff was useful to keep in mind.  I especially like the section on Const and Rigid Parameters. 

Tools that might be useful

BitTorrent Sync
http://torrentfreak.com/bittorrents-secure-dropbox-alternative-goes-public-130423/
BTW, don't "dropbox" me: there's nothing wrong with looking at alternatives

Interesting Stories 

The rise and fall of AMD
The Making of Pulp Fiction
Meet the men who spy on women through their webcams
Interesting story involving Dennis Rodman and North Korea
How to avoid Drones
Beat by Dre

Entertainment

Guns in movies being replaced by thumbs-up
Salary Negotiations: Whats possible when there is no more money?
Funny animated gifs of infomercials
It's like sky-mall for your computer!




 


Wednesday, April 24, 2013

Slightly OFF Communication


 (otherwise known as real-life Seinfeld situations)

I was walking to an office in Fremont when I noticed a man trying to simultaneously steer and push his car at the same time. Despite the pouring rain, I decided to lend him a hand. I quickly learned he wasn't trying to push his car, was was trying to push START his car. I eyed him smartly and asked "have you ever successfully push-started a car before?", he assured me he had. I was already committed (the dog was tied to a street sign), so I proceeded to help him push his car up and down the street. Eventually we gave up and pushed the car into a parking spot, which is what I wanted to do in the first place.

If you know my dog, you know he howls like the dickens when he's not within 2 feet of me in public. So throughout this entire ordeal there was the background noise of a howling labrador echoing throughout Fremont. While we were pushing the car into its final parking space, a woman approached me to ask if the dog was mine, because she thought someone might have abandoned him. Imagine a howling dog attached to a no parking sign in Fremont - yeah it wasn't pretty.

...

I got to the office and the door was locked. Was anyone there? I knocked, no answer, but a desklight was on far inside. I pulled out my cell phone and sent a text to the person asking if they were in the office, and he replied "Yes!". He apparently did not get the hint that I was at the front door, which makes sense because I only occasionally work at this office. So I was about to text him a more obvious message when the (fall-off) hallway door opened, and someone familiar stepped in. It looked like someone who worked in the office, so I calmly waited for him to walk down the long hallway. As he approached, he acknowledged my dog and came up to pet him, so I just said "I'm in luck, you just saved me 25 cents". He gave me an odd look, which is when I noticed it wasn't who I thought it was, but some person from another office in the building. There was nothing I could do, so he oddly passed me by and I stood at the (still locked) front door looking like a tool.

Wednesday, April 10, 2013

Cord Cutter

I'm a cord cutter - which is just a person who got rid of their pay TV service (cable or satellite) in favor of another method. This post is just about the method I use, yours may differ. My hope is that it might give you some ideas on how you can also be a better cord cutter.
  • Everyone watches TV differently, so it's important to figure out what's important to YOU.
  • We enjoy having access to live broadcast tv, so we hooked an antenna to a DVR (Tivo Premiere) to record all the shows from the major networks. We supplement with Netflix, and for anything else we use Amazon Video-On-Demand (VOD), which costs about $2/episode.
  • It might sound confusing, but remember the Tivo does 95% of the work. We setup which shows we want it to record and it does the rest. Everything else is available on Netflix, and if you find yourself still wanting more you can then turn to Amazon VOD. What makes it even easier is that Netflix and Amazon are hooked directly into the Tivo.
  • Our goal was to shoot for a equivalent price per month lower than cable, which was around $70/month. I'm happy to report we usually pay about $20/month these days, depending on how you measure it.
  • If you don't care about broadcast tv, or don't care to have a DVR, I'd recommend a Roku. It opens the doors to more online services, such as Amazon Prime Streaming for instance (a Netflix competitor that doesn't work with Tivo).

Monday, April 8, 2013

Notepad++: Launch Firefox, Chrome, IE to your heart's content

Somehow I lost my ability in Notepad++ to open a file in a web browser. I couldn't figure out how to get it back, so I turned to the internet and ran across a solution for people having difficultly setting it up with Google Chrome. I ended up just modifying their solution:



This post on super user (stack exchange) got me started, then I put together how to add Firefox, Chrome, and IE.
http://superuser.com/questions/306736/notepadis-there-a-way-to-fix-the-fact-that-i-cant-run-chrome-from-the-run-me

Shortcuts.xml

Notepad++ uses a "shortcuts.xml" file to store shortcut information. You'll have to poke around, but it's located in your AppData folder, here is where I found mine:
Win7: C:\Users\jmj\AppData\Roaming\Notepad++\

  • It's important to note that this file acts like a registry setting. When Notepad++ is started, it loads those settings into memory, then when it's closed it saves them back to the settings.xml file. This makes it so that you can't edit the shortcuts.xml file in Notepad++ itself because when you close the application it will over-write your changes to the file!
  • Unfortunately the best way to avoid this is to keep NPP closed and edit the file in (gasp!) notepad.exe

You place the commands in the < UserDefinedCommands > section, I've provided that section from my shortcuts.xml file below:
<UserDefinedCommands>
<Command name="Launch in Chrome"  Ctrl="yes" Alt="yes" Shift="yes" Key="82">%LocalAppData%\Google\Chrome\Application\Chrome.exe                       &quot;$(FULL_CURRENT_PATH)&quot;</Command>
<Command name="Launch in FireFox" Ctrl="yes" Alt="yes" Shift="yes" Key="83">&quot;C:\Program Files (x86)\Mozilla Firefox\firefox.exe&quot;    &quot;$(FULL_CURRENT_PATH)&quot;</Command>
<Command name="Launch in IE"      Ctrl="yes" Alt="yes" Shift="yes" Key="84">&quot;C:\Program Files (x86)\Internet Explorer\iexplore.exe&quot; &quot;$(FULL_CURRENT_PATH)&quot;</Command>
</UserDefinedCommands>

  • I copied the "Launch in Chrome" directly from the superuser.com website, then modified it for the remaining calls. 
  • I tried to line up the attributes above so that you can easily read them 
  • You can use the Shortcut Mapper to change the shortcut calls after you have these loading correctly (I haven't bothered yet) 
  • I had to use &quot; to handle spaces in the path (i.e. "C:\Program Files (x86)\Mozilla..") 
  • $(FULL_CURRENT_PATH) refers to the html file you are editting in NPP (ex: jasonjeromeresume.html from the screenshot) 

There are other commands available, read about them in the npp docs:
http://npp-community.tuxfamily.org/documentation/notepad-user-manual/commands

That's it!

Monday, March 25, 2013

Notepad++ Time-Stamp

Kudos

I’ve been keeping some form of a work journal for years; I’d highly recommend it.  I recently got annoyed with creating timestamps in Notepad++, and ran across a helpful post in a forum.  It was so helpful that I thought I’d do my best to try to give it some additional street cred.

Here is the original link:
http://sourceforge.net/p/notepad-plus/discussion/331753/thread/3458d1da#62f2

What day of the week was 4/22/2006 anyway?

Before I start, if you have the TextFX plugin already setup in Notepad++, it provides 2 static methods of inserting a datetime stamp:
Menu: TextFX > TextFX Insert > I:Date & Time: short format: 3:56 PM 3/22/2013
Menu: TextFX > TextFX Insert > I:Date & Time: long format:  3:56 PM Friday, March 22, 2013
If these look good enough to you, you can skip to the section on how to map a keyboard shortcut to these.  However, in addition to the time and date, I also wanted the day of the week, like this:
03:36 PM 03/22/2013 (Friday)


Steps

It turns out this can easily be done with a simple Python script.  I don’t even know Python that well and I was able to do it.

1. Install the python plugin:
  • The plugin’s name is: Python Script
  • It’s recommend you do this via the NP++ Plugin Manger (Menu: Plugins > Plugin Manger)
  • Here’s a link to the project page:  http://npppythonscript.sourceforge.net/
  • The script includes some basic Python libraries, so you shouldn’t need to install Python or other 3rd party libraries

2. Setup script in Notepad++:
  • Menu:  Plugins > Python Script > New Python Script
  • It will ask you for a new file name, I choose: npp_timedate_stamp.py
  • A new tab will appear in NP++ for you to enter the script.
  • This is the script I used:
    
    # Add date/time stamp in Notepad++ 03:28 PM 03-22-2013 (Friday)
    import time
    editor.addText( time.strftime( '%I:%M %p %m/%d/%Y (%A) ' ) )
    
    
  • Here is a link to the Python documentation which shows what all the format string characters: http://docs.python.org/2/library/time.html
  • Save your script

3. Configure Notepad++ to use the script:
  • Menu: Plugins > Python Script > Configuration
  • You should see your script under the User Scripts section
  • Add it to Toolbar and/or Menu
  • I put it in both, but I only managed to find it under menu
  • It shows up as its own entry under Menu: Plugins > Python Script > npp_timedate_stamp

4. Create a keyboard shortcut (my preferred method):
  • Menu: Settings > Shortcut Mapper
  • Switch to Plugin
  • Scroll down until you see your script name (i.e. npp_timedate_stamp)
  • Click on it, choose Modify, and choose a key.  I used: CTRL + ;

Furthermore

This was exciting to me in more ways than one, because in the past I’ve looked for ways of modifying Notepad++, and plugins can be a daunting undertaking.  Apparently the Python plugin is mapped to all the Notepad++ features, so I might utilize it more in the future.

Friday, March 22, 2013

Future Phone, 7 plus or minus 2

I had this thought swirling around my head this morning that wouldn't go away.  What I usually do in such cases is write down enough to be satisfied and then continue on with whatever I was doing.  However, today involved building an image, so after quickly sketching it up in gimp I figured I might as well post it somewhere.

I was thinking about how we make phone calls. 
  1. Originally we called an operator and asked to be connected to a house address (i.e. using words)
  2. We switched to a 7 digit number
  3. There were so many phone numbers we had to add the area code every time you dialed, so it became a 10 digit number
  4. (I'm ignoring countries outside the US, sorry but you guys have a ton of numbers to dial)
  5. With the phone Address book it seems we're almost back to the original model of connecting using words
 * There shall be no implications what-so-ever that I know anything about the history of telecommunications from this list, although I did take a very interesting telecom class in college.

This got me to thinking: how else could we make calls other than using the number method?

The address book has pretty much eliminated the need for memorizing a phone number, although you could think of that number as being a good unique key into the world "database" of phones.

That's it.  Thanks for the ear internet.

Built this fairly quickly in gimp, I'm not sure why everyone complains about it being too confusing to use.









Thursday, March 21, 2013

Entry-Level Android Application

I've been taking a series of classes on Android development in my spare time via UW.  The final project for my 1st class was to build a simple 2-screen application and present it in front of the class.

Lucky for me the presentation was recorded.  Un-lucky for me it was recorded using Adobe Connect, which makes downloading and editing the video extremely annoying.  I figured a way around all the hurdles and you can watch the video below.  I've also posted the slides below with some notes.



Some quick notes:
  • Originally I was going to made a tip calculator, but was talked into this idea instead
  • The idea for this app came from an idea I had for a Greasemonkey script

The slides from the presentation:



Slide 1
  • The presentation was meant to be mostly verbal with just a few points made on the slides themselves.  However, I did modify a couple for this blog post.



Slide 2
  • A simple feature allows me to explore the entire end-to-end process



Slide 3
  • The first example is simple to allow the audience to quickly follow the gist of the calculation
  • The second example shows how the result can be useful: with a 5 month wait, I can plan to read something else while I'm waiting



Slide 4
  • The better looking app usually wins
  • I found this image of an old-style library checkout card to use as a guide (my apologies if this is your image)




Slide 5
  • For the actual presentation, I switched to using a separate overhead projector that displayed my phone on the wall.  I just inserted a screenshot for this version.



Slide 6
  • Process button wasn't needed, but works as a visual cue to the user
  • I used View elements in the XML layout, with a height/width of 1dip to make the lines
  • I repeated those lines at the bottom to complete the look I was trying to achieve
  • If I had to do this again, I would calculate the device's resolution and repeat those lines as many times as I needed.  It didn't matter for this project.




Slide 7
  • Changing Preferences wasn't supposed to overwrite the current values the user had entered, but upon testing this just confused the user.  I had to change it to just have the preferences always over-write the current values.
  • I originally had the result displayed in a TextView (read only), but decided to change it to a EditView so the user could select and copy the result
  • The font and background with smudges made a HUGE difference. Smudges were just in the background image I created in GIMP, the aspect ratio didn't matter.
  • I don't think anyone noticed, but I used that same background image in the app for this slide. I wanted to show that the image could be re-sized to fit just about anything and still look realistic.




Slide 8
  • If you didn't watch the video, the audience had a couple questions and comments about how I did a couple things
  • The comment that I remember most was when someone commented on the background image - he said at first he thought the screen on my phone was dirty!