Jun 15
Problem: For your custom Python class if you try to use json serializer or try to return the object through REST api you see this error – Object of type ABC is not JSON serializable
Solution: For simple custom class you can use following solution
import json
class ABC:
def to_json(self):
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
abc = ABC()
abc.to_json()
June 15th, 2022 in
Other,
Technical | tags:
Python |
No Comments |
1,044 views
Aug 24
In some cases you might run into this git issue
fatal: multiple stage entries for merged file ‘xyz’
OS : Mac
Git : 2.5.4
Solution:
1. Delete git index rm .git/index
2. Add files again git add -A
3. Commit files again git commit -m "Message"
August 24th, 2018 in
BASH,
Mac OS | tags:
git fatal |
No Comments |
2,780 views
Aug 10
Recently ran into this weird issue while running the application using Eclipse photon. The message looked like this
objc[3979]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
This is a known issue with some earlier jdk versions; Though oracle website claims that it is a harmless issue. The easiest fix is to upgrade your jdk version. In my case upgrading to jdk1.8.0_151.jdk fixed the issue.
August 10th, 2018 in
Eclipse,
Java,
Mac OS,
Other,
Technical |
No Comments |
4,194 views
Aug 07
Problem: Post file data & additional parameters to REST API through curl or command line
Solution:
curl -F ‘file=@{LOCAL_FILE_LOCATION}’ http://localhost:8080/api/data/add -F “info={“p”:false,”subtype”:”BT”,”userid”:”abcd@gmail.com”}”
Eg Java API to consume the above curl data:
@RequestMapping(value = "/add", method = RequestMethod.POST)
public ResponseEntity<String> addData(@RequestParam("info") String info, @RequestParam("file") MultipartFile file) {
August 7th, 2018 in
Java,
Technical | tags:
curl,
REST |
No Comments |
7,273 views
Aug 01
AWS had recently launched M5 instance type; which are essentially upgrade to M4 instances. We wanted to use the latest instances so we decided to upgrade our server infrastructure.
But it’s a tricky processes then we had anticipated and AWS documentation has tooo much information. Here are the steps we took:
-
- Before you start – Create an image of your current system
- Assumption – You have an active M4 instance
- Check if ENA (Elastic Network Adapter) support is available on your machine. This is must for M5 instance. From your local console (assumption aws cli has been installed)
aws ec2 describe-instances --instance-ids instance_id --query "Reservations[].Instances[].EnaSupport"
If you get empty response then it means it’s not enabled.
[]
Read the rest of this entry »
August 1st, 2018 in
BASH,
Linux,
Other,
Systems,
Technical | tags:
EC2 |
No Comments |
6,896 views
Nov 20
I don’t like to use sudo/root while installing third party softwares. I ran into issues while installing nodejs. Then I found a nice article which takes cares of this issue.
npm installs packages locally within your projects by default. You can also install packages globally (e.g. npm install -g ) (useful for command-line apps). However the downside of this is that you need to be root (or use sudo) to be able to install globally.
Here is a way to install packages globally for a given user.
1. Create a directory for your global packages
mkdir “${HOME}/.npm-packages”
Read the rest of this entry »
November 20th, 2015 in
BASH | tags:
JavaScript |
No Comments |
4,432 views
Oct 26
If you are trying to integrate Google oauth into your application then you might see this kind of error. This happens because you didn’t correctly configure the redirect url in Google console. Follow this steps:
– Login to https://console.developers.google.com & Go to your existing project
– Go to Api & Auth -> Credentials
– In my case I was trying to integrate it locally so ‘Authorized Javascript Engines’ say ‘http://localhost:8080’
– Now in ‘Authorized redirect URIs’ add entry ‘http://localhost:8080/signin/google’. You are done!
October 26th, 2015 in
Open Source,
Random Picks.. |
No Comments |
3,925 views
Oct 20
If you ever run into this exception in your spring-hibernate setup then just do following things.
1 – Annotate all your @Repository classes with @Transactional attribute
2 – Add @EnableTransactionManagement to your config class which is generating sessionFactory & hibernateTransactionManager. That’s it 🙂
October 20th, 2015 in
Java,
Open Source,
Random Picks.. |
No Comments |
3,802 views
Oct 16
If you are using a spring boot in your application then you might stumble upon spring-boot-parent artifact is represented this way e.g.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>
<relativePath /> <
</parent>
But in case if you already have multi-module project setup, you might have existing parent structure. How to integrate two?
Solution:
Just keep your existing project structure as it is and instead of the above spring block add a dependency management section in pom. e.g
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>${springboot.version}</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
This was suggested on the stackoverflow & it did trick for me 🙂
October 16th, 2015 in
Java,
Open Source,
Other |
No Comments |
2,520 views
Oct 12
Ran into weird issue with hibernate
criteria.setProjection(Projections.rowCount());
long count = (Long) criteria.uniqueResult();
in above case criteria.uniqueResult() should never return null.
Solution:
This happens when you have multiple sessions factories in the code & they are not wired correctly. Just match them correctly so they don’t interfere with each other. 🙂
October 12th, 2015 in
Open Source,
Other,
Random Picks.. |
No Comments |
2,896 views