Introducing Subversion (SVN) Into Your Team

Posted by Dan | Posted in Automation / Scripting, Development, Subversion | Posted on 10-29-2011

0

Here’s a listing of items that may be of challenge when introducing it to a team who has no previous SVN experience. Version control is a rewarding experience, and once you get the hang of it, you’ll be wondering how you lived without it.

 
1.  (Most) everyone using SCM for the first time. Have to be familiar with:
  a.  Subversion concepts
    i. Terminology
    ii. Best practices
 
  b. Tools:
    i. Tortoise Concepts
    ii. Subclipse (Programmers)
 
  c.  Quirks
    i. Sometimes the icon overlay won’t show in Explorer
    ii. Thumbs.db file can make the status of the directory misleading
    iii. Updating code in MacOSX’s finder can corrupt the SVN metadata 
         because a native SVN shell (e.g. Tortoise) isn’t being used.
 
  d. Troubleshooting (I sent out a list of 10+ SVN issues and how to 
     troubleshoot)
    i. What do you do when you get this type of error?
 
  e. Undoing the way things were done before an SCM tool was used
 
2.  SVN Performance
 
  a.  Performance of the SVN repository is dependent on use
    i. If programmer-A does intensive SVN operations, like checkouts, it 
       slows down operations for everyone else – programmer B has to 
       sometimes up to 20 minutes to view the revisions of 1 file. 
 
  b. Performance of SVN client is dependent on network
 
 
3.  Development Workflow between all members  
 
4.  Deployment to STAGING + PRODUCTION
 
  a.  A better process for deploying to STAGING:
 
    i. If a change set that has to be deployed to STAGING is small 
       (e.g. <10 files under 1 folder), it can be done manually, which 
       takes seconds.
 
    ii. If a change set is large (10 files, however, dispersed 
        throughout a code base), gets more error prone (done by hand) 
        and is better done through automation.

Send A File Path from the Windows Context Menu to App

Posted by Dan | Posted in Automation / Scripting, C#, Windows | Posted on 05-26-2011

0

Here’s an easy way to pass the file path to a console app. I needed a way to right click on a folder or a file, and send the path to a console app, where the app does its thing with the file(s).

To show you what I mean:

When I right-click on “coolbeans” it runs the following console app, which simply displays the path:

The C# app is pretty straightforward. Basically, once you have the file path, you can apply any operations on the file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace dan_rocks
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine(args[0]);
      Console.ReadLine();
    }
  }
}

So there’s nothing crazy going on in the above sample. You basically just have to add a few entries to the Registry.

If you want to pass a folder path when you right-click on it, and select the option in the context menu, create a new entry:

HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell

If you want to pass in a file, do the following:

HKEY_CLASSES_ROOT\*\shell

Let’s pass in the filepath to note.exe:

Do that and you’ll see the following:

Testing Database Import Scripts with Snapshots

Posted by Dan | Posted in Automation / Scripting, Databases, SQL Server, Systems | Posted on 05-05-2010

0

Can’t stress enough how handy database snapshots (compatible only in Enterprise and Developer editions of SQL Server 2005+) come in when testing bulk imports, data scrubbing, or any sort of data / schema modification script. In nearly no time, I can create a snapshot (via shortcut snippet), run my script – don’t like the results? My script crapped out the data? I can run an instant undo by recovering from the snapshot, which works pretty fast. If I want to create another snapshot, I usually tend to overwrite the snapshot I created, and then create it again.

It’s so handy that I have a snippet for it:

Anywhoot, here’s how you create a snapshot:

1
2
3
4
5
6
7
-- CREATING A SNAPSHOT
CREATE DATABASE YourDatabase_snap ON         -- Name of new snapshot
(
  NAME = yourdb_data,                        -- Logical filename of source db you want to snapshot
  FILENAME = 'c:\YourDatabase_data_1800.ss'  -- Sparse file to create
)
AS SNAPSHOT OF YourDatabase;                 -- Source db name
1
2
3
4
-- RECOVERING FROM A SNAPSHOT
USE master;
RESTORE DATABASE YourDatabase                    -- Source db name where the data resided
FROM DATABASE_SNAPSHOT = 'YourDatabase_snap';    -- Snapshot db name

