RSS

Posts in 2020

  • PostgreSQL mini cookbook: aggregate query tricks

    Last Update: in PostgreSQL

    PostgreSQL mini cookbook: PostgreSQL aggregate query tricks, those tricks back to 2001 and still works today. 😉

    Sum a field You want to calculate the total number of payments per customer, staff. Solution Use SUM() and GROUP BY: SELECTa,b,sum(c)FROMtGROUPBYa,b;Example: …

    Read more

  • PostgreSQL mini cookbook: basic query tricks

    Last Update: in PostgreSQL

    PostgreSQL mini cookbook: PostgreSQL basic query tricks, those tricks back to 2001 and still works today. 😉

    Case insensitive searches You want to check equality or do a regular expression search but ignoring case Solution Either use lower() on the field and the value being compared or use the ILIKE or ˜˜* regular expression operators. Discussion If you …

    Read more

  • Python unicode string lowercase and caseless match

    in Python

    str.lower() and str.casefold()

    str.lower() and str.casefold() Starting with Python 3.0, strings are stored as Unicode. Python defined to two functions str.lower() and str.casefold() can be used to convert string to lowercase: str.lower() Return a copy of the string with all the …

    Read more

  • psql 101

    Last Update: in PostgreSQL

    psql is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results. Alternatively, input can be from a file.

    psql shell command List exist databases $ psql --list List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ------------------------+-------+----------+-------------+-------------+------------------- dvdrental | dbch | UTF8 …

    Read more

  • Azure function Did not find any initialized language workers

    Last Update: in Azure

    Azure function app random response 500 Internal error to client. log indicate Azure function: Did not find any initialized language workers.

    Symptom We deployed a very simple Azure function with nodejs runtime, on an Linux container. However after deployment, the service is not stable stable, it goes up and down, server random response 500 Internal error to client. From Azure’s log, …

    Read more

  • hugo-page-lastmod

    Last Update: in Hugo

    Use .GitInfo or .Page.Lastmod as last update date in hugo page

    Use .GitInfo or .Page.Lastmod Hugo have build-in support to get the last Git revision information for every content file. To enable Hugo get git commit info, first need change enableGitInfo to true in config.toml: Page.Lastmod is fetched from …

    Read more

  • Add git commit to docker image tag in Azure pipeline

    Last Update: in Azure

    Add git commit to docker image tag in Azure pipeline

    Problem I have Azure devops pipeline to build docker image from source. I want the docker image have the source code revision info like git commit hash. I tried to use Build.SourceVersion as a docker image tag, Build.SourceVersion : The latest …

    Read more

  • Pass var in Azure pipeline

    Last Update: in Azure

    Use variable to pass data in Azure devops pipelines

    I have an Azure devops pipeline and want to pass some data between different tasks. One way to do is use environment var. Variables give you a convenient way to get key bits of data into various parts of the pipeline. As the name suggests, the value …

    Read more

  • Azure WALinuxAgent Backdoor

    Last Update: in Azure

    WALinuxAgent is is Microsoft Azure Linux Agent with root access (backdoor?). Remove it if you do not use it.

    WALinuxAgent is Microsoft Azure Linux Agent with root access (backdoor?). It is pretty powerful to manage Linux on Azure. The source code is host at github Azure/WALinuxAgent . The Microsoft Azure Linux Agent (waagent) manages Linux provisioning and …

    Read more

  • python-cas Flask Example

    Last Update: in CAS

    An example project to demo how to integrate python-cas into a Flask app.

    python-cas is Python CAS (Central Authentication Server) client library support CAS 1.0/2.0/3.0. It was initially split from django-cas-ng to support any Python app to easily implement a CAS client. This post is an example project to demo how to …

    Read more