Monday, May 13, 2013

Viewing Files in the GAC

The GAC can be found at C:\windows\assembly.  There is a custom shell extension enabled that prevents you seeing the GAC dlls as you would normally see the file system in Windows Explorer.  There are several ways to see the dlls in the GAC.


Copy the DLLs to Another Location

Open the command prompt and type the following:

cd  c:\windows\assembly\GAC_MSIL
xcopy . C:\GacDump /s /y


Disable the Shell Extension in the Registry

Open the registry editor and add/set the HKLM\Software\Microsoft\Fusion\DisableCacheViewer DWORD value to 1.


Use the SUBST Command

Run the following command (assuming you don't already have G:) mapped.

> SUBST G: C:\WINDOWS\ASSEMBLY


References

http://blogs.msdn.com/b/johnwpowell/archive/2009/01/14/how-to-copy-an-assembly-from-the-gac.aspx

Thursday, April 11, 2013

Oracle Crib Sheet for MS SQL Server Developers


Oracle Gotchas

  • Table and column names can only be a maximum of 30 characters in Oracle. This can be a huge pain if you are migrating from SQL Server to Oracle.
  • Oracle is case sensitive by default.
  • Oracle uses a User concept where as SQL Server uses a Database to isolate database objects. 
  • Oracle doesn't have an autoincrement data type concept.  You have to use a sequence to get a  unique value.  Then you can can manually add this to the insert statement or use triggers so it happens automagically.

Limiting a Result Set

In SQL Server I commonly use the TOP operator to limit a result set. In Oracle the TOP operator is not available. In Oracle you can use ROWNUM to limit a result set.


select *
from emp
where ROWNUM <= 5
order by sal desc;

Capturing Queries

I haven't found a tool as convenient as sql profiler for capturing queries in the Oracle world.  In the Oracle world you query the v$sql table to get the sql statement that have been run against your database.

select * from v$sql order by last_load_time desc;

Here is one way to get the expensive queries in Oracle.

select * from
(select t.sql_id, sql_fulltext,p.operation,p.options from v$sqlarea t, v$sql_plan p
where t.hash_value=p.hash_value and p.operation='TABLE ACCESS' and
p.options='FULL'
and p.object_owner not in ('SYS','SYSTEM')
order by DISK_READS DESC, EXECUTIONS DESC)
where rownum <=10;

Insert Data From Another Table or View

Oracle doesn't support the following insert style.

SELECT existing_columns
INTO target_table
FROM source_table 

Data Types

Oracle doesn't have a native Guid data type.  In Oracle the preferred data type for a guid is RAW(16).

Oracle doesn't have a boolean (bit in sql server) data type.  The recommended data type is Number(1) or char.

Case Sensitivity

Oracle is case sensitive by default.  SQL Server is case insensitive by default so you may need to alter your indexes to avoid table scans.  Function based indexes to the rescue!

CREATE INDEX HR.Employee_idx ON HR.Employee (LOWER(FIRST_NAME));

References:

http://docs.oracle.com/cd/E10405_01/doc/appdev.120/e10379/ss_oracle_compared.htm





Function based indexes:
http://docs.oracle.com/cd/E11882_01/server.112/e25789/indexiot.htm#CNCPT1161

Sunday, January 6, 2013

Knockout JS Samples Converted to Backbone JS

Introductory Examples

Here are several Knockout JS examples converted to Backbone JS. I am primarily doing this as a learning experience. Please provide feedback. I left some console.log statements in the backbone examples so the example may not work if you aren’t using a browser that has native console.log support.

Wednesday, September 12, 2012

Github is a Ripoff

Github is a Ripoff

Github charges you for private repos. It doesn't matter the size of the repo or usage of the repo… just that you have a dang repo. Their price structure is the following:

$7/month 5 private repos
$12/month 10 private repos
$22/month 20 private repos

The pricing structure is ridiculous for my use case of making many small mobile apps for different platforms. Queue some blaring horn intro music… Bitbucket has free unlimited private repos! Let me say that again… FREE UNLIMITED private repos! Also, they support mercurial and git!

Bitbucket is awesome! Disclaimer -  I do want to throw a disclaimer out there… I love Github too… just not their pricing structure for private repos:)

Monday, August 6, 2012

Quartz.NET - Learning the new API

I am starting to look at Quartz .NET as potential task scheduler. I used the older version of Quartz.NET in the past and need to see review the new API. The latest version has a new fluent api. The first thing I check is, “Does Quartz .NET have a Nuget Package?”

Checklist

  1. Nuget package? Check
  2. Does Quartz .NET have a website with documentation? Check
  3. Is there a tutorial? Check
  4. Is the tutorial up to date? NO… see comments below.
  5. Is there a Github repo? Check

Quartz Terms

  • Job - The task or job you want to run.
  • Trigger - Trigger objects ‘trigger’ the execution of jobs.
  • Groups - Jobs and Triggers can be grouped together.

Out of Date Documentation

The tutorial is for the older version of Quartz .NET and is no longer applicable. Looking at the Migration Guide gives an example that doesn’t compile.
After some finagling with the code I came up with a simple working example:
// Simple working example
class Program
{
    static void Main(string[] args)
    {
        // construct a scheduler factory
        ISchedulerFactory schedFact = new StdSchedulerFactory();

        // get a scheduler
        IScheduler sched = schedFact.GetScheduler();
        sched.Start();

        IJobDetail jobDetail = JobBuilder.Create<SimpleJob>()
                                            .WithIdentity("job1", "group1")
                                            .Build();

        ITrigger trigger = TriggerBuilder
                       .Create()
                       .WithIdentity("trigger1", "group1")
                       .StartAt(DateBuilder.FutureDate(5, IntervalUnit.Second))
                       .WithSimpleSchedule(x => x.WithInterval(new TimeSpan(0, 0, 0,seconds: 5))
                                                                .RepeatForever())
                        .Build();

        sched.ScheduleJob(jobDetail, trigger);
    }
}

