Sunday, January 19, 2014

Walk on a trail

an hour walk on the trail 140, 341, 342, really nice weather.

Gerrit+LDAP

setup gerrit with LDAP authentication.

Here are the key note for gerrit.conf file
[auth]
        type = LDAP
[ldap]
        server=
        accountBase= ou=people,dc=*,dc=*
        accountPattern=(&(objectClass=person)(uid=${username}))
        accountFullName= mail
        accountEmailAddress = mail
[httpd]
        listenUrl=http://*:8180/

 also tried apache2 proxy to LDAP. key note
created a new virtual host with port 8082, have to add this to the port.conf
the gerrit port is still 8180.
in gerrit.conf
canonicalWebUrl = http://192.168.1.30:8082/
[httpd]
        listenUrl = proxy-http://127.0.0.1:8180/
the LDAP way is easier to config, the proxy one is working halfway, can only login first user and creat admin. I don't have time to figure out why
 another lessons learned here for gerrit username.
User names cannot contain spaces.  Currently they are restricted to be
strings that match the following regular expression:
  ^[a-zA-Z][a-zA-Z0-9._-]*[a-zA-Z0-9]$

otherwise, gerrit login will give "name does not conform" error.

Saturday, January 18, 2014

Apache+openldap without SSL

This is a experimental in my home network without using ssl.

sudo a2enmod ldap authnz_ldap authn_alias
the red part is appended.  
sudo emacs sites-available/default
        AuthLDAPURL ldap://localhost:389/dc=****,dc=****?uid?sub?(objectClass=*)

        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
       
                Options FollowSymLinks
                AllowOverride None
       
       
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all

                AuthName  "Authentication"
                AuthBasicProvider ldap-internal
                AuthType Basic
                AuthzLDAPAuthoritative on
                Require valid-user
       
that's it, access apache with LDAP.

Scribefire not working now

I have been using scribefire to publish blogs for 5 years, and recently ( since my last post), it stopped working with this site. I am too busy to figure out why and I saw other people's comments on the apps comments section complaining for the same thing.I have a home blog using apache roller, so scribefire will allow me to publish to both site. if some one figured out the cause, I would like to use scribefire again.

Tuesday, December 31, 2013

setup openwrt on Asus rt-n15 as wireless client with relayed(Pseudo-bridge)

openwrt on asus rt-n15(Attitude Adjustment 12.09|Load:0.26 0.08 0.06)
  • rt-n15
