06 October 2014

ubuntu 14.4, opengl, touch, gtkmm

http://vbkaisetsu.sky-air.net/wordpress/2012/03/gtk-3-4-%E3%81%AE%E3%82%BF%E3%83%83%E3%83%81%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%82%92%E8%A9%A6%E3%81%99/
g++ `pkg-config --cflags gtk+-3.0` a.cpp -o hello `pkg-config --libs gtk+-3.0` -fpermissive

https://gist.github.com/chergert/4344205
python touchy.py

chromium-browser --touch-events=enabled

http://blog.vucica.net/2014/03/ubuntu-touchscreen-and-multiscreen-hd-touchscreen-on-the-left-laptop-on-the-right.html

install GL
sudo apt-get install freeglut3 freeglut3-dev

install gtkgl
sudo apt-get install gtkgl-dev
example for gtkgl
http://gtkglarea.sourcearchive.com/documentation/1.2.3-2.2/simple_8c-source.html
compile
g++ `pkg-config --cflags gtkgl-2.0` simple.cpp -o hello `pkg-config --libs gtkgl-2.0` -fpermissive -Wformat-security

g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2


gl with gtk3

https://github.com/tdz/gtkglext

http://stackoverflow.com/questions/12076648/is-there-a-way-to-have-an-opengl-context-inside-a-gtk3-application

https://www.youtube.com/watch?v=CvBbphubIGo
https://github.com/andrepiske/tegtkgl
gcc -Wall -g `pkg-config --cflags gtk+-3.0` main.c tegtkgl.c -o hello2 `pkg-config --libs gtk+-3.0` -lX11 -lGL -lm

12 September 2013

VIA embedded EPIA boards

Anyone using these boards? Maybe not. Couldn't find much info on the connectors. But it has serial ports which is good for our needs. I forgive the hard-to-understand-connectors. =o=

Apparently, the connector for the UART Neltron 1600 series is the same as JST SH series. One of them being SHR-10V-S-B. The pin headers are QI 2mm (probably usable).

source: http://www.viaarena.com/forums/archive/index.php?t-41593.html

02 March 2013

Icon in login screen of Ubuntu 12.04

Having many custom xsessions with blank icons are confusing...
To change the white circular icon:
source
gimp /usr/share/unity-greeter/unknown_badge.png
save as
/usr/share/unity-greeter/custom_SESSIONNAME_badge.png

Install chrome 12.04

downloading .deb from google didn't work (maybe I forgot sudo)

source
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

01 March 2013

Webserver on Ubuntu 12.04

I wanted to have my own wiki on my Ubuntu.

1. install apache
sudo apt-get install apache2

2. install php
sudo apt-get install php5 libapache2-mod-php5

3. restart
sudo /etc/init.d/apache2 restart

4. test with /var/www/info.php at localhost/info.php
<?php
phpinfo();
?>


5. using home folder instead of /var/www
sudo mv /var/www /var/www-backup
sudo ln -s /home/username/Sites /var/www


And then I can have my sites also backed up on Dropbox! Yay!

Moving Pukiwiki on PHP 5.4.6

source

The frontpage was blank, I thought I was doing something wrong with my website settings.
But turns out pukiwiki wasn't working well on php 5.4 without changes.
It can be seen on the blog above, I'll rewrite it again here:

1. lib/func.php
Comment out bin2hex() function
// Inversion of bin2hex()
/* 
function hex2bin($hex_string)
{
// preg_match : Avoid warning : pack(): Type H: illegal hex digit ...
// (string) : Always treat as string (not int etc). See BugTrack2/31
return preg_match('/^[0-9a-f]+$/i', $hex_string) ?
pack('H*', (string)$hex_string) : $hex_string;
}
*/


2. plugin/ls2.inc.php
array_walk($args, 'plugin_ls2_check_arg', & $params);
to
array_walk($args, 'plugin_ls2_check_arg', $params);

It already worked at this stage, but just in case, I also did this

3. lib/convert_html.php, lib/link.php, lib/init.php
change all & new to new

When moving pukiwiki to a new server, need to do:
chmod 666 *
chown username:username *

for wiki/ backup/ diff/

Tar newly changed files

find /home/user/Dropbox/ -name '*pdf' -mtime -2 | xargs tar -rf ttt.tar; gzip ttt.tar

file changed 2 days ago

Locate command not finding

When the locate command not finding something, it may need to be updated.
sudo updatedb

Preventing Gnome to override Xmodmap Settings

Calling gnome-settings-daemon causes xmodmap keyboard settings to be override. To solve:
1. Dirty way, put sleep after calling gnome, before calling xmodmap
gnome-settings-daemon&
sleep 1; xmodmap ~/.Xmodmap

2. Put into .bashrc, but this causes weird message xmodmap: please release the following keys within 2 seconds
if [ -f ~/.Xmodmap ] ; then
xmodmap ~/.Xmodmap
fi

3. I ended up using this method, but this should also be used with caution, since it seems to remove some custom shortcut settings...
gsettings set org.gnome.settings-daemon.plugins.keyboard active false


Warning: do not use combination of Mod4+p, it's mapped to some display setting by something... Just map the key to Mod3 or others.

Japanese Input on Ubuntu 12.04

Uses ibus
sudo apt-get install ibus-anthy
Add Anthy in Input Method
ibus-setup
in .xsession add
ibus-daemon&

22 February 2013

