Skip to content

Instantly share code, notes, and snippets.

View unkcpz's full-sized avatar

Jusong Yu unkcpz

  • Swiss
View GitHub Profile
@unkcpz
unkcpz / aiida-with-pg-rmq-containers.md
Created December 2, 2021 12:57 — forked from ltalirz/aiida-with-pg-rmq-containers.md
AiiDA production setup with containerized Postgresql & Rabbitmq

Why?

As of May 4th, 2021, erlang is not available from macports for the ARM (Apple Silicon) platform. Docker containers make it super easy to install postgresql and rabbitmq.

The M1 chips have great parallelism, so I'd hope to be able to run docker without noticing the overhead too much. I could use conda as well, but docker provides the neat docker-compose.yaml that makes it possible to start up and shut down all the services required with a single command.

Task

@unkcpz
unkcpz / timeout_and_tick.go
Created April 3, 2019 01:34 — forked from ngauthier/timeout_and_tick.go
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@unkcpz
unkcpz / supermicro-ipmi-mac-address.md
Created July 21, 2018 07:12 — forked from DavidWittman/supermicro-ipmi-mac-address.md
Pull the LAN1/eth0 MAC address from SuperMicro IPMI

You can find the MAC address for LAN1/eth0 (not the BMC MAC) via the SuperMicro IPMI interface by running the following command:

$ ipmitool -U $IPMI_USER -P $IPMI_PASS -H $IPMI_HOST raw 0x30 0x21 | tail -c 18

The eth0 MAC address will be output in this format:

00 25 90 f0 be ef
@unkcpz
unkcpz / .Xdefaults
Created July 10, 2018 01:36 — forked from yevgenko/.Xdefaults
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight