Posts Tagged ‘Dev’

Posted by kent at 2 September 2011

Category: Dev

Tags: , , , ,

If you’ve upgraded Perl on your Gentoo box to 5.12, and tries to reemerge ImageMagick, you might get this error:

Could not find a typemap for C type 'Image::Magick' in Magick.xs, line 2404
make[3]: *** [Magick.c] Error 1
make[3]: Leaving directory `/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/work/ImageMagick-6.7.1-0/PerlMagick'
make[2]: *** [install-exec-perl] Error 2
make[2]: Leaving directory `/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/work/ImageMagick-6.7.1-0'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/work/ImageMagick-6.7.1-0'
make: *** [install] Error 2
 * ERROR: media-gfx/imagemagick-6.7.1.0 failed (install phase):
 *   emake failed
 *
 * If you need support, post the output of 'emerge --info =media-gfx/imagemagick-6.7.1.0',
 * the complete build log and the output of 'emerge -pqv =media-gfx/imagemagick-6.7.1.0'.
 * The complete build log is located at '/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/temp/environment'.
 * S: '/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/work/ImageMagick-6.7.1-0'

>>> Failed to emerge media-gfx/imagemagick-6.7.1.0, Log file:

>>>  '/var/tmp/portage/media-gfx/imagemagick-6.7.1.0/temp/build.log'

Reemerge with:

 # USE="-perl" emerge -av imagemagick

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] media-gfx/imagemagick-6.7.1.0  USE="bzip2 corefonts cxx jpeg openmp png tiff truetype xml zlib -X -autotrace -djvu -fftw -fontconfig -fpx -graphviz -gs -hdri -jbig -jpeg2k -lcms -lqr -lzma -opencl -openexr -perl -q32 -q64 -q8 -raw -static-libs -svg -webp -wmf" 0 kB

Total: 1 package (1 new), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] 

After some minutes:

>>> Recording media-gfx/imagemagick in "world" favorites file...
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

You might also want to update /etc/portage/package.use with “media-gfx/imagemagick -perl” if you don’t need Perl with ImageMagick.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by kent at 9 March 2011

Category: Dev

Tags: , ,

From TDWTF.

Inept management hires inept arrogant conceited glory hogging twit

Inept management promotes twit at twit’s urging

Twit hires more twits for personal gain

Twit blames remaining competant workers for downward spiral

Remaining competant worker leaves

Company does well-deserved tail spin, crashes and burns

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 28 February 2011

Category: Dev, Flex

Tags: , , , ,

<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
            import mx.controls.Label;

            public function willShowResult(result:Label, myVar:String):Boolean {
                if (myVar== 'XXX') {
                    return false;
                }
                return true;
            }
        ]]>
    </mx:Script>

    <mx:columns>
        <mx:DataGridColumn
            dataField="myVar"
            headerText="My var"/>
        <mx:DataGridColumn
            dataField="result"
            headerText="My result">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:Label text="{outerDocument.willShowResult(this, data.myVar) ? data.result : ' ' }"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
    </mx:columns>

</mx:DataGrid>
VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 28 February 2011

Category: Java, Tip

Tags: , , , ,

If an autocomplete stopped working go

Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced ->  check for “Other Java Proposals”

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 25 October 2010

Category:

Tags: , , ,

Those who use hibernate for database access know that you need to provide an information that this object is a hibernate object. To do so you typically need to annotate your object with @Entity. It’s not a problem although if we speak about some large system. In large systems we have typically a number of instances of the same object that represent the same table in different contexts and packages. And here we need this: to give each object unique name.
Example:

@Entity(name="person.usa")
class Person {
   ...
}

This PMD rule shows how to check if a hibernate object have a name.

<![CDATA[
     //Annotation/NormalAnnotation[
     (
           Name/@Image='Entity'
           and
           not
           (
                 MemberValuePairs/MemberValuePair/@Image='name'
                 and
                 //PrimaryExpression/PrimaryPrefix[contains(Literal/@Image,'.')]
           )
     )
]]]>
VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 17 October 2010

Category: Dev, Java

Tags: , , ,

It’s uncommon to see methods like this>

public Person findPerson() {
   if(someService) [
     return someService.getPerson();
   }
   return null;
}

There is no reason to make a Person object where there are no persons found. But doing so requires extra code in the client to handle the null value. This becomes a problem if a client is, for example, a GUI:

somePage.jsp
<%
  ...
  Person person = myService.findPerson();
%>
<table>
   <tr>
      <td>${person.name}</td>
      <td>${person.address}</td>
      <td>${person.numberOfPurchases}</td>
   </tr>
