Skip to content

Instantly share code, notes, and snippets.

@cvnb
cvnb / read-block-from-filesystem-and-disk.md
Created May 22, 2018 02:43 — forked from szaydel/read-block-from-filesystem-and-disk.md
[ZDB - ZFS debugger tool] Various snippets for working with zdb, the zfs debugger #tags: zdb, zfs, debugger, zfs-debug, bsros, illumos

The following steps allow one to either read data from L0 block directly or after converting DVA to physical device address, read data from device instead with dd.

We'll pretend that we have pool p03 with dataset path: p03/global/data0. We have a single file on this data0 dataset, called words. It is basically a list of words, the good'ol unix dictionary.

  1. Get information with zdb about dataset, we want to get list of indirect blocks.
# zdb -AA -ddddd p03/global/data0
...snip...
    Object  lvl   iblk   dblk  dsize  lsize   %full  type
        14    2   128K   128K  19.8M  19.8M  100.00  ZFS plain file
@cvnb
cvnb / RegExp.scala
Created December 6, 2017 02:40 — forked from yellowflash/RegExp.scala
Regex Engine which runs in `O(mn)` Glushkov automaton
sealed trait RegExp {
def isFinal:Boolean
def acceptsEmpty:Boolean
def shift(prev:Boolean, character:Char):RegExp
def matches(str:String) =
if(str.isEmpty) this.acceptsEmpty
else str.foldLeft(this.shift(true, str.head))(_.shift(false,_)).isFinal
}
object Epsilon extends RegExp {
@cvnb
cvnb / ups-kill.sh
Created November 22, 2017 18:22
Power off UPS when computer is halting
#!/bin/bash
case $1 in
halt | poweroff)
# See if this is a powerfail situation.
if [ -f /etc/apcupsd/powerfail ]; then
echo
echo "ACPUPSD will now power off the UPS"
echo
/etc/apcupsd/apccontrol killpower
@cvnb
cvnb / PKGBUILD
Created June 27, 2017 05:38
PKGBUILD for arangodb 3.1.23
# Maintainer: Mike Williamson <mike at korora dot ca>
pkgname=arangodb
pkgver=3.1.23
pkgrel=1
pkgdesc="A multi-model NoSQL database, combining key-value, document and graph data models."
arch=("i686" "x86_64")
url="https://www.arangodb.com/"
license=('APACHE')
depends=('openssl' 'systemd' 'curl' 'zlib' 'jemalloc')
@cvnb
cvnb / gist:eb1db60b017b1b2b5da2e23b1688bb4f
Last active March 20, 2017 03:30 — forked from danstuken/gist:3625841
Batch Convert XCF to JPEG in GIMP
(define (script-fu-xcf2jpg-batch xcfDirectory inQuality)
(let* ((xcfList (cadr (file-glob (string-append xcfDirectory "/*.xcf") 1))))
(while (not (null? xcfList) )
(let* ((xcfFilename (car xcfList))
(jpgFilename (string-append (substring xcfFilename 0 (- (string-length xcfFilename) 4) ) ".jpg"))
(xcfImage (car (gimp-file-load RUN-NONINTERACTIVE xcfFilename xcfFilename)))
(xcfDrawable (car (gimp-image-flatten xcfImage))) )
(file-jpeg-save RUN-NONINTERACTIVE xcfImage xcfDrawable jpgFilename jpgFilename
inQuality 0.0 0 0 "" 0 1 0 2)
(gimp-image-delete xcfImage)
@cvnb
cvnb / gist:5e524e33ce2b83b23dae1daf9c08698c
Created March 20, 2017 03:26 — forked from danstuken/gist:3625841
Batch Convert XCF to JPEG in GIMP
(define (script-fu-xcf2jpg-batch xcfDirectory inQuality)
(let* ((xcfList (cadr (file-glob (string-append xcfDirectory "/*.xcf") 1))))
(while (not (null? xcfList) )
(let* ((xcfFilename (car xcfList))
(jpgFilename (string-append (substring xcfFilename 0 (- (string-length xcfFilename) 4) ) ".jpg"))
(xcfImage (car (gimp-file-load RUN-NONINTERACTIVE xcfFilename xcfFilename)))
(xcfDrawable (car (gimp-image-flatten xcfImage))) )
(file-jpeg-save RUN-NONINTERACTIVE xcfImage xcfDrawable jpgFilename jpgFilename
inQuality 0.0 0 0 "" 0 1 0 2)
)