I needed to design a UI using JavaFX. I use SceneBuilder for building my UI. I found this invaluable link for using AnchorPanes concept to make it work inside TabPanels. It really cleared my concepts in a minute and I had a working tab based UI shortly.
Author Archives: cyberaka
Installing pip on MacOS
I recently started exploring python and immediately ran into the following issue:
$ pip install requests
-bash: pip: command not found
A quick google search yielded this result. So basically on MacOS you have Python preinstalled along with easy_install command. So the following command installs pip:
$ sudo easy_install pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 9.0.1
....
....
Processing dependencies for pip
Finished processing dependencies for pip
A quick and handy solution indeed!
Adding docker support in Spring Boot application
Adding docker containerization support in a working Spring Boot application is surprisingly easy.
Step 1: Add the docker maven plugin to your pom file.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.3.4</version> <configuration> <repository>${project.artifactId}</repository> </configuration> </plugin> </plugins> </build>
Step 2: Build the application as well as the docker image
mvn clean package install dockerfile:build
Step 3: I have a local docker registry setup in my Lan so I prefer to push this image to my network registry manually (this can be automated as well however).
docker tag my-app:latest my_network_registry_host:5000/my-app
Step 4: Now we can bootup this docker image anywhere in the network.
docker run \ --detach \ --link <any database link> \ -e <Environment variable 1> \ -e <Environment variable 2> \ -p 8080:8080 \ --name my-app \ my_network_registry_host:5000/simply-hr
docker logs --follow simply-hr
Install Python Offline
Found a good article which enabled me to install python 2.7.3 inside a folder.
http://www.benhepworth.com/blog/2016/05/18/install-python-to-separate-directory-on-linux-in-5-easy-steps/
Setting up Redmine docker instance
In order to setup a fully functional Redmine server via Docker I use the following consolidated command:
docker run \ --detach \ --name redmine \ --link mysql:mysql \ --publish 3000:3000 \ --env="REDMINE_DB_MYSQL: redmine" \ --env="REDMINE_DB_PASSWORD: redmine" \ --volume /Volumes/DATA/Abhinav/Docker/redmine/files:/usr/src/redmine/files \ redmine
This connects my mysql docker instance with sonar and it is able to create tables and start using MySQL properly for storing all it’s data.
Java Code To Extract Email From Text
I found a good piece of code which can be used to extract multiple email from a String. A modified version of the code is listed below:
public static String readContactEmailFromString(String resumeText) { final String RE_MAIL = "([\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Za-z]{2,4})"; Pattern p = Pattern.compile(RE_MAIL); Matcher m = p.matcher(resumeText); StringBuilder sb = new StringBuilder(); while(m.find()) { if (sb.toString().contains(m.group(1))) continue; if (sb.toString().isEmpty()) { sb.append(m.group(1)); } else { sb.append("; " + m.group(1)); } } return sb.toString(); }
Fetching colleague’s fork on Github
I am currently using Github and all project members have forked the main repository into private repository. Now the problem is that I need to review my colleagues code committed in his branch inside his forked repository. So to do this I found out a good article that showed me exactly how to do that. I used the following approach.
git remote add my-colleague https://github.xyz.com/my-colleague/project.git git fetch my-colleague git checkout -b my-colleague-branch --track my-colleague/branch
After I do this I can see all the work done by my colleague and I can switch back to my branch anytime.
Spring Certification
We can now do Spring certification without going for Pivotal training. It was long due and here it is finally!
Can you take Spring certification without Pivotal Training Course?
5 Spring Framework Books for Java developers (Includes Spring Security and Spring Boot) – Best of lot
Read more: http://www.java67.com/2016/12/5-spring-framework-books-for-java-programmers.html#ixzz4hVU7visy
How to recover from a hung SSH session on Mac
A simple technique on MacOS which I use every now and then when my SSH connections hang due to network disconnect. You can immediately terminate the hung SSH session by pressing ~. (tilde and dot) keys together.
http://apple.stackexchange.com/questions/35524/what-can-i-do-when-my-ssh-session-is-stuck
List of good Curl commands
I use CURL for debugging my REST endpoints every now and then if I don’t want to use Postman or DHC clients. I usually like to copy paste results / statistics from command line into emails to my colleagues. This gives them a plain jane command which they can use to test themselves as well as compare their results with mine. The following article has some good pointers on how to use CURL and some very practical examples have been provided.
15 Practical Linux cURL Command Examples (cURL Download Examples)