Browsed by
Category: Tips and Tricks

Sending simultaneous requests using Python

Sending simultaneous requests using Python

Python is a perfect programming language unless you have to deal with asynchronous action. Many programmers using Javascript complain about ‘callback hell’. Still, people become grateful when they have to deal with asynchronous action (simultaneous, parallel, concurrent, etc.). Recently I needed to send several requests at the same time, instead of waiting for the previous request to finish. Moreover, all responses should be collected as one variable. 1. Ordinary request If we call 10 requests sequentially, it took 11.285 seconds….

Read More Read More

Django 301 redirect problem with React

Django 301 redirect problem with React

The answer is: ‘/’ Sometimes when you change your client-side code, and suddenly you experience a 301 redirect response from your server-side. In my case, I was using Django as a serverside and use ReactJS as a client-side. The API was implemented in a RESTful style. Most of the cases, the reason was I forgot to end with ‘/’ in my request URL. (Good) https://api.example.com/api/100/ (Bad) https://api.example.com/api/100 I haven’t really investigated what is behind this rule but, don’t panic and…

Read More Read More

[Docker-Compose] Django + PostgreSQL

[Docker-Compose] Django + PostgreSQL

When you need to launch multiple containers that work as a single application, it is difficult to manage with single Dockerfile. That’s why we need to use “docker compose” so that we can manage our containers from a higher level. The application that we will test is a simple Django application. The database is PostgreSQL, and it will also be installed using Docker. Normally, it is not recommended to install the database using Docker. The database should be running on…

Read More Read More

Hadoop 101: Multi-node installation using AWS EC2

Hadoop 101: Multi-node installation using AWS EC2

In this post, we will build the multi-node Hadoop cluster using three EC2 instances ( one for master, two for slaves). (I will assume that you know how to use AWS. If you don’t, please check this link) To run Map-Reduce task properly, you need enough memory. Therefore, we will use t2.medium type instance. (If you are a student and need some free credit, check this link.) AWS EC2 t2.medium×3 (1 for a name node, 2 for data nodes) Ubuntu…

Read More Read More

[Docker] React.js + Nginx

[Docker] React.js + Nginx

When you deploy your React.js application through Docker, you can deploy with Nginx. The basic principle is, first build a React.js application and move the generated files to “share/nginx/html” in the container. You are just replacing the default Nginx welcoming page to your React.js application. Now you just need to run Nginx. Please check the Docker file below. Check the sample project

Get id, name, and class values using Javascript / jQuery

Get id, name, and class values using Javascript / jQuery

Last time, I tried to get each input value using id, name, and class. This time we will use the id to get name/class, name to get id/class and class to get id and name. (I do not remember exactly, sometimes you need them.) Declare the div first. One for using jQuery, the other for using the vanilla javascript. Using jQuery. Using vanilla javascript  (getElementById element is singular, class and name are plural) That’s it. * If you use duplicate…

Read More Read More

Javascript replace all

Javascript replace all

In Python, if you use the replace method of string, all the relevant characters are changed, but in javascript, only the first part is changed and no further progress is made. Solution: Use a regular expression Bonus! How can we change two different characters? Solution: Use regular expressions well.