יום שישי, 7 במרץ 2014

Open stack cinder block

I have found the following blog post regarding Open Stack cinder block:
laying-cinder-block-volumes-in-openstack-part-1-the-basics
Cinder allows to attach external  storage volume into the cloud in addition to the instance ephemeral storage

The cinder api can be found here :
cinder api
Allows to create volumes , update volumes , delete volumes , list volume information
Handle snapshots

Map interface design review

Last week I had design review session about Map wrapper interfaces.
The interface is part of a module that allows a programmer to switch map infrastructure implementations within its product transparently  to the logic of the UI layer 

Part of the proposed interface looks something like this :
Capture28
The goal of the MapSurface interface is to allow adding drawing annotations on the map like routes , spots areas etc.

Prons

1.KISS:
Very simple interface allow the programmer quickly learned how to use it even without documentation and code samples . 


Cons

1.Open close principle violation:
In order to add handling for new widget type for an example a closed curved etc the IMapInterface  should be changed .

2.The interface does not allow me to use the created route in a surface of a map in other window .


 

 

 

יום שבת, 19 באוקטובר 2013

Configure netbeans for Php debugging

In order to allow Php debugging on NetBeans IDE 7.4 I did the following steps :

1.Change the php ini file as follow :
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "C:\xampp\tmp"

The php ini file is located under :
C:\xampp\php\php.ini

2.Make sure that the tools – options  in the netbeans is like this
Capture1

The project properties :
Capture2
Restart the xamp apache server .

and walla

Capture3

יום שבת, 7 בספטמבר 2013

Ruby –The Redo command

Ruby has a three loop controlling command : Break , Next and Redo ,while the Break and the Next command has equivalents in all other languages Redo is unique to Ruby .

Redo acts like next except it doesn't evaluate the while condition .

example:

  1: while line = gets

  2: puts line 

  3: break if line =~ /^STOP/ # stop at end

  4: redo if line.gsub!(/^STO/) { line = 'STOP'}

  5: end

The result :
ee
ee
sto
sto
STO
STO
STOP

יום שבת, 27 ביולי 2013

c++ cross compilation for my raspberry pi

C++ cross compilation should be a very simple and intuitive task especially using the  new eclipse Kepler that’s already contains all the integration ingredients .
If a problem comes out  95% is because of bad toolchain. ( that cause linking problems and segmentation faults when  you finally overcome the linking problems )
I fount the following source for raspberry pi toolchain working:
$ wget https://s3.amazonaws.com/RTI/Community/ports/toolchains/raspbian-toolchain-gcc-4.7.2-linux64.tar.gz

Please Note :
Use the proper toolchain version according to your compilation machine (32 or 64 bit ).
If segmentation faults error appear to to compile the program with “static” flag .

Resources:
http://www.xappsoftware.com/wordpress/2013/02/07/using-ubuntu-to-cross-compile-for-raspberry-pi/

יום שישי, 12 ביולי 2013

Pax in work

The pax tools are collection of tools for OSGI
Pax Construct:set of scripts,  that automates the creation,building, and execution of OSGi projects.

Download Pax:https://ops4j1.jira.com/wiki/display/paxconstruct/Download

C:\devtools\Osgi\pax>pax-create-project -g learn.myProject -a dwmj -v 1.0.0-SNAP
SHOT

..\pax-provision

 

https://ops4j1.jira.com/wiki/display/ops4j/Pax
http://wiki.ops4j.org/display/ops4j/Pax

Java Serialization

