These are the three core data types in python. Of course there are strings, int too. I'm listing this here as I often forget these: List Somewhat similar to tuple (see below) but changeable. Uses square brackets instead of parenthesis in tuple. 1>>> kirk = ["James Kirk", 34, "Captain", 2265] …
Read MoreUse enumerate to iterate to each list's element 1>>> # Pythonic Example 2>>> animals = ['cat', 'dog', 'moose'] 3>>> for i, animal in enumerate(animals): 4... print(i, animal) 5... 60 cat 71 dog 82 moose If the index is not important, use "_" in place of …
Read MoreSetup venv 1~$ python3 -m venv venv 2~$ source venv/bin/activate Install Django (If not yet installed, otherwise skip) 1~$ pip install django Create the skeleton of the site 1~$ django-admin startproject mysite . Server file structure of current directory would be as follows: 1manage.py 2mysite 3mysite/__init__.py …
Read MoreSometimes, you need to check the uptime of a Windows machine. Here's the Powershell command for that: 1PS C:\> systeminfo|find "System Boot Time" This was tested working under Windows 10 Pro and worth noting that it also works in the old cmd. For other methods, see this article.
Read MoreLinux systemcmd or init way of rebooting will not work in a Windows Subsystem for Linux or wsl-run Linux. You need to use the Powershell command below: 1wsl --shutdown For other methods, see this article.
Read MoreWhen troubleshooting, you sometimes need to check the contents of a docker image. 1docker run -it <name_of_image> sh Once you're in, you can inspect specific files and its content.
Read MoreSuggested Init Script The very basic variable you need to lookout for in go is the environment variable $GOPATH. In Unix/Linux-based systems it is by default in ~/go. My preference is to put it in a directory where my go code exists. So here's a short shell script I use: 1#!/bin/bash 2 3## Enforce calling …
Read MoreIn your preferred directory, initialize GOPATH using the short script in Suggested GoLang Init Script. Then, do the following steps: Install godoc 1~$ go install golang.org/x/tools/cmd/godoc@latest 2go: downloading golang.org/x/tools v0.1.7 3go: downloading golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e 4go: …
Read More1~$ mkdir greetings 2~$ cd greetings 3~$ go mod init example.com/greetings In a text editor, create greetings.go with the following content: 1package greetings 23import "fmt" 45// Hello returns a greeting for the named person. 6func Hello(name string) string { 7// Return a greeting that embeds the name in a …
Read MoreCopy tables to an _old as backup 1CREATE TABLE new_table AS 2TABLE existing_table; See details in https://www.postgresqltutorial.com/postgresql-copy-table/
Read More