Thursday, April 16, 2015

Update Surface Pro with Ubuntu to support pen pressure sensitivity using the wacom drivers.

I purchased a Surface Pro tablet to be able to use it as a portable Cintiq tablet. I own a Cintiq 21ux and use it with Ubuntu. I was kinda disappointed after installing Ubuntu since pen pressure sensitivity did not work.

I poked around and realized that Microsoft shipped a wacom driver compatible device but changed the vendor and device id.

I wrote a script to use the wacom drivers and calibrate the stylus and eraser: fix-surface-pro-pen.sh

I'll try to add my changes to the wacom drivers to avoid having to do this hack if I get some time.

Saturday, March 16, 2013

Debug android NDK

I have been trying to debug my android application for a few weeks now, and was unable to set breakpoints.
I finally figured out that there is a bug in the NDK, following the steps in this article link
To be able to set breakpoints I had to only build only one version of the shared libraries to avoid the linker from choosing the wrong shared library. Basically I had to change the file Application.mk with the following:
APP_ABI := armeabi armeabi-v7a
APP_ABI := armeabi #armeabi-v7a
Now I can continue using breakpoints within the android NDK.

Sunday, February 3, 2013

Ubuntu disable ctrl-p

Some laptops use ctrl-p to switch display. Ubuntu added support for this and broke my shortcut configuration. To disable ctrl-p switching displays type the following on a terminal:
dconf write /org/gnome/settings-daemon/plugins/media-keys/active false
reference

Monday, July 2, 2012

Disable super key gnome shell 3.4 (gnome3)

I don't like how gnome-shell uses the super key for the overlay shortcut. This can be disabled by typing the following command in a terminal.
gsettings set org.gnome.mutter overlay-key ''
When changing workspaces only the primary monitor changes. To allow all monitors to change use the following.
gsettings set org.gnome.shell.overrides workspaces-only-on-primary false

Thursday, June 7, 2012

Generate XmlRootElement for jaxb objects

I recently had to add XmlRootElement to a class. After using google for a while, I finally figured out a way to do it. I Updated the pom jaxb plugin to include the annotate plugin and created a mappings file that customizes the jaxb object. pom.xml:
<plugin>
    <groupid>org.jvnet.jaxb2.maven2</groupid>
    <artifactid>maven-jaxb2-plugin</artifactid>
    <configuration>
        <extension>true</extension>
        <strict>false</strict>
        <plugins>
            <plugin>
                <groupid>org/jvnet/jaxb2_commons</groupid>
                <artifactid>annotate</artifactid>
                <version>0.4.1.5</version>
            </plugin>
        </plugins>
    </configuration>
    <executions>
        <execution>
            <id>generate</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <bindingincludes>
                    <include>*.xjb</include>
                </bindingincludes>
                <args>
                    <arg>-Xannotate</arg>
                </args>            
            </configuration>
        </execution>
    </executions>
</plugin>
file.xjb:
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionbindingprefixes="annox">
    <jaxb:bindings schemalocation="filename.xsd" node="/xs:schema">
        <jaxb:bindings node="xs:complexType[@name='ObjectType']">
            <annox:annotate>
                <annox:annotate 
                annox:class="javax.xml.bind.annotation.XmlRootElement"
                name="access">
            </annox:annotate>
        </annox:annotate></jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

Wednesday, May 30, 2012

inotifywait - run scripts on file changes

When working on a project in Java, I often need to stop/start maven whenever I make changes to the source code. I wanted to have maven restart automatically whenever I changed the source code. I ended up using some bash scripts to get the job done. inotifywait will run the script restart.sh whenever a file inside src is saved. This could also be done to automatically run test when source code changes. watch.sh:
#!/bin/bash
while inotifywait -re close_write src; do ./restart.sh; done
restart.sh:
#!/bin/bash
./kill_tomcat.sh
sleep 1
mvn tomcat:run -o &
kill_tomcat.sh:
#!/bin/bash
pkill -kill -f tomcat:run

Tuesday, February 28, 2012

python rfoo rconsole

I ran accross this today. rfoo allows connecting to a remote running session of python and inspect the session's values, modify the data, etc. You can read more about it here Install in ubuntu:
sudo apt-get install python-dev
pip install cython
pip install rfoo
rconsole is a remote Python console with auto completion, which can be used to inspect and modify the namespace of a running script. To invoke in a script do:
from rfoo.utils import rconsole
rconsole.spawn_server()
To attach from a shell do:
rconsole

Saturday, October 15, 2011

wmii ubuntu 11.10 (Oneiric Ocelot)

The default gcc compiler now requires linked libraries to appear after the source file
gcc example.cpp -lsomelibrary
wmii build files have the shared libraries located before the source files, and thus can not be easily built with the default configuration.
To build wmii I updated the config.mk to use gcc-4.4 for the compiler
CC = gcc-4.4 -c
LD = gcc-4.4
This allowed the project to compiled with the following command:
dpkg-buildpackage -rfakeroot -us -uc -b

Thursday, September 29, 2011

Fix clang errors in ubuntu

In natty clang needs some the headers that are not included in ubuntu. To get clang to work use the following:
sudo ln -s /usr/include/c++/4.5 /usr/include/c++/4.4

Wednesday, September 14, 2011

