Browsed by
Category: Tips and Tricks

Pip Install Mysqlclient Error

Pip Install Mysqlclient Error

Environment: Ubuntu 18.04 Error 1. OSError: mysql_config not found Solution 1 Error 2. unable to execute ‘x86_64-linux-gnu-gcc’: No such file or directory Solution 2 Error 3. MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory Solution 3 Final Code Happy Coding!

[AWS] Connect API Gateway to EC2

[AWS] Connect API Gateway to EC2

In this post, we will talk about how to connect the AWS API gateway to EC2. Normally, we use the API gateway to make an API when we are using Lambda. However, for some cases, you might want to use an API gateway as a proxy for the EC2 instance server. Let’s say we have an EC2 instance running the Flask application that we installed from the last post. We want to make an API that is pointing the server…

Read More Read More

Python Current Unix Timestamp

Python Current Unix Timestamp

In Python, to get UNIX timestamp, you need to use the time library like below. Since its type is a float, you need to cast to int if you need. Furthermore, if you want to consider your timezone, you can simply add the hours like below. The following example is the utc+9 case. Happy coding!

How to check if a word is English or not in Python

How to check if a word is English or not in Python

Here I introduce several ways to identify if the word consists of the English alphabet or not. 1. Using isalpha method In Python, string object has a method called isalpha However, this approach has a minor problem; for example, if you use the Korean alphabet, it still considers the Korean word as an alphabet. (Of course, for the non-Korean speaker, it wouldn’t be a problem 😅 ) To avoid this behavior, you should add encode method before call isalpha. 2….

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.

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 the 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…

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 a 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…

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