Serhat Teker

Serhat Teker is the software engineer who wrote these articles.

I created this Tech Blog to help me remember the things I’ve learned in the past, so my future-self doesn’t have to re-learn them in the future.

               

Git Diff of Current and Previous Version of a File

2019-09-21 — One minute read
#git  #vsc  #vim 
We will use vim and git wrapper plugin for this. Installation First make sure you installed Tim Pope’s vim-figitive plugin before started. In the repo there is clear instruction but for vim-plug, add below line to your .vimrc and source it: " Plugins will be downloaded under the specified directory." Change it to direct to yourscall plug#begin('~/.local/share/nvim/plugged')" Add thisPlug 'tpope/vim-fugitive'call plug#end()Then run :PlugInstall. Using We will run :Gdiffsplit. From documentation:

How to Upgrade to Python 3.7 on Ubuntu 18.04/18.10

2019-09-14 (Edited: 2022-04-27) — 2 minutes read
#python  #linux  #ubuntu 
In this article, we upgrade to python 3.7 from python 3.6 and configure it as the default version of python.

Django - DB bulk_create()

2019-09-07 — 2 minutes read
#python  #django  #database  #queryset 
bulk_create() From Django doc: This method inserts the provided list of objects into the database in an efficient manner (generally only 1 query, no matter how many objects there are): So instead of inserting data into db one by one in an inefficient manner it is better to use this method. Method api detail: bulk_create(objs, batch_size=None, ignore_conflicts=False) Example: >>> MyModel.objects.bulk_create([ … MyModel(title='This is a test'), … MyModel(title='This is only an another test'), .

Django UserContextMixin

2019-08-31 — 2 minutes read
#python  #django 
If you want to get the currently logged-in user and use it—e.g at the top of every template, in class-based view it could be hard to achive. However there is an easy and pythonic/djangoic way to accomplish that: just use a Mixin. Actually Django framework consists of very wide range of Mixins such as SingleObjectMixin or TemplateResponseMixin. For more detail: Django Class-based Mixins. So now we can write our very own Mixin to do the job:

Python - Difference Between ‘is’ and ‘==’

2019-08-24 — One minute read
#python  #foundation 
In python the is operator compares if two variables point to the same object. The == operator checks the “values” of the variables are equal. #!/usr/bin/env python # -- coding: utf-8 -- a = [1, 2, 3] b = [1, 2, 3] c = a if (a == b): print("True") else: print("False") if (a is b): print("True") else: print("False") if (a == c): print("True") else: print("False") if (a is c): print("True") else: print("False") Or with more “pythonic” and clearer syntax: