Thursday, June 3, 2010

???

   1: int result= 2;   
   2: result = result<<2 +1;    
   3: std::cout << "Result is " << result << '\n';
   4: return (0);

Real Programmers

Real Programmers Don't Write Specs

Real Programmers don't write specs -- users should consider themselves lucky to get any programs at all and take what they get.
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand and even harder to modify.
Real Programmers don't write application programs; they program right down on the bare metal. Application programming is for feebs who can't do systems programming.
Real Programmers don't eat quiche. In fact, real programmers don't know how to SPELL quiche. They eat Twinkies, and Szechwan food.
Real Programmers don't write in COBOL. COBOL is for wimpy applications programmers.
Real Programmers' programs never work right the first time. But if you throw them on the machine they can be patched into working in "only a few" 30-hour debugging sessions.
Real Programmers don't write in FORTRAN. FORTRAN is for pipe stress freaks and crystallography weenies.
Real Programmers never work 9 to 5. If any real programmers are around at 9 AM, it's because they were up all night.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.
Real Programmers don't write in PL/I. PL/I is for programmers who can't decide whether to write in COBOL or FORTRAN.
Real Programmers don't play tennis, or any other sport that requires you to change clothes. Mountain climbing is OK, and real programmers wear their climbing boots to work in case a mountain should suddenly spring up in the middle of the machine room.
Real Programmers don't document. Documentation is for simps who can't read the listings or the object deck.
Real Programmers don't write in PASCAL, or BLISS, or ADA, or any of those pinko computer science languages. Strong typing is for people with weak memories.
Real Programmers only write specs for languages that might run on future hardware. Noboby trusts them to write specs for anything homo sapiens will ever be able to fit on a single planet.
Real Programmers spend 70\% of their work day fiddling around and then get more done in the other 30\% than a user could get done in a week.
Real Programmers are surprised when the odometers in their cars don't turn from 99999 to 9999A.
Real Programmers are concerned with the aesthetics of their craft; they will writhe in pain at shabby workmanship in a piece of code.
Real Programmers will defend to the death the virtues of a certain piece of peripheral equipment, especially their lifeline, the terminal.
Real Programmers never use hard copy terminals, they never use terminals that run at less than 9600 baud, they never use a terminal at less than its maximum practical speed.
Real Programmers think they know the answers to your problems, and will happily tell them to you rather than answer your questions.
Real Programmers never program in COBOL, money is no object.
Real Programmers never right justify text that will be read on a fixed-character-width medium.
Real Programmers wear hiking boots only when it's much too cold to wear sandals. When it's only too cold, they wear socks with their sandals.
Real Programmers don't think that they should get paid at all for their work, but they know that they're worth every penny that they do make.
Real Programmers log in first thing in the morning, last thing before they go to sleep, and stay logged in for lots of time in between.
Real programmers don't draw flowcharts. Flowcharts are after all, the illerate's form of documentation.
Real Programmers don't use Macs. Computers which draw cute little pictures are for wimps.
Real Programmers don't read manuals. Reliance on a reference is the hallmark of a novice and a coward.
Real Programmers don't write in COBOL. COBOL is for gum chewing twits who maintain ancient payroll programs.
Real Programmers don't write in FORTRAN. FORTRAN is for wimpy engineers who wear white socks. The get excited over finite state analysis and nuclear reactor simulations.
Real Programmers don't write in Modula-2. Modula-2 is for insecure analretentives who can't choose between Pascal and COBOL.
Real Programmers don't write in APL, unless the whole program can be written on one line.
Real Programmers don't write in Lisp. Only effeminate programmers use more parentheses than actual code.
Real Programmers distain structured programming. Structured programming is for compulsive neurotics who were prematurely toilet trained. They wear neckties and carefully line up sharp pencils on an otherwise clear desk.
Real Programmers scorn floating point arithmetic. The decimal point was invented for pansy bedwetters who are unable to think big.
Real Programmers know every nuance of every instruction and use them all in every Real Program. Some candyass architectures won't allow EXECUTE instructions to address another EXECUTE instruction as the target instruction. Real Programmers despise petty restrictions.
Real Programmers don't like the team programming concept. Unless, of course, they are the Chief Programmer.
Real Programmers have no use for managers. Managers are sometimes a necessary evil. Managers are good for dealing with personnel bozos, bean counters, senior planners and other mental defectives.
Real programmers ignore schedules.
Real Programmers don't bring brown bag lunches to work. If the vending machine sells it, they eat it. If the vending machine doesn't sell it, they don't eat it.
Real Programmers think better when playing Adventure or Rogue.
Real Programmers use C since it's the easiest language to spell.
Real Programmers don't use symbolic debuggers, who needs symbols.
Real Programmers only curse at inanimate objects.

Float integer

   1: int main()
   2: {
   3:      float result;      
   4:  
   5:     result = 1/3;      
   6:  
   7:      std::cout << "Result is " << result << '\n';
   8:      std::cin>> result;
   9:      return (0);
  10: }

Sonuç ??

