"; */ ?>


04
Jan 11

Edit Keyboard Layout on Mac

Moving from several years of hardcore Ubuntu life to Mac is “a bit” challenging, but hey.. bring it on!

First thing that I needed to do is to be able to type.. Well yea, English is easy, since Mac does come with US keyboard that ironically comes with English letters. However what about people who are fortunate to know and love another language ( besides English )? Easy, you’d say: Mac has gazillions of different layouts ( a.k.a. “Input Sources” ) available:

mac keyboard input sources

Well, what if none of them suites me? Let’s take a look at the Russian Phonetic layout that comes with OS X:

russian phonetic layout mac

Maybe someone is ok with this layout, but many letters here are quite far from being “phonetic”. Leaving this be would result in many “typing in frustration” hours when you think you pressed “a”, but it was “b”, etc.. But don’t give up just yet, there is an awesome solution: Ukelete which is an excellent Unicode Keyboard Layout Editor for Mac OS X.

So switch to a “Russian Phonetic” layout:

Choosing Russian Phonetic Layout

Now start Ukelete, go to “File –> New From Current Input Source”:

New From Current Input Source

You should see the default layout in Ukelete window now:

Russian Phonetic Layout Ukelete

You are almost done.. Now just play a little “Swap Keys” game to get where you need to be:

Ukelete Swapping Keys

And get that final layout that you love:

Russian Phonetic Final Layout

Now save it as a “keyboard layout file”:

Save As Keyboard Layout File

to “/Library/Keyboard Layouts/”.

Now go to the “System Preferences –> Language & Text –> Input Sources”, and you should see a new “Russian – Phonetic” layout:

New Russian Phonetic Input Source

You are done :)

P.S. Another thing is to remap CapsLock to Option key via “System Preferences –> Keyboard –> Modifier Keys”:

Remap CapsLock

and change the shortcut to switch input sources ( keyboard layouts ) to “CapsLock + Tab”:

Remap CapsLock

Happy typing!


01
Dec 10

To Yammer through Corkscrew and Cygwin

The whole thing started when I wanted to use Yammer from behind a corporate firewall. The only laptop I had handy at that moment had Windows on it, so I thought, well.. I’ll

  • install Cygwin ( a Linux-like environment for Windows )
  • download and compile corkscrew ( enables SSH connections over HTTP/HTTPS proxies )
  • set up my proxy server in “$HOME/.ssh/config”:
  • Host *
      ProxyCommand corkscrew myproxy.com 8080 %h %p
  • forward X11 with ssh:
  • export DISPLAY=localhost:0.0
    ssh -2 -4 -C -X -v USER@SERVER
  • start firefox, and login to Yammer
  • DONE

But… Cygwin is not Ubuntu :)

First error I got after a fresh cygwin install was

mkdir: cannot create directory `/cygdrive/h': Permission denied

So here I had to make sure that my “H:” drive is unmapped, and I needed to add:

set HOMEDRIVE=
set HOMEPATH=
set HOMESHARE=

to “C:\cygwin\cygwin.bat” before “bash –login -i” line

The next error was slightly different, but also resembled the first one a lot:

mkdir: cannot create directory `/cygdrive/h': No such file or directory

Here I had to just cruelly delete “C:\cygwin\etc\passwd”

Now moving forward, I downloaded the Corkscrew, configured it ( ./configure ), and was about to compile it when I got:

$ make
gcc -DHAVE_CONFIG_H -I. -I. -I. -I.    -g -O2 -c corkscrew.c
In file included from /usr/include/cygwin/in.h:21,
                 from /usr/include/netinet/in.h:14,
                 from /usr/include/arpa/inet.h:14,
                 from corkscrew.c:2:
/usr/include/cygwin/types.h:120: parse error before "int16_t"
/usr/include/cygwin/types.h:124: parse error before "int32_t"
/usr/include/cygwin/types.h:128: parse error before "int64_t"
/usr/include/cygwin/types.h:137: parse error before "uint16_t"
/usr/include/cygwin/types.h:141: parse error before "uint32_t"
/usr/include/cygwin/types.h:145: parse error before "uint64_t"
/usr/include/cygwin/types.h:154: parse error before "u_int16_t"
/usr/include/cygwin/types.h:158: parse error before "u_int32_t"
/usr/include/cygwin/types.h:162: parse error before "u_int64_t"
/usr/include/cygwin/types.h:177: parse error before "register_t"
In file included from /usr/include/netinet/in.h:14,
                 from /usr/include/arpa/inet.h:14,
                 from corkscrew.c:2:
