java.lang.OutOfMemoryError: GC overhead limit exceeded

How To Count Lines of Code in Visual Studio

22. November 2011 02:00 by Scott in Visual Studio, Tricks  //  Tags: , , ,   //   Comments (0)

Measuring programming progress by lines of code is like measuring aircraft building progress by weight. - Bill Gates

 

If your like me, then you want to know at times how many lines of code you have written over the years.  I have this one web site that I thought would be roughly 200,000 lines of code.  Its over at Utopiapimp.com.  I questioned today how many lines of code I have when I was in discussion with one of my coworkers.  He didn’t think that my website offered that much and well, I had to prove him wrong.  So in figuring out how many lines of code I wrote, I had two different ways.  Here are the ways.

When using Visual Studio Team System:

Analyze -> Calculate Code Metrics has the ability to count projects of code, but not actually web forms applications.  The problem with this, is that I actually have a website and not an actual C# project, So I used the second method.

Visual Studio Trick:

This method will will match every line that are not comments (//), a compiler directive (starts with #), a single opening or closing brace, or blank lines. So these are true lines of code.

  • Select Edit -> Find & Replace -> Find in files… or just press CTRL+SHIFT+F
  • Check Use and select Regular expressions.
  • Top Left Drop down using the Find in Files Selection
  • Type the following as the text to find:

for C#

^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@/#).+

for VB.NET (thanks Steve for the info!)

^~(:Wh@'.+)~(:Wh@/#).+

 

  • If you select Current project or Entire solution, you also need to specify the file types that will be included in the search.

Proceed with the “search” and at the bottom of the Find results window you will see the total line count.

Draw a Circle Graphic with ESRI Android SDK

14. November 2011 12:56 by Scott in Development, ESRI  //  Tags: , , ,   //   Comments (3)

I wrote this code a while back.  The requirement was to have a user draw a circle with the ESRI Android SDK.  Well, their Android SDK doesn't currently support drawing circles.  It draws all other types of polygons except for the circle.  So what does a Software Engineer do, we come up with our own implementation.

So for the world to see, here it is:

First we capture the OnMotionEvent and the comments are in line.

Hope this helps someone.

    public boolean onDragPointerMove(MotionEvent from, MotionEvent to) {

        if (tempCircleGraphic != null)
            _graphicsLayer.removeGraphic(tempCircleGraphic);

        // creates a new polygon to be drawn.
        _circleTemp = new Polygon();

        Point point = _map.toMapPoint(to.getX(), to.getY());

        // If the starting point is null, create a polyline and start a
        // path.
        if (_startPoint == null) {
            _startPoint = _map.toMapPoint(from.getX(), from.getY());
            // creates a polyline so we can measure the radius of the
            // person
            // drawing the circle.
            _polylineTemp = new Polyline();
            // starts the poly line
            _polylineTemp.startPath(_startPoint.getX(), _startPoint.getY());
        }
        // continues the draw of the poly line
        _polylineTemp.lineTo((float) point.getX(), (float) point.getY());

        // calculates the circle when getting ready to be drawn.
        int pointsAroundCircle = 50; // N
        double radius = _polylineTemp.calculateLength2D(); // radius
        for (int i = 0; i < pointsAroundCircle; i++) {
            double fi = 2 * Math.PI * i / pointsAroundCircle;
            double x = radius * Math.sin(fi + Math.PI) + _startPoint.getX();
            double y = radius * Math.cos(fi + Math.PI) + _startPoint.getY();
            if (i == 0) // starts the drawing of the circle. if
                        // beginning
                        // the for loop
                _circleTemp.startPath(x, y);
            else if (i == pointsAroundCircle - 1) // ends the circle
                                                    // when at
                                                    // the end of the
                // for loop.
                _circleTemp.closeAllPaths();
            else
                // continues drawing the cirlce while it iterates
                _circleTemp.lineTo(x, y);
        }
        // creates a new graphic and sets the geometry to a polygon.
        Graphic graphic = new Graphic();
        graphic.setGeometry(_circleTemp);

        int drawColor = getDrawColor();
        int transparentColor = Color.argb(POLYGON_ALPHA, Color.red(drawColor),
                Color.green(drawColor), Color.blue(drawColor));
        SimpleFillSymbol fillSymbol = new SimpleFillSymbol(transparentColor);
        graphic.setSymbol(fillSymbol);
        
        tempCircleGraphic = graphic;
        // add the updated graphic to graphics layer
        _graphicsLayer.addGraphic(graphic);

        // Refresh the graphics layer
        _graphicsLayer.postInvalidate();
        return true;

    }

java.lang.RuntimeException: Stub! On With JUnit and Android

2. November 2011 10:35 by Scott in Development, Android  //  Tags: , , ,   //   Comments (34)

Running into another Error I figured I would blog about.

So im getting a Stub Error while trying to JUnit test a library I built with some Android code inside of it.  The Error is as follows:

java.lang.RuntimeException: Stub!
    at android.graphics.Color.rgb(Color.java:9)
    at com.irad.conversion.gml.GmlConverter.GetAttributesFromGml(GmlConverter.java:446)
    at com.irad.conversion.gml.GmlConverter.ConvertGmlPolygonToGraphic(GmlConverter.java:562)
    at com.irad.conversion.gml.GmlConverter.ConvertGmlToEsriGraphic(GmlConverter.java:114)
    at com.irad.conversion.gml.test.GmlConverterTest.ConvertGmlToEsriPolygonRingsGraphicTest(GmlConverterTest.java:194)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

While, I couldn't figure out what was going on, I kept getting a message of Stub while running some Android API code.  Keep in mind I was testing with JUnit outside of the official Android Test Project.  And in that lies the problem.

Solution:

In order to run Android API code, you MUST run it on the emulator.  Which to me stinks and for something as easy as converting colors like I was feels needless, but I guess I must now convert all my JUnit tests to the Android JUnit Project Sadly.

Developer Income Report #2

1. November 2011 08:08 by Scott in Developer Income Report  //  Tags:   //   Comments (0)

The Intro:

Starting off with my first report, well here now is my second report.

Ive been developing web apps since 2007 and while modest income has come from them, I decided to focus solely on one real idea.  Most of my ideas in the past have been simple and fun, while this idea will truly turn into a company.  So lets go ahead and tell you.  I have built a few apps listed here and while none of them bring in a great deal of money, I have learned a great deal from them.  So lets go ahead and start it off.

The Money:

DrinkingFor.com, UtopiaPimp.com, ItFeelsLike.com, DemotivatedPosters.com, and PostSecretCollection.com all have the same online advertising tied to them because mainly they don't all garner enough hits to do well on the advertising platform I like to use.  The only one that garners well over 2 Mil page views a month is Utopiapimp.com, and while thats pretty significant, its an application that supports a very popular online game and web games don't make nearly enough in Ads to be well off.

So last month, I made +$118.00 from these sites. which sadly is about $30.00 less than last month.

I haven't built any new applications as a contractor since Audingo. App is Here, but I wish to.  If you know anyone that needs Mobile/Web/Desktop development in C# and Java, Im here to help and can be contacted at spoiledtechie&&gmail.com. I just had a baby and while insurance does cover most medical expenses, it didn't cover them all.

Two months ago, I built another Android Application for my self.  While it hasn't garnered much in the way of cash yet, it has been a huge hit among the Roller Derby crowd! 

I made +$6.09 from this past month.  Nothing to go home about, but its a lunch.

And to Pay for server costs for my various Web Apps, I paid out -$85.00 this month. I use a Virtual Server which costs only$45.00, but I have a few upgrades with these guys.

So for the Month of October, I made a total of +$39.09 this month in my spare time.

Whats Next?

I was planning to build out another web app and sadly its about 75% done to beta test.  But I have to focus on another project due to a new team member coming on board.  There has been a project I have been wanting to build for a while now and my team mate joined my team just for this project.  So in the coming weeks and months, I will be building something soo great, its going to change the way an entire way of thinking and executing is made.

Problem with Running Tomcat with Eclipse

26. October 2011 16:53 by Scott in   //  Tags: , , ,   //   Comments (0)

I had a problem running Tomcat through eclipse and received this error:

Port 8080 required by Tomcat v7.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

I needed to figure out what was running on port 8080 and couldn't find any other tomcat item.  I needed to shut down what ever was running on port 8080 so I could run tomcat through eclipse.

So this is what I figured out.

  1. Run this command: NETSTAT -p tcp -ano
  2. find the service running on 8080.
  3. read the PID.
  4. Press Ctrl+Alt+Dlt and go to the processes tab.
  5. Goto View->Select Columns-> Enable the PID column.
  6. Find the PID that matches your cmd list results and go ahead and kill it.

That should work and glad I could help.

Here's To the Crazy Ones

6. October 2011 09:19 by Scott in Apple  //  Tags:   //   Comments (6)

 

"Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They’re not fond of rules. And they have no respect for the status quo.

You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They push the human race forward.

And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do."

RIP Steve Jobs.

Developer Income Report #1

3. October 2011 00:22 by Scott in Developer Income Report  //  Tags:   //   Comments (0)

The Intro:

I decided that I need to start writing my income out to both the world and for my self following this the reports posted here.  So A little intro.  Ive been developing web apps since 2007 and while modest income has come from them, I decided to focus solely on one real idea.  Most of my ideas in the past have been simple and fun, while this idea will truly turn into a company.  So lets go ahead and tell you.  I have built a few apps listed here and while none of them bring in a great deal of money, I have learned a great deal from them.  So lets go ahead and start it off.

The Money:

DrinkingFor.com, UtopiaPimp.com, ItFeelsLike.com, DemotivatedPosters.com, and PostSecretCollection.com all have the same online advertising tied to them because mainly they don't all garner enough hits to do well on the advertising platform I like to use.  The only one that garners well over 2 Mil page views a month is Utopiapimp.com, and while thats pretty significant, its an application that supports a very popular online game and web games don't make nearly enough in Ads to be well off.

So last month, I made +$152.00 from these sites.

I recently got into building Android Apps at work and that has pretty much pushed me to do so in my free time.

So two months ago, I created an Android Application for Audingo. App is Here.  I did this for a start up out of Texas.

I made +$5,000 for one months worth of work on building their Android App.

This past month, I decided to do another Android Application for my self.  While it hasn't garnered much in the way of cash yet, it has been a huge hit among the Roller Derby crowd! 

I made +$10.32 from this past month.  Nothing to go home about, but its another few bucks in the pocket.

And to Pay for server costs for my various Web Apps, I paid out -$85.00 this month. These guys are awesome and by far the cheapest dedicated hosting I could find!

So for the Month of September, I made a total of +$5,077.32 this month in my spare time.

Whats Next?

In the coming weeks, I plan on releasing another web application for my various web apps I currently own.  This web app will hopefully allow for better user feedback that I can implement into my various websites later on.  Sort of like the circle of life, but this way its Developer -> User -> Developer driven.

Java JPA Doesn’t Show Updates to tables

15. September 2011 17:21 by Scott in   //  Tags: , , ,   //   Comments (27)

There was a problem one of my peers found with Java JPA that got him stuck for a few hours.  He told me to blog about it so here it is.

When you use the JAVA JPA library.  You will pull results from the database.  That’s exactly what the JPA lib does.  Its like LINQ, but for Java.

So here is the problem.  When pulling results from the JPA objects from the database, the JPA then caches all the objects.  So every time after that, the cached results get returned instead of the most important information just placed in the Database.  So, in order to get around this, you must call the “refresh” method.  Or at least that’s what he told me to say.  That method will then hit the DB again for another round trip and update all the objects on the JPA side.

That is all.

Fucking Big Company Rules

12. September 2011 10:05 by Scott in   //  Tags:   //   Comments (20)

So I work at a large company, with well over 75,000 people.  Its extremely large and the bureaucracy sucks.

A developer and I built this state of the art product on the Android phone.  It can be ported over to the iPhone and the WP7.  This product is soo revolutionary, it has the ability to put an entire product out of business.  A product that is soo incredibly important to man kind, that without its use we as a Human race could all suffer deadly consequences without its use.

This Android product takes over the roll of the product.  Instead of costing nations (yes, nations) a couple thousand dollars for EACH device, my company could inevitable put this application into the hands of every single person with a mobile phone.  Therefore, entirely disrupting and of course saving tax payers millions over time.  And not to mention, this product could be used by everyone in the world.

But what does my company do?  They decide that placing apps on the marketplace will not return enough revenue to make this product worth while.  Even charging $10.00 for a product like this, they decide against it.  This product has the potential to save millions of lives when disaster strikes, but what do they do?  The bury it.  The put it into a hole and never think about it again.

So what do I do?  I can’t do anything.  If I were to write my own application, I would be sued for millions.  Taken to court and most likely lose my job over it.  I am also bound by certain contracts signed when I first started here.  Anything I build, my company owns.  My working peers around me say, I should write a brand new application and just release it.  It would make the world a better place, so just do it.

I am looking for advice here.  For some help and guidance.  Do I do my own thing to “help make the world a much safer place to live”?

MSSQL Server – Delete Duplicate Rows – Records

11. June 2011 01:59 by Scott in   //  Tags:   //   Comments (8)

This is how I delete duplicate rows from the database.

DELETE
FROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)