Static C++

   1: #include <stdio.h>
   2: #include <iostream>
   3:  
   4: int first(void)
   5:   {
   6:       int i = 0; 
   7:  
   8:      return (i++);
   9:  }
  10: int second(void)
  11: {
  12:     static int i = 0;
  13:     return(i++);
  14: }
  15:  
  16:  
  17: int main()
  18: {
  19: int counter;
  20: for(counter = 0;counter <3 ;counter++)
  21: {
  22:     printf("First %d \n", first());
  23:  
  24: }
  25: for(counter = 0;counter <3 ;counter++)
  26: {
  27:     printf("Second %d \n", second());
  28:  
  29: }
  30: std::cin>>counter;
  31:     return (0);
  32:  
  33: }

sonuçlar

first 0 0 0

second 0 1 2

şeklinde.C# da bir fonksiyon içine static değişken tanımlanamazken c++ da tanımlabiliyor ve değer atansa bile sadece ilk oluşturur ken kullanıyor

Hata Nerede

   1: #include <iostream>
   2:  
   3: void main()
   4: {
   5:     std::cout<<"Hello World \n";
   6:     return (0);
   7: }

Wednesday, May 27, 2009

Reflector on the job

 

You have a list full of custom class items and want to find according to one property.Ok the best way is lambda functions(Or Not?).Other than lambda functions you can use reflection and use some code like:

 

public NeuronList FindByProperty(string PropertyName, object Value)
 {
     try
     {
         NeuronList foundItems = new NeuronList();
 
         foreach (NeuronBase item in List)
         {
             System.Type itemType = item.GetType();
             PropertyInfo[] itemProperties = itemType.GetProperties();
 
             foreach (PropertyInfo info in itemProperties)
             {
                 if (info.Name == PropertyName)
                 {
                     object itemValue = info.GetValue(item, null);
                     if (Convert.ChangeType(itemValue, info.PropertyType).Equals(Value))
                     {
                         foundItems.Add(item);
                     }
                 }
             }
         }
 
         return foundItems;
     }
     catch (Exception ex)
     {
         throw new Exception("Can not find property", ex);
     }
 }

Neural Networks

Have written a basic ann app which can do anything known about neural networks and has a simple ui, of course it needs lots of improvements but to get the basic idea you can take a look.

I am assuming you have some idea about neural networks

BaseNeuron is my neuron class which derives from user control. Input Neuron Middle Neuron and Output Neurons are derived from Base Neuron .Input Neuron is the neurons where you apply input output neurons are as name implies output :).Every neuron can be connected to another by synaps.A synaps becomes more powerful as it transmit signals

NeuralNetwork is our network and contains two collections inputneurons and neurons(middle and output).NeuralNetwork stores the fired neurons you can find all fired neurons in our network in nth turn.

NeuralPort is the ports where you can make connections(input and output) to ann.

NeuronList is our List that hold neurons and enables us to find desired neuron by neuronNo

NetworkVisualiser is the gui that shows our neural network connections and fired neurons.

Network builder is obsolete now network build her own.

I am uploading a copy in google code under hyacinth.

http://code.google.com/p/hyacinth/downloads/list

Wednesday, May 20, 2009

N-Depend

I have been busy with artificial neural networks for some time so couldn’t post much.

NDepend is a static code analyzer it inspects your code and tells dependincies metrics code analysis. I found metrics very useful.It tell if you used boxing if your namings are wrong, if you used wrong access modifier, you have too many fields.You can also write your own queries it uses cql code query language very similar to sql, You can select methods which returns int.

http://www.ndepend.com/ is the web page.

Take a look

Thursday, May 7, 2009

Hyacinth v1.1

I added some missing things to hyacinth my jabber client.She can now encrypt messages .

Monday, April 27, 2009

Pollard’s Rho factoring algorithm in C#

Pollard’s rho algorithm is used to factor composite integers. Suppose you have 8633, 89 *97 are the factors.

Here is the code:

static void Main(string[] args)
        {
            Int64 a = p.PollardRho(12187823);
        }
        public Int64 customFunct(Int64 param, Int64 mod)//Custom number generator
        {
            return ((param * param + 1 )% mod);
        }
        public Int64 PollardRho(Int64 number)
        {
            Int64 a = 2, b = 2, tmp;//initail starting values
            while(true)
            {
            a = customFunct(a,number);//get first number
            b = customFunct(customFunct(b,number),number);//get second double run custom func
            tmp = GCD(Math.Abs(b-a), number);// if a =  b mod d(divisor one of the divisors of our number) then a-b is multiple of d and number is multiple of d 
            if (tmp > 1)
                break;
            }
            return tmp;
        
        }
        public Int64 GCD(Int64 x, Int64 y)//Greatest Common Divisor
        {
            if (x == 0)//Find it? return
                return y;
            if (y == 0)//Find it? return
                return x;
            x = x % y;// take the mod of the large val to small one if the order is wrong in the next recursive loop it will be correct
            return GCD(y, x);//Parameters changed place
        }

I put comments on the code and included usage.The code includes a custom function you may experiment with and a greatest common divisor calculator.