public class SimpleJob : IJob
{
    public SimpleJob(){}

    public void Execute(IJobExecutionContext context)
    {
        Console.WriteLine("SimpleJob is executing.");
    }
}

General Questions

  1. Does Quartz spawn new processes or use the thread pool? Uses the thread pool.
  2. How are the tasks executed? The tasks are executed asynchronously.
  3. How do you configure a job to run on a schedule, say every night at midnight?
        ITrigger trigger = TriggerBuilder
                      .Create()
                      .WithDailyTimeIntervalSchedule(x => x.StartingDailyAt(new TimeOfDay(23, 59)))
                      .Build();
    
  4. How do I stop a Job that is currently executing? See the Quartz.IInterruptableJob interface, and the Scheduler.Interrupt(string, string) method.
  5. How do I persist a job? Create the SQL Tables.
  6. How do I configure the scheduler using a config file? There is an example xml file in GitHub.

Pulling Down the Source

  1. Pulling down the source, since Quartz .NET, is in Github is fairly trivial.
    git clone https://github.com/quartznet/quartznet.git
  2. Next I had to copy nuget.exe to {clone directory}\quartznet.nuget.
  3. Finally I had to “Allow NuGet to download missing packages during the build” by going to Tools > Options in Visual Studio. 

Handy Code Snippets

  1. How you shutdown the scheduler
     sched.Shutdown( waitForJobsToComplete:true );
    
  2. Display some stats about the schedule that just ran
    SchedulerMetaData metaData = sched.GetMetaData();
    log.Info(string.Format("Executed {0} jobs.", metaData.NumberOfJobsExecuted));
    
  3. When a job throws an exception you can handle the exception and rethrow a JobExecutionException.
    try
    {
            int calculation = 4815 / denominator;
    }
    catch (Exception e)
    {
         log.Info("--- Error in job!");
        JobExecutionException e2 = new JobExecutionException(e);
    
         // fix denominator so the next time this job run
         // it won't fail again
          dataMap.Put("denominator", "1");
    
         // this job will refire immediately
    e2.RefireImmediately = true; // or e2.UnscheduleAllTriggers = true;
        throw e2;
    
    }

Reference Links

Monday, July 30, 2012

Boost Your Development, Use Twitter Bootstrap

Twitter Bootstrap is a great css framework to use when building websites. What makes Twitter Bootstrap so freakin awesome? It takes all of today’s best HTML and CSS practices and wraps them up into a very convenient package.
I have built 2 websites using Twitter Bootstrap and keep coming back to it for it’s pure awesomeness. The css provided in the Bootstrap framework is rock solid. The css naming convention followed through out is very semantic and clean.

Reset CSS

The css includes a good reset adapted from Normalize.css by Nicolas Gallagher.
Inside the default css there are two classes that I like to use no matter what css I am working with: clearfix and hidden.
.clearfix {
  *zoom: 1;
}

.clearfix:before,
.clearfix:after {
   display: table;
   content: "";
}

.clearfix:after {
  clear: both;
}
 ...
.hidden {
  display: none;
  visibility: hidden;
}

Icons

Bootstrap provides 140 eye pleasing icons built by Glyphicons.



Forms CSS

It’s important to be able to toggle vertical and horizontal forms via css in order to be able to rapidly change your layouts based on customer feedback. The Bootstrap framework provides tidy css to do exactly that. By flipping the css class from form-horizontal to form-vertical, you can make a wide horizontal form to be a vertically stacked input form.

12 Column Grid

The provided css grid framework is by default based on a 12 column grid which is my favorite number of default columns. A 12 column grid can be divided into halves, thirds, and fourths, so it’s an optimal number of columns for a default grid. The columns can be offset or nested.

JavaScript Plugins

Bootstrap also contains a nice set of JavaScript plugins. My 2 favorite jQuery control plugins Bootstrap has are the Tooltip and Popover controls. jQuery UI doesn’t even have these 2 plugins. I have found tooltips and popovers in general to be great helpers in building pleasing user interfaces.



I built a site that uses Twitter Bootstrap for a Nonprofit group called HorsesHelpingPeople. Twitter Bootstrap was a great tool that helped me build that site.
What do you think about Twitter Bootstrap? Would you recommend any library over Twitter Bootstrap?

Friday, July 27, 2012

How to Beat Apple


I am a long time Mac user, going on a little over 3 years as of today. I have been very satisfied with the entire Mac experience. One thing that blew me away when I got my first Mac was that I didn't have to download printer or scanner drivers. Every version of Windows, at that point in time, had required my to physically download and install the drivers for both my printer and scanner. There were a myriad of these “gee whiz” moments. Another example of a “gee whiz” moment is when I realized that my Mac was the first computer that could open a MS Word Doc without downloading more software.

As Apple gobbles up more and more mind share there are going to be problems with lack of competition, and that concerns me. Competition drives innovation. More companies need to be more competitive with Apple. I have been trying to formulate ideas on how to “beat” Apple.

Microsoft should do A or B immediately:

A.  Don't allow Windows 8 to run on Mac hardware.
B.  Get a vendor to build a virtual machine, similar to Parallels, to run Mac OS X.

Microsoft should bundle the equivalent of Dropbox as part of Windows 8. I have heard talk of this for Windows 8 but am not sure if it’s going to be there. Nintendo, Microsoft, or Sony should release an open platform handheld video game system that has a controller, stylus pad, and/or touch screen like the Nintendo DS.

I have really struggled with coming up with ideas on how to beat Apple. How do you think Apple can be “beat”?