Deleting a snapshot is just like dropping a database.

1
DROP DATABASE YourDatabase_Snap

Fast Delete

Posted by Dan | Posted in Automation / Scripting, Systems | Posted on 04-09-2010

0

I needed to delete 30,000 files that took about 60 GB. I know traditionally it takes forever to delete it in Windows. Even using the “del” command in the console, it’s always been slow for me. Enter Robocopy. I never gave it a chance until today. The way it can delete is by syncing directory against an empty one which was just what I needed. It was able to do it in about 50 seconds. Awesome.

You’ll have to download Robocopy as part of the Windows Server 2003 Resource Kit Tools.

What I used to delete this big directory:

robocopy /MIR c:\empty-directory c:\my-files-to-delete

Using Winrar from the Command Line

Posted by Dan | Posted in Automation / Scripting, MySQL, Windows | Posted on 03-29-2010

0

Winrar is a great tool used for compressing files. It also has a command line tool called “rar.exe” to compress files, in case you want to batch it up. Here’s an example of the most common switches I use.

"C:\Program Files\WinRAR\rar.exe" a -m5 -r -ep1 "C:\temp\Work\Upgrades\2010-02-06\111.rar" "C:\temp\Work\Upgrades\2010-02-06\Post-Upgrade\"

First path is the location of the rar file to create. The second path is either the location of the file(s) or directory to compress.

options used
 
  -ep1  Exclude base directory from names
  a     Add files to archive
  -r    Recurse subdirectories (will compress entire directories)
  -m5   Set compression level to maximum

You can even assign a password to it using the -p switch

Search As You Type

Posted by Dan | Posted in Windows | Posted on 02-14-2010

0

Just upgraded recently from WindowsXP to Windows7. One feature I used a lot forever (since Win95 I think), was the search as you type (this is what I call it anyways). It’s when you have an Explorer window open (let’s say in this case c:\ ) and you type “W” – it moves the cursor to directory that starts with the letter “W.” You can type “Win” quickly and it will go to the first directory that starts with those keywords in case you have directories that start with “Win.”

So after I configured the UI settings on Win7 to the way I saw fit, I realized that this feature was gone. It would automatically start searching for text in all files recursively – very annoying. I asked how to turn this feature off in many forums and do what I wanted to do and no one knew.

I finally figured it out. It was a setting that I turned on accidentally. (D’oh!)

Explorer Window -> Organize -> Folder Options -> View Tab -> When typing
into list view -> Select the typed item in the view

That wasn’t checked. I suppose I did it instinctively without thinking. In WindowsXP, the area is used to trigger Advanced File Sharing, and I guess I didn’t realize this in Windows7. Also, I don’t think in XP this is an option you can control because it just works.

Windows7 Options

WindowsXP Options

Reasons I’m Not a Fan of Google Chrome OS

Posted by Dan | Posted in Systems, Technology | Posted on 02-14-2010

0

I’m assuming you’ve seen what Chrome OS can do. Just Google “Chrome OS,” because it’s everywhere.

I would give Chrome OS an 8.0 / 10.0 for computer beginners, like the grandmas of the world. It’s gets a 2.0 / 10.0 for techies. Why? Three reasons.

  • Needs too many resources for what it delivers.
  • Cannot run executables, not even virtually/sandboxed.
  • Needs the cloud for storage.

Kind of annoying that I can’t just run it on any old laptop / netbook. System requirements are too demanding for what it promises and it seems it’s needed just to have that 2-4 second boot-up time, which honestly it doesn’t mean much to me. There’s never a time where I’m in such a hurry that I need my computer that fast, because I’m either doing something else, or I just use my phone.

I some people really care about boot-up time? I’d rather wait 10 more seconds and have the ability to run .EXE files and have it run on old PC’s. For a minimalist device, I have my table PC or iPhone already that can do all that stuff, and I don’t have to worry about malware on the iPhone. I don’t think techies have to worry to much about malware since they’re careful about getting them in the first place and have good Anti-viruses.

Lastly, an Internet connection is not ubiquitous yet. I’m on the subway a lot where there’s no WIFI and sometimes I travel to places without an Internet connection. I want to be able to at least read my latest documents without connecting to the cloud.

The OS is still in the works, so I suppose maybe they’ll address some of these features in the future.

