Monday, April 22, 2013

Mxdperfstat 10.1 Download MXD Performance Statistics

If you are here chances that you were like me searching for an ArcGIS 10.1 version of this wonderful tool. Well, there isn't any, but I managed to make it work by copying some 10 dependency dlls. (Version , System and few others, took me awhile to figure them out)

If you don't know what this tool is, this is it's description from ESRI site

MXDPERFSTAT (ArcGIS 10 and 93) can help diagnose typical MXD document performance problems, e.g. 
• Inefficient scale dependency 
• Slow symbology 
• Large features 
• Projection on the fly 
• Potential database tuning 

System Requirements: 
1. Microsoft .Net Framework 
2. ESRI .NET Assembly 10 or 9.3.1 
a. ArcGIS Desktop with .Net support or 
b. ESRI Engine Runtime 
3. ESRI license: 
a. ArcGIS Engine runtime or 
b. ArcGIS Desktop

This tool will work on ArcGIS 10.1, extract and use,

Download here

If you want the 9.3 or 10 version of this tool click here.

Friday, April 19, 2013

Fetch URL Text from Android/Java Application

I searched a lot for a straight forward clean multithreaded code to do this simple task, read data from a URL and get the output. All I found were segments of codes that force close.

So I wrote a simple class do this task.

Create a new Class name it FetchURL and past this whole thing into it.

