linux:scribble
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux:scribble [2013/08/29 01:57] – [printf stdint.h types] add stdio.h as well ;) stybla | linux:scribble [2022/07/06 17:27] (current) – setfont stybla | ||
---|---|---|---|
Line 97: | Line 97: | ||
Some reference at [[https:// | Some reference at [[https:// | ||
+ | |||
+ | ==== shifts ==== | ||
+ | |||
+ | Not exactly as I expected, but remember to shift from N to M as shown below otherwise you'll end up with completely different number. | ||
+ | I'm wondering, though, whether this is MS case, because LS case seems to be exactly M to N. | ||
+ | |||
+ | < | ||
+ | uint16_t number = 305; | ||
+ | uint8_t data[2]; | ||
+ | |||
+ | data[0] = number >> 8; | ||
+ | data[1] = number >> 0; | ||
+ | </ | ||
+ | |||
+ | ==== Exercises ===== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ===== Change keyboard layout in console ===== | ||
+ | |||
+ | '' | ||
+ | |||
+ | Don't forget about '' | ||
===== Cisco IOS notes ===== | ===== Cisco IOS notes ===== | ||
Line 140: | Line 163: | ||
</ | </ | ||
+ | ===== ffmpeg ===== | ||
+ | |||
+ | Note that these were scraped from various sites and forums and I take no credit. | ||
+ | |||
+ | ==== Fix colour profile/ | ||
+ | |||
+ | BT709(and nothing else) is supported by some TVs. Therefore one has to reencode video with BT709 colour profile. Note that this command can be used to extract(unpack) MKV(Matroska video file), although just I/O without reencoding is faster, and re-encodes audio to ACC 44.1kHz 128kbit bit rate! | ||
+ | |||
+ | < | ||
+ | ffmpeg \ | ||
+ | -i input_file.suffix \ | ||
+ | -color_primaries 1 \ | ||
+ | -color_trc 1 \ | ||
+ | -colorspace 1 \ | ||
+ | -vf scale=out_color_matrix=bt709 \ | ||
+ | -color_primaries bt709 \ | ||
+ | -color_trc bt709 \ | ||
+ | -colorspace bt709 \ | ||
+ | # RE-ENCODE AUDIO TO AAC - unnecessary, | ||
+ | -acodec aac \ | ||
+ | -strict -2 \ | ||
+ | -ab 128K \ | ||
+ | -ar 44100 \ | ||
+ | # Remove metadata - unnecessary, | ||
+ | -map_metadata -1 \ | ||
+ | output_file.suffix | ||
+ | </ | ||
+ | |||
+ | ==== Convert BT601 to BT709 ==== | ||
+ | |||
+ | Just in case ... | ||
+ | |||
+ | < | ||
+ | ffmpeg -i input.mp4 -vf " | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Git ===== | ||
+ | |||
+ | 99.9999% scraped from Intranets. | ||
+ | |||
+ | ==== New branch from tag ==== | ||
+ | |||
+ | '' | ||
+ | |||
+ | ==== Fetch remote branch ==== | ||
+ | |||
+ | '' | ||
+ | |||
+ | |||
+ | ===== Go ===== | ||
+ | |||
+ | Aka golang | ||
+ | |||
+ | ==== JSON ==== | ||
+ | |||
+ | Remember that struct attributes/ | ||
+ | |||
+ | <file golang json_test.go> | ||
+ | package main | ||
+ | |||
+ | import ( | ||
+ | " | ||
+ | " | ||
+ | ) | ||
+ | |||
+ | // Attributes, eg. Name, must begin with capital letter/ | ||
+ | // Also, JSON mapping is shown. | ||
+ | type Message struct { | ||
+ | Name string `json:" | ||
+ | Body string `json:" | ||
+ | Time int64 `json:" | ||
+ | } | ||
+ | |||
+ | func main() { | ||
+ | m := Message{" | ||
+ | b, err := json.Marshal(m) | ||
+ | fmt.Println(err) | ||
+ | fmt.Println(string(b)) | ||
+ | } | ||
+ | </ | ||
===== iconv ===== | ===== iconv ===== | ||
Line 147: | Line 251: | ||
< | < | ||
iconv --from-code=cp1250 --to-code=UNICODE -o $out_file $in_file | iconv --from-code=cp1250 --to-code=UNICODE -o $out_file $in_file | ||
+ | </ | ||
+ | ===== Jenkins ===== | ||
+ | |||
+ | < | ||
+ | Jenkins.instance.getItemByFullName(" | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Thread.getAllStackTraces().keySet().each() { | ||
+ | if (it.name.contains(' | ||
+ | println " | ||
+ | it.stop() | ||
+ | } | ||
+ | } | ||
</ | </ | ||
Line 196: | Line 314: | ||
multilibs from time to time), so that might be the issue behind error above. But libvirt | multilibs from time to time), so that might be the issue behind error above. But libvirt | ||
is long gone, replaced and forgotten now. | is long gone, replaced and forgotten now. | ||
+ | |||
+ | ===== Move LVM on LUKS to new HDD ===== | ||
+ | |||
+ | Unfortunately, | ||
+ | |||
+ | > Ideally, you initialize the new LUKS partition as a LVM PV, add it to your volume group with: | ||
+ | |||
+ | < | ||
+ | |||
+ | > Then use the LVM pvmove command to migrate your data to it like so: | ||
+ | |||
+ | < | ||
+ | |||
+ | > When the data migration is done, be sure to remove the old LUKS partition from the volume group with: | ||
+ | |||
+ | < | ||
+ | |||
+ | > This can all be done with the system online, although it is marginally safer and probably significantly faster to do it from a LiveCD like SystemRescueCD. Also, if you have a new enough version of LVM, you probably want to use the --atomic option for pvmove, that will ensure that you don't end up with some LV's on the new device and some on the old device if the pvmove command fails. | ||
+ | |||
+ | I wish I've documented all the steps I took to move LUKS between HDDs since it might come handy. Also, it's not the first time I did that. Damn! | ||
+ | |||
+ | ===== loop-AES ===== | ||
+ | |||
+ | ==== Decrypt loopAES encrypted partition ===== | ||
+ | |||
+ | < | ||
+ | gpg --decrypt private.gpg | \ | ||
+ | cryptsetup loopaesOpen \ | ||
+ | / | ||
+ | newvolumename \ | ||
+ | --key-file=- \ | ||
+ | --key-size 128 \ | ||
+ | --hash sha256 | ||
+ | </ | ||
+ | |||
+ | Note that this isn't for ''/ | ||
+ | |||
+ | ==== Resize encrypted LVM backed partition ===== | ||
+ | |||
+ | < | ||
+ | root@foo:# umount /encrypted | ||
+ | |||
+ | root@foo:# lvextend -L +1T / | ||
+ | |||
+ | root@foo:# losetup -F /dev/loop3 | ||
+ | Password: | ||
+ | |||
+ | root@foo:# fsck -f /dev/loop3 | ||
+ | fsck from util-linux 2.22.1 | ||
+ | e2fsck 1.42.6 (21-Sep-2012) | ||
+ | Pass 1: Checking inodes, blocks, and sizes | ||
+ | Pass 2: Checking directory structure | ||
+ | Pass 3: Checking directory connectivity | ||
+ | Pass 4: Checking reference counts | ||
+ | Pass 5: Checking group summary information | ||
+ | /dev/loop3: 1065215/ | ||
+ | |||
+ | root@foo:# resize2fs / | ||
+ | resize2fs 1.42.6 (21-Sep-2012) | ||
+ | Resizing the filesystem on /dev/loop3 to 506573824 (4k) blocks. | ||
+ | The filesystem on /dev/loop3 is now 506573824 blocks long. | ||
+ | |||
+ | root@foo:# mount /encrypted | ||
+ | </ | ||
+ | |||
+ | Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/ | ||
+ | |||
+ | ===== MySQL ===== | ||
+ | |||
+ | ==== Convert database to UTF-8 encoding ==== | ||
+ | |||
+ | Originally found at [[https:// | ||
+ | |||
+ | Run mysql and check the encoding: | ||
+ | |||
+ | < | ||
+ | SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = " | ||
+ | SELECT CCSA.character_set_name FROM information_schema.`TABLES` T, | ||
+ | </ | ||
+ | |||
+ | Change encoding of tables: | ||
+ | |||
+ | < | ||
+ | cat > ~/.my.cnf <<EOF | ||
+ | [client] | ||
+ | user=USER | ||
+ | password=PASSWORD | ||
+ | EOF | ||
+ | mysql --database=DBNAME -B -N -e "SHOW TABLES" | ||
+ | </ | ||
+ | |||
+ | Change encoding of DB itself: | ||
+ | < | ||
+ | ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci; | ||
+ | </ | ||
+ | |||
+ | Remove '' | ||
+ | |||
+ | |||
+ | ===== OpenOffice/ | ||
+ | |||
+ | ==== Convert documents to PDF from command line ==== | ||
+ | |||
+ | Found at [[http:// | ||
+ | like UTF-8 characters in file names, resp. non-ASCI chars(I' | ||
+ | full path to document you want to convert. On the contrary, actually. | ||
+ | |||
+ | < | ||
+ | libreoffice --headless --invisible --convert-to pdf --outdir ~/dir ~/ | ||
+ | </ | ||
===== Open Sound System (OSS) - license expired ===== | ===== Open Sound System (OSS) - license expired ===== | ||
Line 269: | Line 497: | ||
find out which ones though. Just make sure you have everything there. If you have two, or more, PXE servers, | find out which ones though. Just make sure you have everything there. If you have two, or more, PXE servers, | ||
then make sure they' | then make sure they' | ||
+ | |||
+ | ===== Puppet ===== | ||
+ | |||
+ | ==== Generate graph/PNG from dot file ==== | ||
+ | |||
+ | < | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== List all facts on Node ==== | ||
+ | |||
+ | < | ||
+ | facter -p | ||
+ | </ | ||
+ | |||
+ | ==== Test puppet on Node ==== | ||
+ | |||
+ | < | ||
+ | puppet agent --test < | ||
+ | </ | ||
+ | |||
+ | ==== Treatchery and trickery ==== | ||
+ | |||
+ | Let's say you write something like this: | ||
+ | |||
+ | < | ||
+ | class foo { | ||
+ | package { ' | ||
+ | service { ' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Now, if you've thought these are just abstracts and you're going to work with them later, you were wrong and might be unpleasantly surprised later. | ||
+ | What it means is: //Puppet, be a good chap, and install apache2 for me and make sure it's up and running.// Yep, you're reading that right. | ||
+ | Obvious, you say? Well, not really, it isn't. If I declare something like this I expect nothing to happen because I didn't say what should' | ||
+ | Obvious, now, is there are some defaults that apply and Puppet will act whether you like it or not. | ||
+ | |||
+ | Oh, and btw, it seems like '' | ||
+ | |||
+ | < | ||
+ | Package[' | ||
+ | ensure => ' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== "no certificate found and waitforcert is disabled" | ||
+ | |||
+ | < | ||
+ | # On client | ||
+ | puppet cert clean | ||
+ | service puppet stop | ||
+ | rm -rf / | ||
+ | # and get a new SSL cert - d'oh! | ||
+ | </ | ||
linux/scribble.1377759433.txt.gz · Last modified: 2013/08/29 01:57 by stybla