snippets

LLM prompt

latex format

**Prompt:**

Convert the following mathematical expressions from backslash format to LaTeX using `$...$` for inline formulas and `$$...$$` for standalone equations.

**Text to Convert:**

1. `y = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`
2. `E = mc^2`
3. `\int_{a}^{b} x^2 dx`
4. `x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} and y = mx + c`
5. `\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}`

**Expected Conversion:**

1. $$y = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
2. $E = mc^2$
3. $$\int_{a}^{b} x^2 dx$$
4. $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ and $y = mx + c$
5. $$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$$

**Instructions:**

Use `$...$` for expressions within a line of text and `$$...$$` for centered equations.

---

This streamlined version focuses directly on the conversion task.

Bash

Work flow

ls column by index

Add sbatch in do.sh

Find how many works are running

Cancel homework from one id to another id

Find numbers of pattern in one file

Display all the content in many files

Find empty file of subdirectories

grep number

loop over some specific list

check disk space

delete many files

Tips

  • do not add space when assign value to some variable.

  • find . -type d -empty | grep -o '[0-9]\+' | tr '\n' ' ' | awk '{print "numbers=(" $0 ")"}'

Git

How to add some specific file

add tag

Python

Algorithm

  • interpolation on lg scale

  • check unique element

  • generate random seeds

  • get suitable chi2/dof

Ipython

  • %pylab [--no-import-all]

Healpy

  • plot with 0 pad

  • square mask

  • disc mask

  • strip mask

  • how to get colorbar of the plots

  • how to get colorbar of the plots (another way)

Numpy

  • np.where:numpy.where(condition, [x, y, ]/);for condition:Where True, yield x, otherwise yield y.

Fits files operation

  • check the header name of a fits file

  • check the info

  • check the data and its type(planck cls fits)

Matplotlib

colors

https://matplotlib.org/stable/gallery/color/named_colors.html#tableau-palette

markers

https://matplotlib.org/stable/api/markers_api.html

h5 files operation

  • open h5 files

  • get colomn name of h5 file

sav files operation

  • load sav files

Latex

  • plot in latex

Plots

  • some codes for subplots

CMB tasks

  • check maps

  • get map depth for noise level

  • multiply gaussian noise

  • convert inf to np.inf then to 0

  • rotate coordinate

  • get mask from variance map

Utils

  • import from other directory

  • work flow

  • absolute path

  • minimum import for test

  • logger

  • find files by python

  • print options

  • debugger

  • name variable

  • transfer input parameter names

  • save a plot to a directory in your home directory

  • generate and save seeds

Docs

tips

  • Argument passing sys.argv is a list in Python that contains the script name and any additional arguments passed to the script. When using the -c or -m options, sys.argv[0] is set to -c or the full name of the module, respectively. Any options found after -c or -m are not processed by the interpreter and are left in sys.argv for the command or module to handle.

  • raw strings:print(r'some string')

  • range() is not a list, but an object returns the successive items of hte desired sequence when you iterate over it. Called iterable

  • dir() lists all the function and variable definition

  • match statements

keywords argment

Special parameters

walrus operator

assign expression value to a variable

Looping Techniques

formatted string

save list and dict in a json file

namespace

namespace is a mapping from names to object. Most namespaces are implemented as Python dictionaries.

static method

a method belongs to a class rather than an instance of the class.(we don't need the self to be passed)

super method

dataclass

dataclass is a decorator available in Python 3.7 and later versions that can be used to automatically generate special methods for classes, such as the init, repr, and eq methods, based on class attributes. The primary purpose of data classes is to simplify the creation of classes that mostly serve as containers for data and require minimal behavior.

python directory structure

iterable and iterator

list, set, dict.items() are all iterable Iterating over an iterable: An iterable is an object that implements the iter() method, which returns an iterator. When you use a for loop (or other iteration construct) on an iterable, Python automatically calls iter() on the object to get an iterator, and then calls next() on the iterator to get the values one by one. Once all values have been retrieved and next() is called again, the iterator raises a StopIteration exception, which Python catches and handles by ending the loop.

ArchLinux

pacman

  • new server

Useful tools

For Shell

Zoxide

rust cd tools, zi command is very useful

eza

rust ls tools

fzf

fuzzy finder

toolong

A terminal application to view, tail, merge, and search log files (python)

history command

cd git directory

Last updated