//Hussein Nasser 19-4-2013
//www.husseinnasser.com 
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
 public class FetchURL {

 private String output;
 private String url;
 
 public FetchURL()
 {
  output = "";
 }
 
 public String getOutput()
 {
  return output;
 }
 
 
 public void Run(String u)
 {
   url = u;
    Thread t =  new Thread() {
         
       public void run() {
                   
         // Toast.makeText( mycontext , "running thread bitch", Toast.LENGTH_LONG).show();
                   
                    URL textUrl;
               try {
                 
                textUrl = new URL(url);
                
                BufferedReader bufferReader = new BufferedReader(new InputStreamReader(textUrl.openStream()));
                 
                String StringBuffer;
                      String stringText = "";
                while ((StringBuffer = bufferReader.readLine()) != null) {
                 stringText += StringBuffer;
                }
                      bufferReader.close();
                 
                      output = stringText;
                    
               } catch (Exception e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
                 
                output= e.toString();
               }
              
                }
            };
             
           t.start();
      try {
   t.join();
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  
 }
 
 
 
 
}



To use the code in your main activity

//Create an Instance of our Class
     FetchURL fu = new FetchURL();
     
     //run this shit (this will pause your current activity until you get the result, this should return 123 
     fu.Run("http://geshout.com/version.txt"); 
     
     //You are clear, your activity is now active and get your string and do Whatever you want 
     String o = fu.getOutput();
     
     //Cheers!
     Toast.makeText(this, "output " +   fu.getOutput(), Toast.LENGTH_LONG).show();
     

This code allows you to read and execute PHP URL, almost anything that returns HTML I guess, anyway report any bugs to me. This code uses threading to execute the network capability And oh, make sure you have the internet permission on your Android Manifest.

Wednesday, January 16, 2013

.NET Microsoft Performance Counter does not match Task Manager

I have been struggling with this for a while now. I was asked to display the CPU usage for a list of windows servers remotely from one machine. So I wrote a piece of code that does just that using the Performance Counter. Only to find out that it returns inaccurate CPU data. I tried reading more than once, taking the normal distribution of a list of values nothing worked.

After a while it appears that you have to read .netValue once then sleep a while then read it again . Yes that is it. This fixed the problem.
Here is the code to get the real value of CPU matching the Task Manager


    Public Function getCPUPerformance(ByVal remoteHost As String) As String

        Dim userHandle As New IntPtr(0)
        LogonUser("username", "domain", "password", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, userHandle)
        Dim identity As New WindowsIdentity(userHandle)

        Dim context As WindowsImpersonationContext = identity.Impersonate()
        Dim cpuUsage As PerformanceCounter

        cpuUsage = New PerformanceCounter("Processor", "% Processor Time", "_Total", remoteHost)

        Dim val1 As Single = cpuUsage.NextValue()

        val1 = cpuUsage.NextValue()

        Thread.Sleep(50) 'You have to Sleep, otherwise you will get kinky results    
  
        val1 = cpuUsage.NextValue()


        Return val1

    End Function





Monday, December 24, 2012

ESRI: Registration Failed, Could not write to disk.

ESRI, ESRI ESRI...

You get everybody confused with your messages.

Why it happens?
Chances that you are here because you encountered this error and you don't know how to fix it. Well the fix is easy but ESRI like to waste your time instead of displaying a little more informative message it just slam whatever the OS returns right back at you.


Anyways, this error usually appear because you were trying to install a new extension on your ArcGIS desktop environment (I assume 10 and above). It ESRIRegAsm.exe to register their dlls, whatever launches this executable must have Administrator privileges because 


The Fix
Run as Administrator. 


If you are running ESRIRegAsm.exe manually, run the Command prompt (cmd) as administrator.

If this error pops up because you installed some exe setup file, then run this setup file as administrator. 

If you are running an MSI file (Windows Installer, they look like this ) , for some reason you cannot right click and run as administrator, so you can use this method.

P.S.: Yes, you have to run as administrator even if you are an administrator on that machine, yeah, don't ask.

Tuesday, December 18, 2012

He's dead, Jim! [Chrome Error]

Its the 18 of December, I just returned to work from a 4 days vacation national day. I started checking my blog only to get this new error message from google chrome that I never seen before.



Who is Jim Google?

Monday, November 26, 2012

First Android Game: Guess the Shoes





Really simple game I wrote for android phones just for the ladies, guess the shoe designer and get points , score as much as you can!

Download game here





Thursday, September 13, 2012

Stock Market vs Moon Phase


Moon Phase vs Stock Change


Stock Market has been always tricky and unpredictable, financial analysts come up with theories everyday to predict the drop or increase of a given stock market. They do this by analyzing many factors including politics, yet analysts keep getting dazzled on how the market can get kinky sometimes.

OK, we keep linking the price change to parameters in our daily life, some war in Greece, or some new Apple product but why we didn't think of projecting this stock change against something global? Something that we can't control, something from nature, something politics can't control, something beyond earth. I'm not really being superstitious here its just when I tell you what I found It will give you some fruits for thought.

The Work

Now I have dates and I have prices, I can extract Year, Month and Day from the date but with some little work and a help from the startdate guys I can calculate, yes, the phase and illumination factor of the moon and then project it on the price. To try that out I selected Ahli United Bank (AUB) as my testing subject, and pulled 2600+ worth of stock data prices since 2000 till 2012 from the Bahrain Stock Exchange. I Formatted  the data and post it to Google Spread Sheet.

After that I used Google Visualization API to create some sexy charts out of that. In a nut-shell, this is my result. click down to see the website.



Here are some snap shots









Findings

  1. 2012 AUB New Moons are 93% safe, they either Hold the stock price or increase it. So if someone wants to sell its good to select a New Moon date (Somewhere between 15 and 16 September). Lets monitor that until the rest of the year.
  2. 2012 AUB Waxing Gibbous Moon  (Near to a Full Moon)  (Spans from 24-27 September)  is dangerous there is a 50% chance that the stock will drop.
  3. So I would say for AUB it is good to buy on Waxing Gibbous Moon days for AUB and then sell them on the next New Moon.
  4. Each year the correlation differs for some reason if I bring another variable into the story I might find the relation.



Now the findings might differ of course from one company to another but it is essentially the formula.

Visit the website and you can even find more.

Disclaimer: This is just fruit for thought, a new edge if you will. I searched the net and no body have done it before so I said why don't I do it.



Sunday, August 26, 2012

Gauss hacks its way into National Bank of Bahrain Internet Banking [VIDEO]





Apparently Gauss Worm was not satisfied by just hitting BBK as it is seeking it's way through NBB's Internet Banking as well. Here is a video that shows how it can pulls customers credentials easily from NBB secured internet Banking

Refer to original post for details of how to prevent the worms effects Gauss Worm Targets Bahraini Banks [BBK].


Watch Video


Here is a YouTube Version


Saturday, August 25, 2012

Meet gamika, an empty page, unlimited possibilities




twitter, facebook, ask.fm, yahoo answers, wikianswers, and many more.

These are services created so that people like you and me share their thoughts, questions, opinions and theories with others. 

So what is the problem of these services? They need to know who are you, they need to register your name, email, numbers, references, address and so much more. They eventually violate your privacy.

We tend to think twice before writing anything in these services, because they know us, they know what we are doing, they track us, they target us with ads, and people following us will judge our tweets, status updates, questions and all of it.

There is no empty page on the web where anyone can write anything they are thinking of where everybody can see. No registration.

gamika.org was built just to do that.

go write something now



Hussein Nasser



Wednesday, August 22, 2012

Which Online ?






Which Online Marketing method is the best?

Which Online Banking is the most trustworthy?

Which Online Shopping site is the busiest?

Which Online Security algorithm is the most efficient to be used to secure the web?

Which Online Cloud storage will prevail?

Which Online compressing algorithm can be used to replace ZIP and RAR?

Which Online Gaming zones are the fastest?

Which Online Streaming Movies website are available?

Which Online radio are in the market?

Which Online sports channel are the easiest to subscribe to ?

Which Online cars broker sites can I use?

Which Online Money currency to replace the dollar?

Which Online Payment methods are the most secure and efficent?

Which Online Chatting Apps are the most flexible and easy to use?

Which Online Live News site shall I follow to know everything?

Which Online Fashion Designers recommendation shall my wife subscribe to?

Which Online Cartoon Network shall I let my kids in?


Everything is moving online, there are plenty and abundant of ideas, stop keeping your ideas secret, no one will try to steal it.

Ideas in secret die. Select an Online Idea and go do it.