Saturday, November 12, 2011

Démontrer que I=]0,1[ n’est pas compact en utilisons l’axiome C1

Solution d' un problème d'analyse du cours d'analyse 1 niveau université:
Démontrer que I=]0,1[  n’est pas compact en utilisons l’axiome C1
Axiome C1:    De tout recouvrement ouvert de I  il existe un sous-recouvrement fini.



Pdf link

f application croissante et la limite à gauche en x0

Solution d' un problème d'analyse du cours d'analyse 1 niveau université:

Soit f une application de R=>R ,avec f croissante et la limite à gauche en x0, f(x0 -0) existe.

Démontrer que f(x0 -0) = sup(x<x0) {f(x)}


Pdf link

Programming

Programming is the collection of processes and implementations that a programmer is conducted to for providing a solution to a physical or abstract problem arising in different domains: business, science, engineering, etc… The programmer is the person who analyses and formulates his or other needs in an abstract manner and then provides the concrete implementation and solution to the problem.

In programming problems needs to be formulated in a clear way: no uncertainty is acceptable in the program execution. The program needs to be well abstracted and implemented using well known paradigms and conventions. The programmer is not born with all required skills and professionalism. His skills increase with time and experience, in a way that his productivity increases. A good programmer needs to write clean code, and he must always have in mind that someone will come after him and reviews or maintains the program’s code.


The problem that the programmer resolves must be well understood and then it will be dissected into several parts and modules which cooperate and communicate to achieve a certain goal. This dissection must have in mind data and process flexibility in both program’s input and output.

Friday, November 11, 2011

Tracking system

The Tracking system is a collection of cooperated subsystem and devices providing vehicles and site supervision and monitoring. This system works from the hardware level (Tracking device and sensors) to the software high level in a coordinated way based on several protocols. The system is designed to make usage and generate reports based on device’s collected data. It can be separated into two parts:
1. Device communication
2. Monitoring system
The first part handles the generation, transport and saving of device’s events. The customer doesn’t need to be aware of this part. The customer’s role and intervention are in the second system which can be a combination of several subsystems such as a web application, localized software, mail notification, etc…

Saturday, December 11, 2010

Parsing XML using linq with c# 3.5

In this post i will include the c# (linq) code necessary to read an xml file containing definition of a list of device Ids and descriptions.
input:  String localDirectory pointing to the location of xml file to be read and parsed.
output:  ArrayList of devices parsed from the XML file.

Note: a device can be any object you want.

  
 mkrs1000
 rs1000 with output
  
  
  
 rs1100
 rs1100 demo
  



// code converting xml file to arrarylist of devices
XDocument document = XDocument.Load(localDirectory);

List<device> listOfDevices = document
   .Descendants("device")
   .Select(device => new Device
   {
       DeviceID = device.Element("deviceId").Value,
       DeviceDescription = device.Element("deviceDesc").Value
   })
   .ToList();


foreach (Device device in listOfDevices)
{
 string s = String.Format("ID: {0,-20} : Desc = {1}", device.DeviceID, device.DeviceDescription);
 Console.WriteLine(s);

}

// class representing an xml node (can be any object you want)
class Device
{
    public string DeviceID { get; set; }
    public string DeviceDescription { get; set; }
}

Wednesday, November 24, 2010

How to fit a number in an array of numbers

The following code try to fit a number inside a list of numbers using the java language. 
  • The inputs to this program are the number to search: numberToSearch, and the List of numbers to fit the number in: targetList .
  •  The outputs are the lower bound: lowerBound , and the upper bound: upperBound , which are numbers from the list which encloses numberToSearch
The functions toArray and itemAt are taken from the OpenGTS (open source vehicle tracking system), whereas the function indexOfStable is based on the indexOf  function from the OpenGTS source code, and was modified by me in order to search the index of an object in an array by doing a comparison by reference not by value as the indexOf  function does.
..................................................................................................................................
..................................................................................................................................
  • Input: numberToSearch to fit into targetList.
  • Output: lowerBound <= numberToSearch <= upperBound where lowerBound and upperBound are conntained in targetList.


long numberToSearch= ....
List targetList= .....

Long lowerBound = targetList.get(0);
Long upperBound = targetList.get(targetList.size()-1);


Long numberToSearchByReference= new Long(numberToSearch);targetList.add(numberToSearchByReference);
Collections.sort(targetList);Long [] targetArray= ListTools.toArray(targetList, Long.class);
int index = ListTools.indexOfStable(targetArray, numberToSearchByReference);
       
if(index <= 0)
     return null;
else {
     lowerBound = ListTools.itemAt(targetArray, index -1, lowerBound);
     upperBound = ListTools.itemAt(targetArray, index +1, upperBound);               
}
 


...........................................................................................................................................................
...........................................................................................................................................................
The following function is based on the OpenGTS source code (ListTools.java) but was modified by me: 
public static <t> int indexOfStable(T list[], T item)
     {
         if (list == null) {

             /* no list */
             return -1;

         } else {

             /* constrain offset/length */
             int alen = (list != null)? list.length : 0;

             /* loop through array checking for item */
             for (int i = 0; i < alen; i++) {
                 if (list[i] == item) { // also takes care of 'null == null'
                     return i;
                 } 
             }

             /* still not found */
             return -1;

         }
     }
  
.......................................................................................................................
.......................................................................................................................
The following function is taked from the OpenGTS source code (ListTools.java)

public static <t> T itemAt(Collection<t> c, int ndx, T dft)
    {
        if ((c == null) || (ndx < 0) || (ndx >= c.size())) {
            return dft;
        } else
        if (c instanceof java.util.List) {
            // Randomly addressable list
            return ((java.util.List<t>)c).get(ndx);
        } else {
            // Serialized collection, iterate to item #ndx
            for (T obj : c) {
                if (ndx-- == 0) {
                    return obj;
                }
            }
            return dft;
        }
    }

.......................................................................................................................
.......................................................................................................................
The following function is taked from the OpenGTS source code (ListTools.java)

public static <t> T[] toArray(Collection list, Class<t> type)
    {
        if (type == null) { type = (Class<t>)Object.class; }
        if (list != null) {
            T array[] = (T[])Array.newInstance(type, list.size());  // "unchecked cast"
            return list.toArray(array);
        } else {
            return (T[])Array.newInstance(type, 0);  // "unchecked cast"
        }
    }

Friday, April 30, 2010

How to configure eclipse and tomcat to run remote debugging:

Check this link: http://wiki.apache.org/tomcat/FAQ/Developing and this link
http://it.newinstance.it/2005/10/04/remote-debugging-tomcat-with-eclipse/

http://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging


1)open catalina.bat and add the following lines :
set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=7945
Now stop tomcat from the services window if you have it installed as a service. Then run the following from a console:

[path to tomcat]\bin>catalina jpda start

In eclipse press Run->Debug Configurations..->Remote Java Application->press new button(on top)->
select the project : moodle-transfer -> enter as port : 7945 -> press Debug.
Now run the application in a browser after you have set a breakpoint in the source code,
then eclipse should propose you to turn to debug perspective, choose yes, then you should begin the debugging.
Note: if you get the following error: failed to connect to remote vm. connection refused. connection refused connect eclipse
then change the port number because it may be used by another application.