Monday, December 19, 2011

Connecting to HTTPS site with specific certificate in PHP

Here is an example how you could connect to a server, which requires that you identify yourself with a certificate.
Your certificate and the server certificate are signed by an authority whose certificate is in ca.ctr.

Wednesday, December 14, 2011

Match multiple patterns with a single regex expression

I wanted to add multiple patterns to single regex expression. Such as password check. For example:

Friday, October 21, 2011

solved maven error "NoClassDefFoundError" ComponentLifecycleException


niskia:/xxyyzz# mvn jar:jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/component/repository/exception/ComponentLifecycleException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.privateGetPublicMethods(Class.java:2547)
at java.lang.Class.getMethods(Class.java:1410)
at org.codehaus.classworlds.Launcher.getEnhancedMainMethod(Launcher.java:195)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:294)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.component.repository.exception.ComponentLifecycleException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 9 more

The solution was reinstalling maven. For debian is done by:

apt-get remove maven2
apt-get install maven2

Monday, October 10, 2011

Problems with graphics in Mantis bugtracker in Linux

I installed Mantis BT, but graphic summaries do not show up. I went to Summary -> Per state and all i saw was:

Synthesis graphs by status
Unable to read/find font

It was shown for all graphic screens in summary menu.

With little tuning I get success in Debian:

Thursday, September 22, 2011

Problems with Expose Gallery (for Joomla) under PHP 5.3

Note: A fixed version of the module is available here.

The main issue is that the gallery do not shows. If you try to open the gallery in Internet Explorer, you will see a JavaScript error notification. It is caused by added "PHP deprecated" warning in a string value, which breaks some of the application's logic. This could be easily corrected manually. The file is:

Monday, September 12, 2011

OOO - Out Of Office email

Здравейте колеги,
На дати ХХХХХХХХХХХХХ ще бъда в отпуска.
Ако ви стане мъчно за мен, може да ме потърсите на някой от следните телефони:
0xxx-xxx-xxx
0xxx-xxx-xxx

За съжаление няма да имам достъп до компютър и до интернет.

Поздрави

Saturday, September 3, 2011

Thursday, September 1, 2011

Installing bugzilla on Debian

Download latest Bugzilla and unpack the archive in apache document root (or configure a virtualhost).

Pre-check in shell with command:

./checksetup.pl --check-modules


I get some missing modules:

Monday, August 15, 2011

Modify primary key syntax

MySQL:

ALTER TABLE your_table DROP PRIMARY KEY, ADD PRIMARY KEY ( some_field, other_field );


There is no problem some_field to be AUTO_INCREMENT.

Friday, August 12, 2011

Easier Command prompts recognition

If you use more that one Command Prompts in Windows, you probably mess them up. An easy way to distinguish them is with color command. Write in each of them color command with different arguments. Letter color changes, yeah!

Command Prompt window #1:
color A

Command Prompt window #2:
color B

MS DOS batch tips

So, by way of tribute to the dying art of the DOS Batch file, I present my top ten batch file tricks:

1 Use PUSHD / POPD to change directories
Read Scott Hanselman's writeup on PUSHD. The basic idea is that it keeps a stack, so at the simplest level you can do something like this:

PUSHD "C:\Working Directory\" ::DO SOME WORK POPD

That allows you to call the batch file from any directory and return to the original directory when you're done. The cool thing is that PUSHD can be nested, so you can move all over the place within your scripts and just POPD your way out when you're done.

Thursday, July 28, 2011

Adding JAXB / jxc support in maven

Put your schemas (*.xsd) and bindings (*.xjb) into the src/main/resources folder.
Correct pom.xml as you add:
<build>
 <plugins>
  <plugin>
   <groupId>org.jvnet.jaxb2.maven2</groupId>
   <artifactId>maven-jaxb2-plugin</artifactId>
   <executions>
    <execution>
     <goals>
      <goal>generate</goal>
     </goals>
     <configuration>
      <args>
       <arg>-nv</arg><!-- this disable strict schema validation -->
      </args>
     </configuration>
    </execution>
   </executions>
  </plugin>
  <plugin>
   <inherited>true</inherited>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
    <source>1.5</source>
    <target>1.5</target>
   </configuration>
  </plugin>
 </plugins>
</build>

Wednesday, July 27, 2011

Extending enums in Java

public enum DataStatus
{
    DECLINED_BY_USER("DECLINED-BY-USER"),
    SUCCESSFUL("SUCCESSFUL"),
    SPAM("SPAM");

    private String code;
    
    private DataStatus(String code) {
         this.code = code;
    }
    
    public String getCode() { return code; }
    
    public String toString(){ return code; } // if you want it so
    
    public static DataStatus parse( String s ){
        s = s.toUpperCase();
        if( s.equals( "SUCCESSFUL" ) )
            return SUCCESSFUL;
        if( s.equals( "DECLINED-BY-USER" ) )
            return DECLINED_BY_USER;
        if( s.equals( "SPAM" ) )
            return SPAM;
        return null;
    }
}    

Monday, July 18, 2011

kickstart commands for mysql (create database & user)

mysql -u root -p --port=3306

CREATE DATABASE database_name;

CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1';

GRANT SELECT,INSERT,UPDATE,DELETE,DROP,CREATE       ON database_name.* TO 'user1'@'localhost';
GRANT SELECT,INSERT,UPDATE,DELETE,DROP,CREATE,ALTER,INDEX ON database_name.* TO 'user1'@'localhost';

FLUSH PRIVILEGES;


(mysql database) UPDATE user SET Password=PASSWORD('new_pass') WHERE User='username';

(mysql database) UPDATE user SET User='username_new' WHERE User='username_old';


For everyone host use '%' instead of 'localhost'