Flash from a Windows PC using the Firmware Restoration utility. (Download and install the Firmware Restoration Utility to your PC.)
The Asus RT-N15 has a failover mode, (refer to rt-n16)http://wiki.openwrt.org/toh/asus/rt-n16
To launch the recovery mode disconnect power from the router first.
Hold the WPS button while replugged the power to the router to reset nvram, router will restart 2x. Hold the RESET button while replugged the power to the router to get into recovery mode : tftpd is listening. The power LED should start to blink (low frequency, ~1 time every 3 seconds). Retry if that won't work for you.
The router IP in the recovery mode is 192.168.1.1 255.255.255.0.
Configure your PC (don't use 192.168.1.1)
netsh interface ip set address name="Local Area Connection" static 192.168.1.2 255.255.255.0
Ping 192.168.1.1 should give a response.
Launch the Firmware Restoration utility, select the firmware and press the Upload button.
Ignore the warning, we wanna be on OpenWRT!
telnet to 192.168.1.1 and login as root, there is no password, type in passwd to set a password for root.
login in to web interface and assign a DNS server to the Lan interface.
close telnet and use ssh to login 192.168.1.1
login in to web interface and assign a DNS server to the lan interface.

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install relayd
root@OpenWrt:~# opkg install luci-proto-relay

root@OpenWrt:~# /etc/init.d/relayd enable

  • use luci to config routed client relayed.
Basically.
  1.  enable 802.11 bgn(radio0) and scan wireless network.
  2. join the wireless network and it will ask for passcode, name of the new network(wwan by default) and create/assign firewall zone(select "lan" here)
  3. create a new network interface (" "stabridge"), select relayed bridge and select connect lan and wwan.
  4. network firewall under zones, change the forwarding for and lan and wwan to "accept"
 

openwrt on tp-link wdr4300

the openwrt was installed and configured as routed client relayed, and I need to reset the openwrt to factory default to use it as a WAP, here are the steps

  1. Power the router up;
  2. After powering up track the SYS light when it starts to blink, when it does press and hold the WPS/reset button till SYS lights starts to blink faster – router goes to recovery mode;
  3. Telnet to the router on 192.168.1.1 – no password needed (if your computer doesn’t gets IP address from DHCP assign it manually for i.e. 192.168.1.200 with netmask of 255.255.255.0);
  4. In telnet terminal type `mtd -r erase rootfs_data` to reset OpenWRT to it’s defaults. then the router will reboot.
  5. after reboot, telnet in and passwd to set a password.
  6. use PUTTY to ssh to 192.168.1.1 with username root and the password.

Monday, October 14, 2013

Installation of 389 Directory Server on Ubuntu server 12.04.3 LTS

  • sudo apt-get install python-software-properties
  • sudo add-apt-repository ppa:ubuntu-389-directory-server/ppa
  • sudo apt-get update
  • sudo apt-get install 389-admin 389-ds-base 389-ds-console

then

  •  sudo /usr/sbin/setup-ds-admin

Saturday, October 05, 2013

mysql jdbc input Chinese

in glassfish 

 

Edit JDBC Connection Pool Properties

 

add properties

Name: characterEncoding 
Value: UTF-8 

Name: useUnicode 
Value: true 

Monday, September 30, 2013

setup glassfish and roller

  • in .30
  • first disable jboss startup by "sudo update-rc.d -f jboss remove"
  • create glassfish user and group
  • mv glassfish to /usr/local/share/glassfish
  • chown to glassfish:galssfish
  • create a admin user and password:  ./asadmin change-admin-password
  • ./asadmin --host  30 --port 4848 enable-secure-admin to allow remote access to admin page
  • login to admin and change default http listener port to another number
  • copy mydql jdbc driver to /domains/domain1/lib/ext and roller-custom.properties to domain1/lib/classes.
  • add jdbc connection pool for roller and jdbc resource for jdbc/rollerdb
  • have to create the rollerdata dir in glassfish home and change the properties in roller-customer.properties
  • .have to install java jdk7 instead of using jre(jdk-7u40-linux-i586.gz)
  • sudo lsof -i tcp and found the job# for glassfish and kill it
  • scp the jdk
  • jdk-7u40-linux-i586.gz
  • sudo mv ./jdk1.7.0_40 /usr/lib/jvm/jdk1.7.0
  •  sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
  • sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
  • sudo update-alternatives --install "/usr/bin/javac" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
  •  sudo chmod a+x /usr/bin/java
  •  sudo chmod a+x /usr/bin/javac
  • sudo chmod a+x /usr/bin/javaws
  • sudo chown -R root:root /usr/lib/jvm/jdk1.7.0
  • sudo update-alternatives --config java
  • sudo update-alternatives --config javac
  • sudo /etc/init.d/apparmor restart
  • edit /etc/profile.d/java.sh and put

"export JAVA_HOME=/usr/lib/jvm/jdk1.7.0

export PATH=$JAVA_HOME/bin:$PATH"

  • restart the server  and cd to glassfish/bin sudo ./asadmin craete-srevice
  • sudo chmod 755  /usr/local/share/glassfish/glassfish4/glassfish/lib/nadmin
  • start the GlassFish-domain1 service.

Sunday, September 22, 2013

glassfish 4 and roller 5.0.1

  • get tired of twisting  apache roller for jboss EAP,  decide to try glassfish 4.0
  •  downloaded and installed glassfish-4.0.zip  full java EE platform
  • unziped and copied mysql jdbc to the domain1/lib/ext
  • copied roller-custom.properties to domain1/clases
  • deployed the download roller-5.0.1-javaee.war
  • woala!!, it works.

Lessons learned:

I am not a Java App server guru, but worked more than 2 years with glassfish(3 then 4) and 3 years with jboss EAP(5, then 6)

a lot of applications downloaded from the internet(roller, nexus, and others) will work with glassfish without modification

for jboss, the apps  need spend some time painfully sniffing through the source code and a lot of time I have to give up and go back to use glassfish.

This is my first time use glassfish 4, and I did not notice a lot of change between 3 and 4, the speed is decent.

between jboss EAP 5 and EAP6, the change is radical and as a developer, a lot of things I did in EAP 5 are completely different in EAP6.

 

build roller 5.0.1 ro jboss eap 6.0

  • download the roller source and import existing Maven projects into eclipse
  • maven clean complie and install  roller-project(parent)
  • roller-core maven clean compile install with no problem
  • roller-planet-business stopped, change pom for guice. 

  <dependency>

  <groupId>com.google.inject</groupId>

  <artifactId>guice</artifactId>

  <version>3.0</version>

</dependency>

  • have to copy droptables.sql to  source/main/resource/sql
  • here are the missing dependency modificaton for roller-weblogger-business

<dependency>

  <groupId>com.google.inject</groupId>

  <artifactId>guice</artifactId>

  <version>3.0</version>

</dependency>

  <dependency>

            <groupId>net.oauth.core</groupId>

            <artifactId>oauth</artifactId>

             <version>20100527</version>

            <scope>compile</scope>

        </dependency>

 

        <dependency>

            <groupId>net.oauth.core</groupId>

            <artifactId>oauth-provider</artifactId>

             <version>20100527</version>

            <scope>compile</scope>

        </dependency>

  • added the net.oauth dependency to roller-weblogger-webapp and roller-weblogger-web and compliled them.
  • deployed roller-weblogger-webapp to jboss
  • tried a lot of things and installed jboss eap6.10, still not working

Saturday, September 21, 2013

maven nexus, apache roller

  • nexus on both 30 and 40.
  • downloaded source for roller and will try to install roller in jboss eap 6.0

Wednesday, September 11, 2013

Restore Roller Mydql Database


  • use ubuntu live cd  and choose " fix broken installation"
  • mount a usb to /media/external by choose the use from "sudo fdisk -l"
  • installed new ubuntu server 12.04 LTS from burned cd(tried usb and DVD not working).
  • installed mysql server after server started(LAMP won't work because of  dns issue of home).
  • mount usb and copy roller dir to /var/lib/mysql
  • sudo service mysql stop
  • sudo  chmod -R 660 /var/lib/mysql/roller/
  • sudo chmod 700 /var/lib/mysql/roller
  • sudo chown -R -f mysql:mysql /var/lib/mysql/roller
  • service mysql start
  • mysqlcheck --repair --all-databases
  • need to dump the roller db regularly, the weblogentry table is the most important.

mysql in ubuntu 12.04 LTS allow remote access

To expose MySQL to anything other than localhost you will have to have the following line uncommented in /etc/mysql/my.cnf and assigned to your computers IP address and not loopback
#Replace xxx with your IP Address 
bind-address        = xxx.xxx.xxx.xxx
Or add a bind-address = 0.0.0.0 if you don't want to specify the IP
Then stop and restart MySQL with the new my.cnf entry. Once running go to the terminal and enter the following command.
lsof -i -P | grep :3306
That should come back something like this with your actual IP in the xxx's
mysqld  1046  mysql  10u  IPv4  5203  0t0  TCP  xxx.xxx.xxx.xxx:3306 (LISTEN)
If the above statement returns correctly you will then be able to accept remote users. However for a remote user to connect with the correct priveleges you need to have that user created in both the localhost and '%'.
Before granting user access, you need to login MySQL. 
$ mysql -u root -p
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
Then
GRANT ALL ON *.* TO 'myuser'@'localhost';
GRANT ALL ON *.* TO 'myuser'@'%';
If you don't have the same user created as above, when you logon locally you may inherit base localhost privileges and have access issues. If you want to restrict the access myuser has then you would need to read up on the GRANT statement syntax HERE If you get through all this and still have issues post some additional error output and the my.cnf appropriate lines.

Thursday, August 12, 2010

jsf, spring security and jstl




The following code get session spring security context and show log in name.

<--c:forEach items='${sessionScope}' var='p'>
<--ul>
<--li>Parameter Name: <--h:outputtext value="'${p.key}'/"><--/li>
<--li>Parameter Value: <--h:outputtext value="'${p.value}'/"><--/li>
<--/ul>
<--/c:forEach>
You logged in as <--h:outputtext value="${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.username}">

-->


Tuesday, June 02, 2009

I delete my glassfish by accident from netbeans, so,I tried to put it back by using add server in netbeans, but the add server wizard won’t show up.

It turns out to be there is a bug with jdk6 update12 and netbeans, so I have to download and install jdk6 update11. And start netbeans from command line with jdk6u11.

Here is the command \dir\NetBeans 6.5\bin>netbeans.exe --jdkhome "\dir\jdk1.6.0_11"

now I can add my glassfish server back to netbeans

Friday, February 22, 2008

Java vs Python (Random thought)

Java 

Python 

Statically typed 

Dynamically typed 

Not compact, (through class)

Compact (scripting like)

GUI, swing, has a lot of nice widgets

Tkinter by default,

Bracket and semicolon

Colon and space

Javac compile into byte code

Command line interpreter

Parameter pass by value ( a value of reference to an object) 

Parameter pass by value( a value of reference to an object) 

  
  
  
  


 

Reference:

  1. python_java_side-by-side.html
  2. does java pass by reference or by value

Thursday, March 01, 2007

DSLR 有了LCD取景,已经不存在像差,DSLR的反光取景没有必要保留
我们先看LCD取景存在的弊端:
(1)LCD取景非常费电。
(2)LCD取景根据光线强弱自动调节感光度,使拍摄所得和实际所见不一致,特别是在光线较暗时。
(3)LCD取景要求机械快门一直打开,结果导致曝光动作繁琐,快门迟滞延长,不利于连拍和抓拍。 由于弊端(2)的存在,很多情况下不得不求助于光学取景器;但DC上的旁轴取景器又存在像差,这给拍摄带来了无法解决的难题。
所以从现在看来,保留反光取景还是很有必要的。
观点二、DSLR不是数码相机的终结者 这个观点笔者持同意态度。就是在目前,数码相机的种类也不是只有数码单反一种,还有DC和120数码后背等多种形态,只是众多不同类型的数码相机适用范围不同。它们有各自不同的市场定位。 再看DSLR的CCD(包括DC的),由于CCD对光线色彩没有识别能力,只能通过在一块CCD前增加低通滤波器来感应不同的颜色(R,G,B),红、绿、蓝三种颜色紧密排列,CPU再很据插值算法来还原得到图像,所以数码相机只是对外界模拟信号的数字化,并不是完整的记录,因此数码相机目前和传统相机的成像差距仍然存在。
有没有更好的办法改进提高数码相机模仿外界模拟信号的精度呢?答案是肯定的,比如应用于专业摄像机的3CCD技术。3CCD技术就是用3块CCD来分别感知如射光线的RGB三种色彩,再根据套色算法合成全彩图像。但要实现3CCD技术,目前的DSLR和DC的内部结构都不能满足(镜头后截距的限制),应此相机结构将发生彻底的改变,而先前的单反镜头也将不再适用。至于CCD/CMOS将来朝哪个方向发展,现在就不得而知了。或许现在盼望的135满画幅的尺寸到那时已经远不能满足需求。
新结构带来的不只是机身上的参数变更,影响更多的恐怕在于镜头生产商的镜头群。尼康,佳能,腾龙,适马等各镜头生产厂家,花费数十年到目前形成了规模庞大的通用镜头群,如果一旦单反相机由新机型取代,那么意味着,各镜头生产厂家必修更换生产线内容,重新开发一系列适用于新机型的镜头群,这个时间需要多久呢?2年?5年?10年?还是更长的时间?
我们玩摄影,应该从“利己”出发,而不应该从“不利他”出发。所谓“利己”和“不利他”就是说,选择有利于我们创作使用的相机,为我们所利用,而不是因为目前相机技术不够成熟而不用(如DSLR),更有甚者,认为购买使用DSLR是为DLSR生产商做试验,从思想上抵制DSLR;有这样想法的人最终只能是终日等待。俗话说,“临渊羡鱼,不如退而结网”,说的就是这个道理。

I am looking for a DSLR. This is something I find useful