The pojo object

  1: package playwithserialization;
  2: 
  3: import java.io.Serializable;
  4: import java.lang.reflect.Field;
  5: import java.util.Date;
  6: import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
  7: 
  8: /**
  9:  *
 10:  * 
 11:  */
 12: public class LogMsg implements Serializable {
 13: 
 14:     public Date getDateTime() {
 15:         return DateTime;
 16:     }
 17: 
 18:     public void setDateTime(Date DateTime) {
 19:         this.DateTime = DateTime;
 20:     }
 21: 
 22:     public String getMsg() {
 23:         return Msg;
 24:     }
 25: 
 26:     public void setMsg(String Msg) {
 27:         this.Msg = Msg;
 28:     }
 29: 
 30:     public String getMessageGroup() {
 31:         return MessageGroup;
 32:     }
 33: 
 34:     public void setMessageGroup(String MessageGroup) {
 35:         this.MessageGroup = MessageGroup;
 36:     }
 37: 
 38:     public TraceEventType getSeverity() {
 39:         return Severity;
 40:     }
 41: 
 42:     public void setSeverity(TraceEventType Severity) {
 43:         this.Severity = Severity;
 44:     }
 45: 
 46:     public String getThreadID() {
 47:         return threadID;
 48:     }
 49: 
 50:     public void setThreadID(String threadID) {
 51:         this.threadID = threadID;
 52:     }
 53: 
 54:     public String getThreadName() {
 55:         return ThreadName;
 56:     }
 57: 
 58:     public void setThreadName(String ThreadName) {
 59:         this.ThreadName = ThreadName;
 60:     }
 61: 
 62:     public String getAdditionalInfo() {
 63:         return AdditionalInfo;
 64:     }
 65: 
 66:     public void setAdditionalInfo(String AdditionalInfo) {
 67:         this.AdditionalInfo = AdditionalInfo;
 68:     }
 69: 
 70:     public String getStackTrace() {
 71:         return StackTrace;
 72:     }
 73: 
 74:     public void setStackTrace(String StackTrace) {
 75:         this.StackTrace = StackTrace;
 76:     }
 77:     
 78:     // Summary:
 79:     //     Identifies the type of event that has caused the trace.
 80:     public enum TraceEventType
 81:     {
 82:         // Summary:
 83:         //     Fatal error or application crash.
 84:         Critical (1),
 85:         //
 86:         // Summary:
 87:         //     Recoverable error.
 88:         Error ( 2),
 89:                 
 90:         //
 91:         // Summary:
 92:         //     Noncritical problem.
 93:         Warning (4),
 94:         //
 95:         // Summary:
 96:         //     Informational message.
 97:         Information (8),
 98:         //
 99:         // Summary:
100:         //     Debugging trace.
101:         Verbose (16),
102:         //
103:         // Summary:
104:         //     Starting of a logical operation.
105:        
106:         Start (256),
107:       
108:         Stop ( 512),
109:       
110:         Suspend (1024),
111:       
112:         Resume ( 2048),
113:       
114:         Transfer (4096);
115:    
116:         private final int mOrder;
117:           
118:          TraceEventType(int pOrder )
119:         {
120:             mOrder = pOrder;    
121:         } 
122:     }
123:     
124:     
125:        private Date DateTime ;
126: 
127:         private String Msg ;
128: 
129:         private String MessageGroup ;
130: 
131:         private TraceEventType Severity ;
132: 
133:         private String threadID ;
134: 
135:         private String ThreadName ;
136: 
137:         private String AdditionalInfo ;
138: 
139:         private String StackTrace ;
140: 
141:         public LogMsg()
142:         {
143:             
144:         } 
145:         
146:             public String toString() {
147:      return (new ReflectionToStringBuilder(this) {
148:          protected boolean accept(Field f) {
149:              return true;
150:          }
151:      }).toString();
152:             }
153: }

The test project


  1: package playwithserialization;
  2: 
  3: import java.io.FileInputStream;
  4: import java.io.FileOutputStream;
  5: import java.io.ObjectInputStream;
  6: import java.io.ObjectOutputStream;
  7: 
  8: import java.util.Date;
  9: 
 10: /**
 11:  *
 12:  * @author Zvika Peer 
 13:  */
 14: public class PlayWithSerialization {
 15: 
 16:     /**
 17:      * @param args the command line arguments
 18:      */
 19:     public static void main(String[] args) {
 20:     
 21:          String filename = "LogMsg.ser";
 22:     LogMsg theLogMsg = new LogMsg();
 23: 
 24:     theLogMsg.setAdditionalInfo("Additional info");
 25:     
 26:     theLogMsg.setDateTime( new Date());
 27:     
 28:     theLogMsg.setMessageGroup("my Message group");
 29:     
 30:     theLogMsg.setMsg("This is the message ");
 31:     
 32:     theLogMsg.setSeverity(LogMsg.TraceEventType.Critical );
 33:     
 34:     // Save the object to file
 35:     FileOutputStream fos = null;
 36:     ObjectOutputStream out = null;
 37:     try {
 38:       fos = new FileOutputStream(filename);
 39:       out = new ObjectOutputStream(fos);
 40:       out.writeObject(theLogMsg);
 41: 
 42:       out.close();
 43:     } catch (Exception ex) {
 44:       ex.printStackTrace();
 45:     }
 46:     // Read the object from file
 47:     // Save the object to file
 48:     FileInputStream fis = null;
 49:     ObjectInputStream in = null;
 50:     try {
 51:       fis = new FileInputStream(filename);
 52:       in = new ObjectInputStream(fis);
 53:       theLogMsg = (LogMsg) in.readObject();
 54:       out.close();
 55:     } catch (Exception ex) {
 56:       ex.printStackTrace();
 57:     }
 58:     System.out.println(theLogMsg);
 59:   }
 60: }

The Result:
debug:
playwithserialization.LogMsg@1bb73b0[DateTime=Sun Jun 30 10:57:35 IDT 2013,Msg=This is the message ,MessageGroup=my Message group,Severity=Critical,threadID=<null>,ThreadName=<null>,AdditionalInfo=Additional info,StackTrace=<null>]
BUILD SUCCESSFUL (total time: 0 seconds)

References
http://javarevisited.blogspot.co.il/2011/04/top-10-java-serialization-interview.html
http://www.vogella.com/articles/JavaSerialization/article.html