When debugging in python, I use ipython's ipdb debugger to set breakpoints. I can add the following code in the location I want to stop:
import ipdb; ipdb.set_trace()
I wanted something similar for ruby. I got the same behaviour set up with the following code and patching using irb_completion's output. Install the required gem files:
gem install ruby-debug-base
gem install ruby-debug
gem install wirble
gem install patch_irb_completion;patch_irb_completion
Modify the ruby file to be debugged:
require 'rubygems'
require 'ruby-debug'
require 'wirble'
Wirble.init
Wirble.colorize

debugger #location to stop
running the code with the --debug option will stop at the requested location and drop an rdb prompt with tab completion. Reference: http://stackoverflow.com/questions/2504515/what-do-i-put-in-my-ruby-jruby-code-to-break-into-the-debugger http://www.unboxedconsulting.com/blog/irc-completion-from-the-debugger

Sunday, July 10, 2011

SpringSource Tool Suite 2.7.0.M2 Released

Eclipse 3.7 (Indigo) has been released.
From the eclipse website install the Java EE version and follow the directions found at this website link to install the SpringSource support.

Wednesday, June 22, 2011

generate database DDL

Roo automatically generates the database but does not provide a DDL. To generate a DDL add the following text to the pom:
<!-- Generate DDL -->
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>hibernate3-maven-plugin</artifactId>
  <version>2.2</version>
  <executions>
<execution>
  <phase>process-classes</phase>
  <goals>
    <goal>hbm2ddl</goal>
  </goals>
</execution>
  </executions>
  <configuration>
<components>
  <component>
    <name>hbm2ddl</name>
    <implementation>jpaconfiguration</implementation>
  </component>
</components>
<componentProperties>
  <propertyfile>src/main/resources/database.properties</propertyfile>
  <persistenceunit>persistenceUnit</persistenceunit>
  <outputfilename>schema.ddl</outputfilename>
  <drop>false</drop>
  <create>true</create>
  <export>false</export>
  <format>true</format>
</componentProperties>
  </configuration>
</plugin>

Friday, June 10, 2011

roo reverse engineer

These are the steps I followed to have roo generate the database entities.
mkdir project
cd project
roo
In roo type the following to create a project along with the persistence layer.
project --topLevelPackage com.tecunhuman.example
persistence setup --provider HIBERNATE --database POSTGRES
exit roo and modify the file "src/main/resources/META-INF/spring/database.properties" to contain the correct information for the database. run roo again and execute:
database reverse engineer --schema schema-name
It will inspect the database and generate the DAO classes.

Thursday, June 9, 2011

Java rooing with xjc

I have been working on web services using java and found some useful tools to speed up development time. I have been using xjc to generate the web resource entities based on the provided schema. This program generates the classes used for the rest service along with the required annotations. Roo is another tool that generates code. It has an option to reverse engineer a database. This allows creating classes with annotations from an existing database. Our stack requires us to use java, spring and hibernate; roo allows creating entities with test in a fraction of the time.

Thursday, June 2, 2011

In the clouds

My blog is now being hosted on the clouds. It was able to migrate by moving the database and content files. I ran into problems with the themes. I had set the default theme in the database to be able to view anything.
I also moved the repository I use to configure my machine into bitbucket. I figured someone might find them useful. I separated part of it into its own project; searchvim is a project I created to make switching between files in vim simple. I tried to simulate a similar behaviour to that of eclipse or intellij. If someone finds it useful or has suggestions let me know.

Wednesday, May 5, 2010

Certificate has new life!

The certificates expired two days ago for our group, but apple didn't really spend as much time locking down their certificates. Setting the time on the development machines and iPad nano back to a day when they were valid seems to work. I was able to continue development and install the final project on the device.

Sunday, April 25, 2010

A Long weekend

I spent most of the weekend trying to integrate the different parts our group has been working on into a single program. I ran into various problems: Objective-c does not have good static program analysis, and since the machines at school do not have the debug function enabled, I had to go trough trying to figure out what was causing the program to crash. There were some errors caused by trying to cast from one type to another, and other errors caused by trying to call methods that do not exist. Small typos would cause the program to compile but fail at run time.

Our group did manage to get the pieces put together. We will be working on sending the order to the server next.

Friday, April 16, 2010

UI Update

Here is a quick update on the UI --

Selecting a table in edit mode brings up a UIPickerView:



Selecting a Patron in edit mode brings up a window to change the text:

Sunday, April 11, 2010

iOrder interface

I started looking into some of the components of the user interface for the application. I played around with the interface builder and found it to be non-intuitive and difficult to use. I looked trough the iPhone SDK documentation, and found how to implement the user interface without the xib files. I found this approach to be easier to implement.

I updated the source files in kiln with the new UI implementation. The different tabs can now be selected, tables can be added and edited. The program looks almost identical to the mock-up.

Saturday, April 3, 2010

iOrder communication

Group 4 has made some progress in our application. We were able to add the server client code to the application. I created a small wrapper for the c sockets that allows creating and using sockets without having to know much about them. Creating a server is as easy as saying createServer( port ) and for the client createClient ( ip, port ). Communication is done via the methods send ( string ) and recieve ( string ).

I did run into some trouble making the server application multi-threaded. Parameters can't be passed directly to the methods in C. I had to use a struct to pass the parameters around... if we run into problems later, i think switching the server over to java would be the best choice.

I have been uploading my source changes into mercurial. I don't like the interface very much (command line). It would have been nice to have the built in support that xcode has for subversion.