Skip to content

Instantly share code, notes, and snippets.

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.

Dealing with the error messages

Here are a few simple recommendations for dealing with returned email messages, especially if there are unfamiliar returned email error messages.

Do

  • Contact the person you're trying to mail by other means. They may not know they are bouncing mail.
  • Keep the returned message. It can help our tech support staff solve the problem quickly. It also (usually) contains the original message, which you may need to resend after the problem is fixed.
  • Try to send yourself a test message if someone tells you your email account is bouncing mail.
@chenrui333
chenrui333 / Jenkins_build_failure_troubleshooting.md
Last active September 21, 2016 19:47
jenkins builds failure troubleshooting log

Jenkins build failure troubleshooting

This gist serves the troubleshooting process of some Jenkins build failures.

@chenrui333
chenrui333 / gradle-issues.md
Created September 25, 2016 02:32
Work related to gradle issues

Multiple versions of gradle

./gradlew will download the diff versions of gradle into dists folder

ref: gardle_wrapper_doc

gradle-x.xx-all.zip vs gradle-x.xx-bin.zip

  • -all.zip (contains binaries, sources and offline documentation)
  • -bin.zip (only binaries)
  • -src.zip (ony source code)
@chenrui333
chenrui333 / Dockerfile
Created January 5, 2017 15:17
Dockerize Pingfederate
FROM amazonlinux:latest
MAINTAINER rui.chen <[email protected]>
ADD pingfederate-8.3.0.zip /
RUN yum install -y unzip wget
RUN wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpm" && \
yum install -y jdk-8u91-linux-x64.rpm
@chenrui333
chenrui333 / spring-tomcat-instrument.md
Last active February 18, 2017 19:21
Spring Tomcat Instrument

Source Code shows that it is only used for Tomcat 6. This is tied with Spring LTW (LoadTimeWeaving) functionality.

From Spring Documentation, it is not needed for Tomcat 8.0 and higher.

Do not define TomcatInstrumentableClassLoader anymore on Tomcat 8.0 and higher. Instead, let Spring automatically use Tomcat’s new native InstrumentableClassLoader facility through the TomcatLoadTimeWeaver strategy.

@chenrui333
chenrui333 / remove_title_page.py
Created March 2, 2017 14:37
Python Scripts Collections
#! /usr/bin/python
# reference: http://stackoverflow.com/questions/39574096/how-to-delete-pages-from-pdf-file-using-python
import glob
from PyPDF2 import PdfFileWriter, PdfFileReader
for fname in glob.glob('./*.pdf'):
infile = PdfFileReader(fname, 'rb')
output = PdfFileWriter()
print("file name:", fname, "with pages: ", infile.getNumPages())

python-serverless-sample