</table>

The result of such code in cases where the person cannot be found is Server error. So, there is no reason ever to return null from an object-valued method instead of returning an empty object. Especially if you deal with arrays and collections.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by kent at 16 August 2010

Category: c++, Dev

Tags: , ,

When I get this error, it’s always because I’ve opened the debugging process in Process Explorer.

Error    1    fatal error LNK1201: error writing to program database 'e:\blergh\blergh\bin\blergh_d.pdb'; check for insufficient disk space, invalid path, or insufficient privilege

Close the handle in Process Explorer or restart Process Explorer.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 24 July 2010

Category:

Tags: , , ,

I was trying to solve a problem of resetting a focus if the parent changes. I had different buttons that show the same .mxml-form but with different data. The problem was that I needed the focus to be on the first date-field whenever the form is shown so that the user can begin typing data right away.

<mx:HBox>
       <mx:Button id="noData" click="showPanelWithNoData()" />
       <mx:Button id="someData" click="showPanelWithSomeData()" />
       <mx:Button id="withData" click="showPanelWithData()" />

       <myCustomForm:DataForm width="100%" />
</mx:HBox>

So for each time one of the buttons is pushed I need the focus to be on myDate-field. To solve the problem I used “updateComplete“-property of the field.

DataForm.mxml

<?xml version="1.0" encoding="utf-8"?>
<DataForm
    xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
            import mx.managers.FocusManager;

            private function resetFocus():void {
                if (focusManager != null && myDate.focusManager != null) {
                    focusManager.setFocus(myDate);
                }
            }
        ]]>
    </mx:Script>

    <mx:FormItem>
        <mx:TextField id="myDate"
            updateComplete="resetFocus()"/>
    </mx:FormItem>

</DataForm>
VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 17 April 2010

Category:

Tags: , , ,

1. Use the == to check if the argument is a reference to this object.

2. Use the instanceof operator to check if the argument has the correct type.

3. Cast the argument to the correct type.

4. For each “significant” field in the class, check if that field of the argument matches the corresponding field of this object.

5. Always override hashCode when you override equals.

6. Don’t substitute another type for Object in the equals declaration.

7. Write unit-test.

   @Override
   public boolean equals(Object obj) {
      if(obj == this) {
         return true;
      }
      if(!(obj instanceof Person)) {
          return false;
      }
      Person p = (Person)obj;
      return p.name.equals(name)
             p.birthday.equals(birthday)
             p.personNumber == personNumber;
      }


Ref.”Effective Java” by Joshua Bloch

Enother example with hashCode and toString:

    @Override
    public boolean equals(Object obj) {
        if (obj == null || !obj.getClass().isInstance(this)) {
            return false;
        }
        Beregning b = (Beregning) obj;

        return new EqualsBuilder()
                .append(simulertPensjon, b.getSimulertPensjon())
                .append(linjer.size(), b.getLinjer().size()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(simulertPensjon).append(linjer).hashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
        .append("simulertPensjon", simulertPensjon)
        .append("antall linjer", linjer.size()).toString();
    }
VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share

Posted by Tatyana at 4 March 2010

Category: Java

Tags: , , ,

I had some difficult time understanding all the roles regarding EJB3. Here is an easy-to-remember description of these roles that I found here.

Imagine a factory producing computers:

Bean Provider:
Chip manufacturer. On the chip, there will be a label with “Warranty void if removed” the chip has the logic and the label sets a Role. If you are not authorized to repair it, warranty voids. (i.e. you cannot access the internal chip if you are not in the role of “Warranty Repair Person”.)

Application Assembler
Mainboard assembler. It takes various chips and puts them on the mainboard. If any additional resistor or cable are required, it will put everything togheter to have something that is some kind of working unit but requires additional assembling.

EJB Server Provider
The EJB Server provider is the Computer Case manufacturer providing a case with a power supply. Is a container for the mainboard

Deployer
As every computer case is different and power voltage vary country by country, the Deployer makes sure to adapt the mainboard to the working environment. In this case adjusts the Voltage on the power supply, and connects the cables. At the same time he will define who are the person allowed to repair it (i.e. provide a list of authorized repair centers)

Persistence Provider
the persistence provider could be the network card company that provides the driver to connect to a network.

System Administrator
Is the person in charge to install the operating system and do necessary configuration changes to the OS to connect to the server, and will make sure to monitor that everything is working fine.

More about Enterprise Java Beans 3.0 and Sun Certified Business Component Developer (SCBCD) certification here.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
Share