On these few months, I’m focusing on doing a Go project. Instead of working on a project, I also have some Go projects to maintain, so I’m using GVM to manage multiple versions of Go. Besides using the multiple versions, I also separated pkgsets between the projects. About how to manage the versions and pkgsets, we can read the introduction here. GVM is easy to use. I usually use these commands below when working on Go project. ...
Django Admin Custom Page
In the previous post, I told you that I built a website to help my wife manage the orders for her shopping service. This year, she registered to a marketplace to gain more customers. She can manage her goods and orders in that marketplace website. But, the marketplace website is still on development, there are some important features we cannot access, such as calculating the sales and profit. We have to calculate it manually and propose to withdraw the money. ...
Django Ajax Selects Edit Button
Last year, my wife started open a shopping service for entrusted goods. When she started getting overwhelmed managing the orders, I built a simple website for her, so she can manage the products and the orders through the website. By the way, I was using Django and Django Admin to build the website. Few days ago, she asked me to add the autocomplete function when searching the product on the create order page. She asked for it because she already had a lot of products. Until now, she has around 190 products to manage. You can imagine that it would be difficult to choose a product when using mobile browser. ...
Twitter Media Upload with go-twitter
On the previous post, I said that I was doing the web service migration in the company, porting the code from Scala to Go. One of the task was integrating the web service with Twitter: getting the data, posting the status, and uploading the media. By the way, I am using go-twitter to do the integration. Everything ran smoothly until we want to upload the image to the twitter. There is no method related to the media in the library. After reading some issues, we found this pull request. We can see that there is a method for uploading any media inside the commit log, but we don’t know why the owner hasn’t merged them. ...
Mongo Go Driver Custom Decoder
In this article, I will show you how to custom the decode function of mongo go driver. We use it to decode the query result from mongodb to struct that we have already set. Right now I have a task to migrate the web app, from Scala to Go. Everything went well until we found one problem, when we save the datetime data in mongodb and we want to display the data on unix timestamp. ...
Nginx Reverse Proxy Flask-restx Swagger Configuration
Few days ago, I was setting up nginx reverse proxy for my project. I was using gunicorn for the HTTP Server with flask-restx for the web framework. Actually this was the first time for me using this combination. I usually use uwsgi for the deployment. It was quite simple to deploy flask with gunicorn. You can use port binding. gunicorn --bind 0.0.0.0:9999 app:app Or you can use unix sock. gunicorn --workers 2 --bind unix:sockname.sock -m 644 app:app I was using the second option, using unix sock, so this was the configuration I use for nginx reverse proxy. ...
Hot Score!
Few weeks ago, my office had a sharing session. My friend shared how he created a tinder bot to do automatic swiping using selenium. Actually the main point of the presentation is how to use selenium (GUI or script) to finish your daily tasks automatically. But, I was interested with the tinder bot. I though, instead of doing mass swiping to the right or left, we can choose whether he/she is based on our preference or not. If he/she is based on our preference, then swipe right. ...
Implement Chained Dropdown List in Django Admin
It is not difficult to create chained dropdown list in Django with custom template, but in one project, I need to create it in Django admin page. I need to create chained dropdown list of area in my app. For your information, my country, Indonesia, has four levels of area. And this is my area model. from django.db import models class Provinsi(models.Model): name = models.CharField(max_length=255, null=True, blank=True) code = models.IntegerField(null=True, blank=True) class Meta: db_table = 'provinsi' verbose_name_plural = 'provinsi' def __str__(self): return self.name class Kabupaten(models.Model): name = models.CharField(max_length=255, null=True, blank=True) code = models.IntegerField(null=True, blank=True) provinsi_code = models.IntegerField(null=True, blank=True) provinsi = models.ForeignKey( Provinsi, on_delete=models.CASCADE ) class Meta: db_table = 'kabupaten' verbose_name_plural = 'kabupaten' def __str__(self): return self.name class Kecamatan(models.Model): name = models.CharField(max_length=255, null=True, blank=True) code = models.IntegerField(null=True, blank=True) kabupaten_code = models.IntegerField(null=True, blank=True) kabupaten = models.ForeignKey( Kabupaten, on_delete=models.CASCADE ) class Meta: db_table = 'kecamatan' verbose_name_plural = 'kecamatan' def __str__(self): return self.name class Kelurahan(models.Model): name = models.CharField(max_length=255, null=True, blank=True) code = models.BigIntegerField(null=True, blank=True) kecamatan_code = models.IntegerField(null=True, blank=True) kecamatan = models.ForeignKey( Kecamatan, on_delete=models.CASCADE ) class Meta: db_table = 'kelurahan' verbose_name_plural = 'kelurahan' def __str__(self): return self.name I have another app called warehouse. This app has some foreign key columns related to area model (one to many relationship). This is the warehouse model. ...
Swagger implementation for Go HTTP
The most important thing when building the web API is creating API documentation. With API documentation, it will be easier for another programmer to integrate their application with your web service. In this post, I will show how to integrate Go net/http package and swagger using http-swagger package. Installation First, we have to install swag package. $ go get github.com/swaggo/swag/cmd/swag Initialization Then we have to generate first `docs` folder, so we could import it to the application. Please run it on root folder of the project. ...
Kubectl, Master NotReady
When I setup the kubernetes at the first time, after execute kubeadm init and apply the pod networks plugin, flannel or calico, I see that the master status is not ready. linx@node-1:~$ kubectl get nodes NAME STATUS ROLES AGE VERSION node-1 NotReady master 3m44s v1.13.0 After reading some articles, I found out that we also need apply weave-kube plugin. I try to apply weave kube plugin, then the master status becomes ready :D ...