Kill zombie processes

Source

Find zombie process(es)

ps axo stat,ppid,pid,comm | grep -w defunct

Kill parent process(es)

sudo kill -9 <ppid>

Dealing with DomainErrors

sqrt(x), log(x), and pow(x) will throw DomainError exceptions with negative x, interrupting differential equation solvers. One can use these functions' counterparts in JuliaMath/NaNMath.jl, returning NaN instead of throwing a DomainError. Then, the solvers will reject the solution and retry with a smaller time step.

sqrt(-1.0) # throws DomainError

import NaNMath as nm
nm.sqrt(-1.0) # NaN

Stellaris console commands

Leaders

The Beholder

event paragon.1

Astrocreator Azaryn

event paragon.228

Keides, Scion of Vagros

event paragon.3115

Curator paragon

event leviathans.590

Gray

event graygoo.406

Skrand Sharpbeak

event paragon.3001
event paragon.3005

S875.1 Warform (need to select a science vessel)

effect random_owned_ship = { ship_event = { id = distar.156 } }

Caretaker AX7-b (need to select a science vessel)

effect random_owned_ship = { ship_event = { id = distar.245 } }

Relics

Add relics

add_relic all

Remove a relic, an example

effect remove_relic = r_severed_head

Buildings

Contained Ecosphere (resource)

event paragon.241

Class-4 Singularity (energy)

event ancrel.10009

Dimensional Fabricator (minerals)

event ancrel.10006

Force display format to PNG

In the VSCode plot panel and fredrikekre/Literate.jl notebooks, PNG images are generally smaller than SVG ones. To force plots to be shown as PNG images, you can use tkf/DisplayAs.jl to show objects in a chosen MIME type.

import DisplayAs.PNG
using Plots
plot(rand(6)) |> PNG

If you don't want to add another package dependency, you could directly use display().

using Plots
PNG(img) = display("image/png", img)
plot(rand(6)) |> PNG

Get the ODE Function from an ODE system

f = ODEFunction(sys) could be useful in plotting vector fields.

using ModelingToolkit
using DifferentialEquations
using Plots

# Independent (time) and dependent (state) variables (x and RHS)
@variables t x(t) RHS(t)

# Setting parameters in the modeling
@parameters τ

# Differential operator w.r.t. time
D = Differential(t)

# Equations in MTK use the tilde character (`~`) as equality.
# Every MTK system requires a name. The `@named` macro simply ensures that the symbolic name matches the name in the REPL.

@named fol_separate = ODESystem([
    RHS  ~ (1 - x)/τ,
    D(x) ~ RHS
])

sys = structural_simplify(fol_separate)

f = ODEFunction(sys)

f([0.0], [1.0], 0.0) # f(u, p, t) returns the value of D(x)

Get 2D indices from a linear index

Use CartesianIndices((nrow, ncol)), from this discourse post.

x = rand((7, 10))
CI = CartesianIndices((7, 10))
for i in 1:length(x)
    r = CI[i][1]
    c = CI[i][2]
    @assert x[i] == x[r, c]
end

Change YAML files on-the-fly

Editing YAML files on-the-fly using the yq tool.

For example, to disable jupyter book cell execution in GitHub actions, one can edit docs/_config.yml and set execute_notebooks to off.

- name: Disable code cell execution
  uses: mikefarah/yq@master
  with:
    cmd: yq -i '.execute.execute_notebooks = "off"' 'docs/_config.yml'

Check battery status

Open Windows Powershell with Administrator rights and run:

powercfg /batteryreport /output "C:\battery-report.html"

The report is at C:\battery-report.html.

Convert PPT to TIFF

How to export high resolution TIFF images from PowerPoint slides.

Advanced save options

File -> Save a copy -> More options -> Save as type: TIFF -> Tools -> compress pictures -> choose the DPI you want -> save.

Change default export settings

The export resolution is 96 dpi by default. You can edit the Windows registry to change it.

Save the following content as dpi-300.reg. Then, double click the dpi-300.reg to change the default exporting dpi to 300.

dpi-300.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\PowerPoint\Options]
"ExportBitmapResolution"=dword:0000012C

Note

For older MS office suite, please see the original article for the corresponding version number.

Sequence field in MS Word

The Seq (Sequence) field sequentially numbers chapters, tables, figures, and other items in a document.

To add a sequence field: Insert > Quick parts > Field > Select SEQ command.

Press F9 to update a field. Press Ctrl+ A (select all) then F9 to update all fields in the document.