wtorek, 5 kwietnia 2016

git - stucked with modified files due to eol differences

Once you've got * text=auto set in your .gitattribute file all text files stored in repository will be changed into EOL sequence adequate to the host system. But any time checkouting on another system - all eols will be replaced with its specific. Quite nifty, isn't it?

But if for some reason your text file you've got in staging area contains for instance CRLF and you are working on linux machine - git status reporting it as modified. But you cannot reset this as there are no diff in terms of text=auto. Moreover git stash also seems to work badly, as again nothing to stash found. If you faced such a problem here is the solution

  1. Edit the .gitattribute file by commenting out the * text=auto line (with # sign)
  2. Type git status on the command line
  3. Revert .gitattribute file

czwartek, 14 stycznia 2016

Ubuntu - disappeared unity windows recovery guide

I found myself really confused that after some operations (eg. switching external displays around) I cannot activate opened applications. I suspected that those apps have to be somewhere on desktop, but apparently not in current view port. There have to be a way to grab and move them.. but how??

After a while of googling wmctrl nifty friend was on my toolbox ready for action.

Lets start from looking at options by typing wmctrl -h for displaying a help.
Now try to figure out what windows are on your desktop:

$ wmctrl -l
0x02e00002  0 krma-laptok XdndCollectionWindowImp
0x02e00005  0 krma-laptok unity-launcher
0x02e00008  0 krma-laptok unity-panel
0x02e0000b  0 krma-laptok unity-dash
0x02e0000c  0 krma-laptok Hud
0x0280000a  0 krma-laptok Desktop
0x0460000b  0 krma-laptok krma@krma-laptok: ~
0x044000b3  0 krma-laptok Inbox - Mozilla Thunderbird
0x0400053b  0 krma-laptok Java - Eclipse 

Lets look at the desktop present on our system
$ wmctrl -d
0  * DG: 3840x1080  VP: 0,0  WA: 45,24 3795x1056  N/A
But how to identify those that are out of viewport?
$ wmctrl -lG
0x02e00002  0 -3940 -1180 3840 1080 krma-laptok XdndCollectionWindowImp
0x02e00005  0 0    24   45   1056 krma-laptok unity-launcher
0x02e00008  0 0    0    1920 24   krma-laptok unity-panel
0x02e0000b  0 -1241 -740 1141 640  krma-laptok unity-dash
0x02e0000c  0 -1060 -164 960  64   krma-laptok Hud
0x0280000a  0 0    0    3840 1080 krma-laptok Desktop
0x0460000b  0 2101 114  1601 844  krma-laptok krma@krma-laptok: ~
0x044000b3  0 70   266  1294 629  krma-laptok Inbox - Mozilla Thunderbird
0x0400053b  0 7655 92   1860 988  krma-laptok Java - Eclipse
Eclipse's x position seems to be a little to high, isn't? Lets move it to (20,20) and leave existing size (1860,988) unchanged:
$ wmctrl -i -r 0x0400053b -e 0,20,20,-1,-1
PS. another nice tool is xdotool. It can
$ xdotool getwindowgeometry 0x0400053b
Window 67110203
  Position: 55,62 (screen: 0)
  Geometry: 1860x988
Note that position is different from (20,20) - moved (35,42)??

poniedziałek, 11 stycznia 2016

How to run javascript script in jvm environment?

Oracle's JDK8 comes with jjs command which runs javascript code agains nashorn build-in engine. Assumming the following piece of code
// script.js
var lines = `ls -lsa`.split("\n");
for each (var line in lines) {
          print("|> " + line);
After running it with the following command:
jjs -scripting script.js
We will be given with a nice listing of working directory

środa, 23 grudnia 2015

Quick fix for non-responding keyboard in Ubuntu

In order to unlock keyboard just restart ibus deamon
ibus-daemon -rd
PS. Check batteries in your keyboard if restarting does not help :)

Fun with awk - how to aggregate column values in bash

How to aggregate values in particular column

for i in $(ls); do du -sm $i; done | awk '{s+=$1;print s,$0} END{print "S:",s}'

środa, 16 grudnia 2015

Quick fix for disappeared time panel in Unity top bar

Forcing restart of unity-panel by killing it do the job. Ingenious ;D.
sudo killall unity-panel-service

niedziela, 13 grudnia 2015

How to deploy chosen artifacts of multimodule maven application

In case there is parent module you need to install also this parent pom.
  REPO_ID=myRepoIdDefinedInSettingsXml && \
  REPO_URL=http://example.com/nexus/content/repositories/releases && \
  VERSION=2.3.1 && \
  /usr/local/bin/mvn deploy:deploy-file \
     -DgroupId=${GROUP_ID} \
     -DartifactId=${PARENT_ARTIFACT_ID} \
     -Dpackaging=pom \
     -Dversion=${VERSION} \
     -DrepositoryId=${REPO_ID} \
     -Durl=${REPO_URL} \
     -Dfile=build/release-*/pom.xml && \
Once parent module is installed (but in fact doesn't need to be first) we can install our modules (MODULE1, MODULE4 and MODULE_N). Installing sources is optional (if your package phase does not generate source bundle - just skip -Dsource option.
    for FILE in $(find target/${ARTIFACTID} -name "${ARTIFACTID}*.jar" | grep -v sources); do \
      /usr/local/bin/mvn deploy:deploy-file \
        -DgroupId=${GROUP_ID} \
        -DartifactId=${ARTIFACTID} \
        -Dversion=${VERSION} \
        -DpomFile=$(dirname ${FILE})/../pom.xml \
        -Dpackaging=jar \
        -DrepositoryId=${REPO} \
        -Durl=${REPO_URL} \
        -Dfile=$(dirname ${FILE})/${ARTIFACTID}-${VERSION}.jar \
        -Dsources=$(dirname ${FILE})/${ARTIFACTID}-${VERSION}-sources.jar; \
    done; \
  done; \