Skip to content

Instantly share code, notes, and snippets.

@chenrui333
chenrui333 / download_weicheng.sh
Last active April 14, 2016 00:47
download audio book from pingshu8.com
#! /usr/bin/sh
eps=(19 20 21 22 23 24 25 26 27 28 29 30 31 32)
#total of episodes
total=${#eps[*]}
echo 'total is ', $total
# step 1, download the episodes

The script is used for encrypting the datasource passwords on jboss servers [ref][jboss-wiki].

The flow is as follows:

  1. Encrypt the plain texts of passwords
  2. Change the *-ds.xml files, like
<!-- REPLACED WITH security-domain BELOW
<user-name>admin</user-name>
@chenrui333
chenrui333 / migrate_svn_repo_to_git.txt
Last active May 26, 2016 19:45
Migrate SVN repo to Git
Tool: svn2git
Steps
1. extract the SVN repo user list
svn log {repo} --quiet | grep "^r" | awk '{print $3}' | sort | uniq
e.g.
rui.chen
2. put the authors info to authors.txt, add the email mapping
e.g.
@chenrui333
chenrui333 / interview_questions
Last active July 6, 2016 17:17
Interview questions hub
Full-stack
https://github.com/indy256/Full-stack-Developer-Interview-Questions-and-Answers
Frontend
https://github.com/h5bp/Front-end-Developer-Interview-Questions
A list of helpful front-end related questions you can use to interview potential candidates, test yourself or completely ignore.
https://github.com/khan4019/front-end-Interview-Questions
Help the front End community to rock interview http://www.thatjsdude.com/interview/index.html

Problem statement:

We still used sun proprietary API (sun.misc.BASE64Decoder, sun.misc.BASE64Encoder), which gives compilation warnings. So someday, I decide it to the codec replacement.

BASE64 codec choices:

  • apache commons
  • javax.xml.bind
  • java8 BASE64 API

http://stackoverflow.com/questions/21741166/lombok-alternatives-for-clear-code-without-getters-setters-tostring-constructors/21741964#21741964

I like this one better: http://programmers.stackexchange.com/questions/232971/implementation-difference-between-lombok-autovalue

AutoValue is a standard Java annotation processor, meaning that it uses only the javax.* interfaces for annotation processing. 
Lombok is also an annotation processor, but it references implementation-specific classes in order to do things that standard processors 
cannot. Most notably, it changes the code being generated for source classes, for example by inserting getter and setter methods. 
The standard for annotation processors very deliberately did not allow that because it was felt to violate Java's WYSIWYG qualities.
package org.hbsp.cl.directory.config;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import javax.sql.DataSource;
@Configuration

In today's team meeting, I learned an important that generally the constructor injection should be used as possible over setter injection.

  • Historically the setter-injection camp come from spring, whereas constructor-injection camp are from pico-container and GUICE. [ref][ref-1]
  • constructor injection is the way to indicate the class design problem, like if you have multiple dependnecies (usually more than three dependencies), you should re-think about the class redesign [ref][ref-2]
  • More comprehensive article with bounce of refences [ref][ref-3]

But in the team meeting, my teammate argues from the unit test perspective, which I dont think it makes too much sense, as we are using Spock to deal with the unit testing, and it can handle static or private fields pretty well.