Skip to content

Instantly share code, notes, and snippets.

@Choumingzhao
Choumingzhao / Git_note.md
Last active August 17, 2021 02:49
Git learning note

Notes for Git novice

  1. how to recover a file in previous commit The answer
  2. When a push failed because the others edit your remote repo The answer
@Choumingzhao
Choumingzhao / MATLAB_mul_compare.md
Last active September 4, 2017 12:31
MATLAB按元素相乘运算速度比较

众所周知,MATLAB长于矩阵运算,在使用矩阵进行运算时比普通的循环快得多,同时,不同的矩阵运算速度也会有不同。以下为实例:

>> clear all  
>> a = rand(100000000, 1);  
>> tic; a'*a; toc % 方法一,矩阵乘法  
时间已过 0.054834 秒。  
>> tic; a.*a; toc % 方法二,不包括求和  
时间已过 0.211555 秒。  
>> tic; sum(a.*a); toc % 方法二,包括求和  
时间已过 0.447394 秒。 
@Choumingzhao
Choumingzhao / 1.static_images_to_gif.md
Last active September 5, 2017 04:04
将多个静态图片转换为GIF文件并添加说明文字

有时候你需要用多个相同尺寸的静态图片转换为一个gif文件,这个时候你需要使用的Python库是imageio

使用$ pip install imageio可以安装。   使用static_images_to_gif.py 中的代码可以快速将具有相同命名特征的文件排序后组合成gif,你可以在理解其内容后作出相应更改才可运行。

同时新的问题出现了,如果我们想给每个图片添加不同的字体然后再做成gif呢? 这个时候还是要使用pillow。前面iamgeio已经安装了pillow。详见combine_multiple_images_and_add_caption.py。此处我们采用的方法新建一个空白的比原照片尺寸稍大的图片,添加文字之后在将原图粘贴上去。

参考:

  1. [Programmatically generate video or animated GIF in Python?][1]
  2. [Add caption to image using Pillow][2]
@Choumingzhao
Choumingzhao / WSL2_clash.md
Last active August 14, 2021 07:43
When WSL2 cannot connect to local `Clash for Windows`

There're many posts about open setttings for Clash for Windows. But following solution actually help with the problem.

This solve the problem by simply adding a new firewall rule, which is the most efficient soluton..

@Choumingzhao
Choumingzhao / Learn_C_CPP_for_newbee.md
Last active August 17, 2021 02:34
C/C++ newbee pitfalls

The GCC compile command is sensitive to the order of the arguments

$ gcc -o prog prog.c -lncurses and $gcc -lncurses -o prog prog.c behave differently. The latter one will fail according to the comment to his question and this entry in GCC doc.

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o. If bar.o refers to functions in ‘z’, those functions may not be loaded.

@Choumingzhao
Choumingzhao / Linux_notes_for_newbee.md
Last active August 17, 2021 02:44
Useful notes for Linux newbee

Useful Linux notes for novice

Linux Universal

Distribution specific(Debian/Ubuntu)

  1. Locate installed package/libraries by apt
    $ dpkg -L <package-name>
@Choumingzhao
Choumingzhao / pg_quick_notes.md
Last active October 20, 2021 01:27
快速上手使用PostgreSQL和PostGIS

PostgreSQL、PostGIS 中文速查手册

这是一个你可能需要的一个备忘手册,此手册方便你快速查询到你需要的常见功能。有时也有一些曾经被使用过的高级功能。如无特殊说明,此手册仅适用于 Linux 下(基本都可以愉快运行,一般也都可以在 Windows 下的 psql 命令窗运行,只是稍微麻烦一点),部分功能可能需要你的软件版本不能太低。

欢迎添加你认为有价值的备忘!

安装PostgreSQL 和 PostGIS

在Ubuntu上,使用Ubuntu-GIS的专门 ppa 来安装最新 GIS 软件,并保持更新。

@Choumingzhao
Choumingzhao / postgis_quick_notes.md
Last active September 26, 2021 09:47
PostGIS快速上手使用

PostGIS中文速查速用手册

这是PostgreSQL 和 PostGIS的PostGIS部分,主要讲PostgreSQL的空间相关功能的使用

空间相关配置

开启栅格支持

postgres 账户下,修改 ~/.profile,加入如下:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Choumingzhao
Choumingzhao / sudo_python.md
Last active March 1, 2024 08:49
Run current python with sudo

A shell function for easier running python script with sudo

#!/usr/bin/env bash
# Invoke current python as sudo
sudo_python() {
    local python_path
    python_path=$(which python)
    if [ -z "$python_path" ]; then
        echo "Python not found in PATH"