/usr/include/cygwin/in.h:40: parse error before "in_port_t"
/usr/include/cygwin/in.h:81: parse error before "in_addr_t"
In file included from corkscrew.c:2:
/usr/include/arpa/inet.h:22: parse error before "inet_addr"
/usr/include/arpa/inet.h:24: parse error before "inet_lnaof"
/usr/include/arpa/inet.h:26: parse error before "inet_netof"
/usr/include/arpa/inet.h:27: parse error before "inet_network"
make: *** [corkscrew.o] Error 1

The fix is obvious, right? :) Just needed to add “#include <sys/types.h>” to “C:\cygwin\usr\include\cygwin\types.h”:

#ifndef _CYGWIN_TYPES_H
#define _CYGWIN_TYPES_H
 
#include <sys/types.h>			/* <<<<< add this line */
#include <sys/sysmacros.h>

Now when forwarding X11 traffic over SSH, depending on firewall settings, the port 6000 ( XDMCP ) is most likely blocked:

connect localhost port 6000: Connection refused

Once the port is open, a beautiful window with Firefox and unlimited opportunities shows up making you ready to concur the world!


29
Nov 10

Install Alternate Ubuntu Image from USB

UNetbootin allows you to create bootable Live USB drives for Ubuntu, Fedora, and other Linux distributions without burning a CD.

Unfortunately it does not work by default with Alternate Ubuntu Images. In order to make it work:

1. download an alternate image: Ubuntu Alternative Downloads
2. write an image to USB drive using UNetbootin
3. boot from this new USB on the target host
4. select the menu item “Default”
5. DON’T press ENTER
6. press TAB
7. add the “cdrom-detect/try-usb=true” before the “- -”
8. press ENTER

Now it will actually look into USB to install the system rather than looking for CD-ROM or trying the whole OS from the network.


12
Oct 10

Running Spring AspectJ Tests with Maven

You need to use a real AspectJ aspect with Spring, where you would like to inject some dependencies into this aspect as a Spring container starts up.

Here is an AspectJ aspect:

@Aspect
public class VeryImportantAspect {
    ...
    public void setSomeDependency( SomeDependency dependency ) {
        this.dependency = dependency;
    }
    ...
}

Now let’s define it as a bean and inject “someDependency”:

<bean id="veryImportantAspect" 
         class="org.dotkam.VeryImportantAspect"
         factory-method="aspectOf">
 
         <property name="someDependency" ref="someDependency"/>
</bean>

Notice factory-method=”aspectOf” that tells Spring to use a real AspectJ ( not Spring AOP ) aspect to create this bean. In reality, if the “VeryImportantAspect” was already woven in, it will have an “aspectOf” method.

Hence if you get this error at some point:

No matching factory method found: factory method 'aspectOf()'

That would mean that the aspect was not woven by AspectJ weaver.

We also need to tell Spring to use load time weaving:

<context:load-time-weaver/>

If you run with the above configuration without doing anything, you would get a following error:

ClassLoader does NOT provide an 'addTransformer(ClassFileTransformer)' method

That tells you ( well not explicitly :) ) to include a “spring-instrument.jar” javaagent.

So at this point two things need to be added: AspectJ weaver and Spring Instrument agent. Build / Continues integration server does not use any IDE, so it is not as simple as downloading AspectJ plugin for IDEA / Eclipse and including VM arguments in Run Configurations… It is simpler: just add the two in your POM file.

Adding an AspectJ plugin:

<plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>aspectj-maven-plugin</artifactId>
     <version>1.3</version>
     <executions>
         <execution>
             <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>                     
             <goals>
                 <goal>compile</goal>       <!-- use this goal to weave all your main classes -->
                 <goal>test-compile</goal>  <!-- use this goal to weave all your test classes -->
             </goals>
         </execution>
    </executions>
</plugin>

Adding a Spring Instrument agent to participate in a test execution:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.4</version>
	<configuration>
            <forkMode>once</forkMode>
            <argLine>
                 -javaagent:"${settings.localRepository}/org/springframework/spring-instrument/${spring.framework.version}/spring-instrument-${spring.framework.version}.jar"
	    </argLine>
            <useSystemClassloader>true</useSystemClassloader>
	</configuration>
</plugin>

And all that work, just too see a couple of lines from Maven:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

06
Oct 10

Humans + Software = Zero

FACT:

Humans are stateful and mutable beings that have no problems processing many things concurrently and share state with others + they are usually “coupled”

GOAL:

And yet in software design we strive for being stateless, immutable and decoupled.


CONCLUSION I:

Humans should not design software

CONCLUSION II:

If humans were designed by software, that project sucked ( according to the GoF teachings )

CONCLUSION III:

Humans are not software, they are maybe… hardware

CONCLUSION IV:

Good software is going to lead to the race of Inhumans

CONCLUSION V:

Humans + Software = 0