Sound Blaster Play on Ubuntu

Haven't been able to listen to audio for quite awhile on my Ubuntu.
I finally got myself a Sound Blaster Play.
It didn't worked by just simply plugged.
Calling alsamixer, the sound card used by the system is the default Intel one, not recognizing the Sound Blaster.

So, I tried changing the default sound card, by what's instructed in this post
1. cat /proc/asound/modules
see your default sound card name
2. sudo gedit /etc/modprobe.d/alsa-base.conf
# Prevent abnormal drivers from grabbing index 0
options snd_hda_intel index=1 #change default sound card index to 1

3. reboot

After rebooting, I still couldn't here any sounds.
I couldn't even open alsamixer anymore... =____=;;;
And finally it was solved by opening gnome-volume-control and unmute the sound
I'm using wmii, so I don't have any sound bar, I wonder if the problem was just because it was muted...
But oh well, now I can listen to audio, nevermind what was it...

18 February 2013

Lapack in Mac OS X

I previously used this when compiling:
gcc ... -llapack
It worked, but I came into error for these two:
 dgetrf_
 dgetrf_
It was solved by using
gcc ... -framework Accelerate

Using Posix Threads in Mac OS X

Got into an EMFILE error
Too many semaphore descriptors or file descriptors are currently in use by this process.
when trying to run a program which runs on Ubuntu well.
The problem is that apparently Mac creates a file for every semaphore, and there's a limit for the number of opened files at one time, and it's set very low for Mac...
This can be fixed by
ulimit -n 10000
do not use sudo.

06 February 2013

Put picture in absolute position in Latex (x,y)


\usepackage[dvipdfm]{graphicx}
\usepackage{mediabb} %for putting in jpg images
\def\Put(#1,#2)#3{\leavevmode\makebox(0,0){\put(#1,#2){#3}}}
...

\begin{document}
\Put(320,-254){\includegraphics[height=3.5cm]{p.jpg}}
% 320 is x to the right at increasing value
% -254 is y to bottom at decreasing value

31 January 2013

r plot


Saving the plot beforehand
jpeg('rplot.jpg')
plot(x,y)
dev.off()

If error for above, save current active plot
dev.copy(png,'myplot.png')
dev.off()

26 January 2013

2D PCA with SVD in R

res.svd <- svd(x)
t <- res.svd$u %*% diag(res.svd$d)
t1 <- t[,1]
p1 <- res.svd$v[,1]
gues <- t1 %*% t(p1)
plot(x)
points(gues[,1],gues[,2],col='red')

25 January 2013

Factor Analysis in R


fa.alldat <- factanal(alldat[c(1,2,3)],1,scores="regression");
biplot(fa.alldat$scores,fa.alldat$loadings,cex=0.5)


factanal
using maximum likelihood factor analysis

fa
is basically using Principal Axes

21 January 2013

Bash Script Compilation

for loop
for((i=6; i<10; i++)) ; do ... done

leading zero
valf=$(printf "%.5d" "$val")

the server my wiki is on is not feeling well currently... ;_;

Summary for MCA in R

standing <- read.table("filename.dat",sep=",",header=TRUE,row.names=1)

summary(gmo[,1:16])

specifiying supplement (sup, eg. description of individual answering questionairre) on the data:  res.mca <- MCA(tea,quali.sup=c(19:21,23:26))

names(standing)

ggplot:
mca1 = MCA(standing, graph = FALSE)
cats = apply(standing,2,function(x) nlevels(as.factor(x)))
mca1_vars_df = data.frame(mca1$var$coord, Variable = rep(names(cats), cats))
mca1_obs_df = data.frame(mca1$ind$coord)
ggplot(data = mca1_vars_df, aes(x = Dim.1, y = Dim.2, label = rownames(mca1_vars_df))) + geom_hline(yintercept = 0, colour = "gray70") + geom_vline(xintercept = 0, colour = "gray70") + geom_text(aes(colour = Variable)) + geom_density2d(colour = "gray80") + geom_text(data = mca1_vars_df, aes(x = Dim.1, y = Dim.2, label = rownames(mca1_vars_df), colour = Variable))

category comparison (one with others):
catdes(standing,num.var=2)
    $test.chi2


run a script containing printouts and plots:
source("script.r",print.eval = TRUE)

(note: printing is turned off in loops), so to plot in a loop:
print(ggplot(...))

leading zeros:
u <- formatC(i, width = 2, format = "d", flag = "0")
or
sprintf("Leading zeros:%04d", x)

Variables representation (use new.plot when the graph window is not showing anymore):
plot.MCA(res.2,choix="var",new.plot=TRUE)
add cex=0.5 for small font

Plotting data.frame:
X11();barplot(c(as.matrix(mca2$eig[3])))

Data used for "variables representation" plot in MCA:
res.mca$var$eta2

17 January 2013

R related installing on old ubuntu (9.10 karmic)

wanted to install ggplot2

install.packages("ggplot2")
but couldn't get it through cran anymore

sudo apt-get install r-cran-ggplot2
also couldn't get it through package

so the other way was to download the old tar from cran (start from a relatively new one, the command will give error if your R is too old, karmic is R 2.9.2 btw)
and apparently, this command saves me (I remembered installing manually to R folders, hmm)
R CMD INSTALL Desktop/packagename.tar.gz

PS. sigh, never edit a blogger post anymore, blogger ruined my previous R post