Console2 Alternative to CMD

Posted by Dan | Posted in AutoHotKey, Automation / Scripting, Systems, Windows | Posted on 02-13-2010

0

You know what, I tried PowerShell and I guess I never got used to it. I’ve been using DOS for the longest time that I prefer its simplicity when navigating through files. As far as scripting with it – forget it – it’s very cryptic and limiting, not to mention awkward. That’s why for scripting now I’m using Python. Nonetheless though, I sometimes need a playing field to run the scripts for, or running console utilities. That’s where Console2 comes in.

Console2 is a great tool that provides tabbing (you can tab through multiple consoles) and several ways to customize the UI. Here’s an example:



I prefer this configuration:


How I Have It Setup



Download Console2:

I have the Console2 open up when I hit CTR+\ via AutoHotkey. Here’s the snippet for this to happen in AutoHotkey. I have this run when Window starts (it must stay in memory).

^\::Run C:\dan-local\dos-win\Console.exe

Change the CMD prompt by creating a PROMPT system variable:




Download the Console2 Config File

Other Tips


Autocomplete
Good tip about command console = CTRL+I
can select files in the current directory, kinda like autofill-in
you can also put in parts of the file and it autoputs it for you

Rename tab
CTRL+R

New Tab with default transparency
CTRL+F1

New Tab with lighter transparency
CTRL+F2

Switch to NEXT adjacent tab
CTRL+TAB

Switch to Previous adjacent tab
CTRL+SHIFT+TAB

CTRL+[NUMBER]
Goes to the tab instance. To make it easier, it’s best if you rename your tabs,

[INSTANCE NAME].[NAME OF TAB]

So for example,

1.Batch File
2.wget list
3.ftp the files

Base Tag Not Supported In Hotmail

Posted by Dan | Posted in Systems | Posted on 02-11-2010

0

It’s interesting how the <base> works in various clients. I thought all major web clients would support it, but apparently it is not the case.

Let’s look at how some email clients process this tag:

Yahoo.com! Web Mail

Base tags are modified by their mail server and relative URLs are changed to absolute. So it works.

Gmail Web Mail

Base tags are modified by their mail server and relative URLs are changed to absolute. So it works.

Gmail Account via Thunderbird

Base tags are shown and its functionality is intact. URLs remain relative. So it works.

iMS Account via Outlook 2007

Base tags are shown and its functionality is intact. URLs remain relative. So it works. More info on iMS.

ShinyLight Account via iPhone

Can’t see the HTML, but all URLs worked.

Hotmail

Unfortunately, this is the ugly duckling. Hotmail servers remove the base tag and leave your relative links as relative. Big FAIL.

Get Latest File

Posted by Dan | Posted in Automation / Scripting, Python | Posted on 02-04-2010

0

In my last post, I made a quick script that checks for the date. It was very limiting, since it used the dir command. This one uses several date/time Python modules and is more capable.

import os, os.path, stat, time
from datetime import date, timedelta, datetime
 
# Reference
# http://docs.python.org/library/datetime.html
# http://docs.python.org/library/time.html
 
def getFileDate( filenamePath ):    
 
  used = os.stat( filenamePath ).st_mtime      
  year, day, month, hour, minute, second = time.localtime(used)[:6]
  objDateTime = datetime(year, day, month, hour, minute, second)
 
  return objDateTime
 
  # Ways to reference this DateTime Object
  # objDateTime.strftime("%Y-%m-%d %I:%M %p")
  # objDateTime.year
  # objDateTime.month
 
 
def isDaysOldFromNow( filenamepath, days ):
 
  # Checks how old a file is. Is it older than "days" [variable] days?
  inTimeRange = False  
  timeDeltaDiff = ( datetime.now()-getFileDate( filenamepath ) ).days
 
  # Check if the file's date is days old or less:
  if ( timeDeltaDiff >= days ):
    inTimeRange = True  
 
  return inTimeRange
 
fname = "C:/temp/decision2.pdf"  
 
# Set this variable to check if the file is this days old
howOld = 3
 
 
if ( isDaysOldFromNow( fname, howOld ) ):
  print fname, "is more than", howOld, "days old"
else:
  print fname, "is NOT more than", howOld, "days old"

Output: