Project

General

Profile

Miscellaneous » History » Version 22

Anonymous, 06/22/2024 10:07 AM
adding instructions

1 1
h1. Miscellaneous
2
3 22
h2. Patch Youtube App using Revanced Manager (6/22/2024)
4
5
h3. Install Steps
6
7
* Delete Revanced app, Micro G, Revanced manager prior installation any of mentioned apps.
8
* Download *but not install* following:
9
** Micro G - https://github.com/ReVanced/GmsCore/releases/tag/v0.3.1.3.240913
10
** Revanced Manager - https://revanced.app/patches?s=Mic
11
** YT App version 19.16.39 (must be this version; revanced manager will warn if not): https://www.apkmirror.com/apk/google-inc/youtube/youtube-19-16-39-release/youtube-19-16-39-android-apk-download/
12
* Install Micro G.
13
* Next install Revanced Manager
14
* Open Revanced manager
15
** Go to Patches
16
** Select an app
17
** Bottom right corner choose Storage
18
** Find YT APK you downloaded, select patch on the bottom right corner
19
* Wait for patch and compile to finish, then choose install app
20
* Open it, check if its Vanced, restart the phone.
21
* If you have stock YT app, uninstall updates and disable it
22
23
Source: https://www.reddit.com/r/revancedapp/comments/1bq92r7/me_rn_trying_to_patch_youtube_revanced/
24
25 19
h2. Combine find and GNU parallel
26
27
Example:
28
<pre>
29
$ find . -name '*.jpg' | parallel convert -geometry 120 {} {.}_thumb.jpg
30 21
$ find . -name '*.png' | parallel --eta convert '{}' -quality 90 '{.}.jpg'
31
$ find . -name '*.png' -delete
32 19
</pre>
33
Note @{.}@ is the filename without the @.jpg@ portion.
34
35
* See: https://www.gnu.org/software/parallel/parallel_examples.html#example-compute-intensive-jobs-and-substitution
36
37 18
h2. Setup ttyd
38
39
* Download @ttyd@ and put it in @/opt/local/bin/ttyd@:
40
** https://github.com/tsl0922/ttyd/releases
41
* Create systemd service file @/etc/systemd/system/ttyd.service@: 
42
<pre>
43
[Unit]                                                                                                                                                                                           
44
Description=TTYD
45
After=syslog.target
46
After=network.target
47
 
48
[Service]
49
ExecStart=/opt/local/bin/ttyd -W -p 9772 login
50
Type=simple
51
Restart=always
52
User=root
53
Group=root
54
 
55
[Install]
56
WantedBy=multi-user.target
57
</pre>
58
** Start and enable service:
59
<pre>
60
$ sudo systemctl start ttyd && sudo systemctl enable ttyd
61
</pre>
62
* Setup apache configuration (add to existing)
63
<pre>
64
        ProxyRequests Off
65
        ProxyPreserveHost On
66
        RewriteEngine on
67
        RewriteCond %{HTTP:Upgrade} websocket [NC]
68
        RewriteCond %{HTTP:Connection} upgrade [NC]
69
        RewriteRule /terminal/?(.*) "ws://localhost:9772/$1" [P,L]
70
        ProxyPass /terminal http://localhost:9772/
71
        ProxyPassReverse /terminal http://localhost:9772/
72
</pre>
73
** Enable necessary apache modules:
74
<pre>
75
$ a2enmod proxy proxy_http proxy_wstunnel mod_rewrite
76
</pre>
77
78
79 17
h2. Increase tmux scrollback
80
81
<pre>
82
$ cd 
83
$ echo "set -g history-limit 9999999" >> ~/.tmux.conf
84
</pre>
85
86 16
h2. Setup VNC
87 15
88
On the server side:
89
# Install @x11vnc@:
90
<pre>
91
$ sudo apt install x11vnc net-tools
92
</pre>
93
# Set VNC password:
94
<pre>
95
$ x11vnc -storepasswd
96
</pre>
97
# Start VNC service from command line:
98
<pre>
99
$ sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/dsorber/.vnc/passwd -rfbport 5900 -shared
100
</pre>
101
# To start at boot using systemd service create: @/etc/systemd/system/x11vnc.service@:
102
<pre>
103
[Unit]
104
Description=x11vnc remote desktop server
105
After=multi-user.target
106
107
[Service]
108
Type=simple
109
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/dsorber/.vnc/passwd -rfbport 5900 -shared
110
111
Restart=on-failure
112
113
[Install]
114
WantedBy=multi-user.target
115
</pre>
116
117
On the client side:
118
# Install @remmina@:
119
<pre>
120
$ sudo apt install remmina
121
</pre>
122
# Open @remmina@, select "VNC", and type in the server's IP address.
123
124
* Source: https://forums.linuxmint.com/viewtopic.php?t=369092
125
126 14
h2. sshuttle
127 15
128
Poor man's VPN:
129 14
130
<pre>
131
$ sshuttle --dns -NHr dsorber@phalanx.homelinuxserver.org:3268  192.168.0.0/16
132
</pre>
133
134 13
h2. Batch Convert PNG to JPG
135
136
NOTE: @convert@ comes from ImageMagick
137
<pre>
138
& ls -1 *.png | parallel --eta convert '{}' -quality 90 '{.}.jpg'
139
</pre>
140
141 12
h2. Crop Video with ffmpeg
142
143
<pre>
144
$ ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4
145
</pre>
146
147
* @out_w@ is the width of the output rectangle
148
* @out_h@ is the height of the output rectangle
149
* @x@ and @y@ specify the top left corner of the output rectangle (coordinates start at (0,0) in the top left corner of the input) 
150
151
Test using @ffplay@:
152
<pre>
153
$ ffplay -i input -vf "crop=out_w:out_h:x:y"
154
</pre>
155
156 10
h2. Build Custom Windows ISOs
157
158
* https://uupdump.net/
159 11
* https://forums.mydigitallife.net/threads/kms_vl_all-smart-activation-script.79535/
160 10
161 9
h2. Script to Convert Local manpages to html
162
163
Note use @zcat@ if the manpages are compressed:
164
165
<pre>
166
#!/bin/bash
167
168
mkdir -p html
169
for file in *; do
170
        if [ -f $file ] && [ "${file: -3}" != ".sh" ]; then
171
                echo $file
172
                #echo "${file%.*}"
173
                pandoc --from man --to html < $file > html/${file%.*}.html
174
        fi
175
done
176
</pre>
177
178 6
h2. Display Total rsync Progress
179
180
<pre>
181 7
$ rsync -a --no-i-r --info=progress2 /path/to/src /path/to/dest/
182 6
</pre>
183
184
NOTE: @-v@ does not work with @--info=progress2@
185
186
Source: https://serverfault.com/a/441724/472586
187
188 5
h2. Slice Video File 
189
190
<pre>
191
$ ffmpeg -ss 00:01:00 -to 00:02:00  -i input.mp4 -c copy output.mp4
192
</pre>
193
194
Explanation of the command:
195
196
* -i: This specifies the input file. In that case, it is (input.mp4).
197
* -ss: Used with -i, this seeks in the input file (input.mp4) to position.
198
* 00:01:00: This is the time your trimmed video will start with.
199
* -to: This specifies duration from start (00:01:40) to end (00:02:12).
200
* 00:02:00: This is the time your trimmed video will end with.
201
* -c copy: This is an option to trim via stream copy. (NB: Very fast)
202
203 4
h2. Add new drive SW RAID5
204
205
# Format drive if needed (see below for steps).
206
# Add new drive to SW RAID:
207
<pre>
208
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1
209
</pre>
210
# Grow array:
211
<pre>
212
$ sudo mdadm --grow --raid-devices=4 /dev/md0
213
</pre>
214
215
h2. Replace failed SW RAID drive
216
217
# If drive is brand new be sure to create a partition on it:
218
<pre>
219
sorber@file2:~$ sudo parted /dev/sdg
220
GNU Parted 3.3
221
Using /dev/sdg
222
Welcome to GNU Parted! Type 'help' to view a list of commands.
223
(parted) mklabel gpt
224
(parted) mkpart primary 2048s 100%                                        
225
(parted) print                                                            
226
Model: ATA ST2000DM008-2FR1 (scsi)
227
Disk /dev/sdg: 2000GB
228
Sector size (logical/physical): 512B/4096B
229
Partition Table: gpt
230
Disk Flags: 
231
232
Number  Start   End     Size    File system  Name     Flags
233
 1      1049kB  2000GB  2000GB               primary
234
235
(parted) quit
236
</pre>
237
# If needed, mark bad drive as failed:
238
<pre>
239
$ sudo mdadm --manage /dev/md0 --fail /dev/sdd
240
</pre>
241
# Add new drive to replace failed:
242
<pre>
243
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1 /dev/sdg1
244
</pre>
245
# Improve rebuild speed slightly:
246
<pre>
247
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_min"
248
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_max"
249
</pre>
250
# Monitor rebuild:
251
<pre>
252
$ watch -n1 cat /proc/mdstat 
253
</pre>
254
255
h2. Get detailed drive information
256
257
<pre>
258
$ udevadm info --query=all --name=/dev/sda
259
</pre>
260
261 1
h2. Split flac with cue
262
263
<pre>
264
$ sudo apt install cuetools shntool
265
266
$ shnsplit -f file.cue -t %n-%t -o flac file.flac
267
</pre>
268
269
h2. Fix Chrome Display Glitches
270
271
Somewhere around Chrome 86 display glitches started happening on wake. Here is how to fix:
272
273 3
Enabling @enable-vulkan@ in @chrome://flags@ then restarting the browser fixed it. If that does not work, you can also try enabling `ignore-gpu-blacklist` as well.
274 1
275
h2. Setup SSH Public Key
276
277
# On host machine generate a key pair. This key can be reused for multiple remote machines so it's not really necessary to change the name unless multiple keys are generated, which is also not really needed.
278
<pre>
279
$ ssh-keygen -t rsa
280
</pre>
281 3
 *NOTE:* for NetBeans to use/recognize the ssh key you must use the old PEM format:
282 1
<pre>
283
$ ssh-keygen -m PEM -t rsa
284
</pre>
285
# Now use `ssh-copy-id` to copy the key to the remote machine (for example):
286
<pre>
287
$ ssh-copy-id -i ~/.ssh/phalanx_rsa.pub dsorber@phalanx
288
</pre>
289
290
h2. Read Windows Product Key from ACPI Firmware
291
292
Boot into Linux and run:
293
294
<pre>
295
$ sudo strings /sys/firmware/acpi/tables/MSDM
296
</pre>
297
298
h2. Windows 10 Install and SysPrep Instructions
299
300
Very good instructions: https://theitbros.com/sysprep-windows-10-machine-guide/
301
302
303
h2. Search and Replace on Binary Files
304
305
A good hex editor can do search and replace on binary files but sometimes that's not practical:
306
307
* BBE - https://sourceforge.net/projects/bbe-/
308
 BBE is a binary editor with SED-like syntax:
309
<pre>
310
$ bbe -e 's/\x0a\x0d\x0a/\x0d\x0a/' infile > outfile
311
</pre>
312
* binwalk - https://github.com/ReFirmLabs/binwalk
313
 binwalk can search for hex strings (and do many other things)
314
<pre>
315
$ binwalk -R "\x0a\x0d\x0a" infile
316
317
WARNING: Signature '0    string    \x0a\x0d\x0a    Raw signature (\x0a\x0d\x0a)' is a self-overlapping signature!
318
319
DECIMAL       HEXADECIMAL     DESCRIPTION
320
--------------------------------------------------------------------------------
321
242           0xF2            Raw signature (\x0a\x0d\x0a)
322
412           0x19C           Raw signature (\x0a\x0d\x0a)
323
580           0x244           Raw signature (\x0a\x0d\x0a)
324
749           0x2ED           Raw signature (\x0a\x0d\x0a)
325
. . .
326
</pre>
327
328
h2. Wake-on-LAN WOL
329
330
Must be enabled on interface; need MAC
331
<pre>
332
$ sudo apt install etherwake
333
$ sudo etherwake <target MAC> -i <outgoing interface>
334
335
$ sudo etherwake b4:2e:99:a5:1e:f0 -i enp30s0
336
</pre>
337
338
h2. Allocator Shim
339
340
From Chromium, this is really interesting
341
* https://chromium.googlesource.com/chromium/src/base/+/master/allocator/README.md
342
343
However it is not clear how to use it outside of Chromium.
344
345
h2. Update Geany
346
347
# Install prereq packages (this obviously only needs to be done once):
348
<pre>
349
$ sudo apt install libgtk-3-dev libgtkspell-dev libgtkspell3-3-dev
350
</pre>
351
# Set compile flags:
352
<pre>
353
$ export CFLAGS="-O3 -march=native" 
354
$ export CXXFLAGS=$CFLAGS
355
</pre>
356
# Build geany and set to install in /opt so it won't collide with the packaged version:
357
<pre>
358
$ tar xf geany-1.30.tar.bz2
359
$ cd geany-1.30/
360
$ ./configure --prefix=/opt/local --enable-gtk3
361
$ make -j20
362
$ sudo make install
363
</pre>
364
# Set PKG_CONFIG_PATH environment variable so we can build the plugins.
365
<pre>
366
$ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/
367
</pre>
368
# Build geany-plugins:
369
<pre>
370
$ tar xf geany-plugins-1.30.tar.bz2 
371
$ cd geany-plugins-1.30/
372
$ ./configure --prefix=/opt/local --enable-gtk3
373
$ make -j20
374
$ sudo make install
375
</pre>
376
377
h2. Find and replace across multiple files
378
379
<pre>
380
$ find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g'
381
</pre>
382
383
h2. Useful IPMI commands
384
385
386
Power measurement on the SuperMicro (probably won't work on Dell chassis as they have some proprietary version of ipmi):
387
388
<pre>
389
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.136.108 dcmi power reading
390
</pre>
391
392
Check power status (i.e. on/off) of chassis:
393
<pre>
394
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power status
395
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power off
396
</pre>
397
398
Get IPMI IP address (look for "IP Address"):
399
<pre>
400
sudo ipmitool lan print 
401
</pre>
402
403
h2. Full sshfs Connect Command
404
405
<pre>
406
sudo sshfs -o idmap=user -o uid=$(id -u) -o gid=$(id -g) -o allow_other -o follow_symlinks ryftuser@sm-X11DGQ:/home/ryftuser /mnt/sm-X11DGQ/
407
</pre>
408
409
h2. Side-by-side Color Diff
410
411
<pre>
412
$ sudo apt-get install colordiff
413
$ colordiff -y --suppress-common-lines data.txt /ryftone/data.txt
414
</pre>
415
416
h2. x86 ABI
417
418
* https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
419
420
h2. clang-format and clang-tidy
421
422
* http://www.labri.fr/perso/fleury/posts/programming/using-clang-tidy-and-clang-format.html
423
424
h2. Shared Library and Related Resources
425
426
* http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
427
* https://blog.qt.io/blog/2011/10/28/rpath-and-runpath/
428
* http://www.bnikolic.co.uk/blog/linux-ld-debug.html
429
* http://insanecoding.blogspot.com/2012/07/creating-portable-linux-binaries.html
430
* https://stackoverflow.com/questions/4156055/static-linking-only-some-libraries
431
432
h2. Ubuntu: List Grub Entries
433
434
<pre>
435
gawk  'BEGIN {                                                                                                                       
436
  l=0                                                                                                                                
437
  menuindex= 0                                                                                                                       
438
  stack[t=0] = 0                                                                                                                     
439
}                                                                                                                                    
440
441
function push(x) { stack[t++] = x }                                                                                                  
442
443
function pop() { if (t > 0) { return stack[--t] } else { return "" }  }                                                              
444
445
{                                                                                                                                    
446
447
if( $0 ~ /.*menu.*{.*/ )                                                                                                             
448
{                                                                                                                                    
449
  push( $0 )                                                                                                                         
450
  l++;                                                                                                                               
451
452
} else if( $0 ~ /.*{.*/ )                                                                                                            
453
{                                                                                                                                    
454
  push( $0 )                                                                                                                         
455
456
} else if( $0 ~ /.*}.*/ )                                                                                                            
457
{                                                                                                                                    
458
  X = pop()                                                                                                                          
459
  if( X ~ /.*menu.*{.*/ )                                                                                                            
460
  {                                                                                                                                  
461
     l--;                                                                                                                            
462
     match( X, /^[^'\'']*'\''([^'\'']*)'\''.*$/, arr )                                                                               
463
464
     if( l == 0 )                                                                                                                    
465
     {                                                                                                                               
466
       print menuindex ": " arr[1]                                                                                                   
467
       menuindex++                                                                                                                   
468
       submenu=0                                                                                                                     
469
     } else                                                                                                                          
470
     {                                                                                                                               
471
       print "  " (menuindex-1) ">" submenu " " arr[1]                                                                               
472
       submenu++                                                                                                                     
473
     }                                                                                                                               
474
  }                                                                                                                                  
475
}                                                                                                                                    
476
477
}' /boot/grub/grub.cfg
478
</pre>
479
480
* https://askubuntu.com/a/941993/392271
481
482
483
h2.GCC Disable Unused Variable Warnings
484
485
<pre>
486
#pragma GCC diagnostic push
487
#pragma GCC diagnostic ignored "-Wunused-variable"
488
( your problematic library includes )
489
#pragma GCC diagnostic pop
490
</pre>
491
492
See: https://stackoverflow.com/a/22708539/73878
493
494
h2. Fix Steam after NVidia driver update
495
496
Since this has now bitten me twice... Steam requires the 32 bit version of the GL library.
497
498
<pre>
499
$ sudo apt install libnvidia-gl-418:i386
500
</pre>
501
502
h2. Restart Cinnamon from TTY
503
504
# Cinnamon freezes
505
# Switch tty. I usually go to tty6, `Ctrl+Alt+F6`
506
# If you need to login first, do so.
507
# Type `w` (yes, just the letter) and press enter. This commands does a lot of different things, but you need it to figure out the number of the display you are using. The display number is in the column FROM. Mine is `:0` (yes, including the colon).
508
# Assuming that cinnamon is already dead (which you would notice by the windows lacking titles and that you can't move different windows around, and perhaps even not being able to use the keyboard), you type `export DISPLAY=:0; cinnamon &`, and don't forget the colon. I add the ampersand (&) only not to keep that tty busy.
509
510
Sauce: https://askubuntu.com/a/198935/392271
511
512
h2. Ubuntu Set Specific Kernel to Boot
513
514
* Use this command to get a list of available options:
515
<pre>
516
$ grep -Ei 'submenu|menuentry ' /boot/grub/grub.cfg | sed -re "s/(.? )'([^']+)'.*/\1 \2/"
517
menuentry  Ubuntu
518
submenu  Advanced options for Ubuntu
519
    menuentry  Ubuntu, with Linux 4.4.0-34-generic
520
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (upstart)
521
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (recovery mode)
522
menuentry  System setup
523
</pre>
524
* Backup grub configuration, just in case:
525
<pre>
526
$ sudo cp /etc/default/grub /etc/default/grub.bak
527
</pre>
528
* Edit grub configuration and change `GRUB_DEFAULT` to something like this:
529
<pre>
530
$ sudo vim /etc/default/grub
531
532
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic"
533
</pre>
534
* Update grub configuration
535
<pre>
536
$ sudo update-grub
537
</pre>
538
* See also: https://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry
539
540
h2. Ubuntu Networking Resources
541
542
* https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
543
* https://help.ubuntu.com/lts/serverguide/network-configuration.html.en
544
* https://netplan.io/
545
546
h2. Win10 Licensing Info
547
548
* https://www.windowscentral.com/how-change-product-key-windows-10
549
* https://www.tenforums.com/tutorials/49586-determine-if-windows-license-type-oem-retail-volume.html
550
* https://www.tenforums.com/windows-updates-activation/104569-win-10-activation-expiring-volume-license.html
551
552
h2. Python GTK Development Resources
553
554
* https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html
555
* https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Box.html#Gtk.Box.pack_start
556
* https://lazka.github.io/pgi-docs/Gtk-3.0/mapping.html
557
558
h2. cpufrequtils Governor Configuration
559
560
These instructions are intended for Ubuntu 16.04 and later (using systemd init).
561
562
* Check the available and currently set governors. Ubuntu has an โ€œondemandโ€ service that sets the governor to ondemand after boot.
563
<pre>
564
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
565
conservative ondemand userspace powersave performance schedutil
566
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
567
ondemand
568
</pre>
569
570
* Configure cpufrequtils to set the governor to performance at boot
571
<pre>
572
$ echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
573
GOVERNOR="performance"
574
</pre>
575
576
* Disable the automatic ondemand service. 
577
<pre>
578
$ sudo systemctl disable ondemand
579
</pre>
580
581
* Reboot.
582
583
* Now check that the governor is set to performance for every CPU:
584
<pre>
585
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
586
performance
587
performance
588
performance
589
performance
590
โ€ฆ
591
performance
592
performance
593
performance
594
</pre>
595
596
* Check current CPU speeds:
597
<pre>
598
$ watch -n 1 bash -c 'cpufreq-info | grep "current CPU frequency"'
599
</pre>
600
601
h2. rsync via ssh example
602
603
<pre>
604
$ rsync --info=progress2 -ahz --compress-level=9 -e "ssh -i ~/ryft-pat-f1.pem" data/ ryftuser@18.205.65.5:/ryftone/regression/pubmed/data/
605
</pre>
606
607
h2. Read Performance using AIO
608
609
Use this fio command (run from temp directory on disk in question) to measure max disk read performance:
610
611
<pre>
612
$ fio --name TEST --eta-newline=5s --filename=fio-tempfile.dat --rw=read --size=10g --io_size=10g --blocksize=512k --ioengine=libaio --fsync=0 --iodepth=32 --direct=1 --numjobs=1 --runtime=300 --group_reporting
613
</pre>
614
615
Note that DIRECT_IO is required when using AIO. (see also: https://askubuntu.com/a/991311/392271)
616
617
h2. Remove Source Files While Creating Tarball
618
619
This is handy as it saves on disk space.
620
<pre>
621
$ tar --remove-files -cf pictures.tar Pictures/
622
</pre>
623
624
h2. Linux Find and Remove Files
625
626
Find and remove files (even with spaces in the path) using case insensitive matching for the wildcard:
627
<pre>
628
$ find . -type f -iname "*.jpg" -print0 | xargs -0 rm
629
</pre>
630
631
h2. Convert ASCII hex to binary
632
This problem seems to come up every so often. There is no need for a one-off solution:
633
634
<pre>
635
$ xxd -r -p input.txt output.bin
636
</pre>
637
638
https://stackoverflow.com/questions/7826526/transform-a-hex-info-to-binary-using-linux-command
639
640
h2. Well Said
641
642
https://developers.slashdot.org/comments.pl?sid=12326098&cid=56908942
643
644
h2. Hex Editor
645
646
I had been using [[https://hexinator.com/|Hexinator]] but I've had some minor issues with it. Today I tried [[https://www.wxhexeditor.org/home.php|wxHexEditor]] and I was pleasantly surprised.
647
648
Download from here: https://github.com/EUA/wxHexEditor
649
650
You'll need the latest version of libwxgtk<version>-dev package.
651
652
I had some minor issues with the build (which seems a somewhat bizarre arrangement...) modify the makefile to set `CC` and `CXX` directly, right about line 90.
653
654
Finally, to get it installed in the right place:
655
<pre>
656
sudo make install DESTDIR=/opt/local BINDIR=bin DATADIR=share
657
</pre>
658
659
h2. Preprocessor Fun
660
661
To invoke the preprocessor directly:
662
<pre>
663
gcc -E -DSOME_DEFINE=SOME_VALUE somefile.c 
664
</pre>
665
666
See also [[https://linux.die.net/man/1/unifdef|unifdef]]: "The unifdef utility acts on #if, #ifdef, #ifndef, #elif, #else, and #endif lines, and it understands only the commonly-used subset of the expression syntax for #if and #elif lines."
667
668
h2. Convert Oversampled .flac to 16 bit 44.1 khz .flac
669
670
<pre>
671
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox {} -b 16 -r 44100 output/{/.}.flac"
672
673
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox -v 0.98 {} -b 16 -r 44100 output/{/.}.flac"
674
</pre>
675
676
h2. Aligned C++ STL Types
677
678
<pre>
679
#include <vector>
680
#include <boost/align/aligned_allocator.hpp>
681
682
template <typename T>
683
using aligned_vector = std::vector<T, boost::alignment::aligned_allocator<T, 4096>>;
684
</pre>
685
686
h2. Command line convert .png to .jpg
687
688
<pre>
689
$ for x in *.png; do convert $x $(basename $x .png).jpg; done
690
</pre>
691
692
You can also add the "`-quality 90`" option if needed.
693
694
h2. Determine CPU Family Name
695
696
<pre>
697
$ gcc -march=native -Q --help=target|grep march
698
</pre>
699
700
h2. Convert .flac to .m4a (AAC)
701
702
Requires `ffmpeg` built with libfdk_aac:
703
704
<pre>
705
$ /opt/bin/ffmpeg -i input.flac -vn -c:a libfdk_aac -vbr 3 output.m4a
706
</pre>
707
708
All together using `find` and `parallel` for magic:
709
<pre>
710
$ find . -type f -name "*.flac" | parallel -j16 "/opt/bin/ffmpeg -i {} -vn -c:a libfdk_aac -vbr 4 {/.}.m4a"
711
</pre>
712
713
h2. PyGObject
714
715
This is the magic needed to have stuff happen quasi asynchronously using PyGObject (GTK+):
716
717
<pre>
718
# Yield to the main loop temporarily
719
while Gtk.events_pending():
720
    Gtk.main_iteration()
721
</pre>
722
723
h2. FUSE Code
724
725
 *https://pastebin.com/wavKntiu
726
727
h2. Use Windoze Schtuffs
728
729
 * https://support.microsoft.com/en-gb/help/17588/fix-problems-that-block-programs-from-being-installed-or-removed (gotta love how this requires a separate program)
730
 * [[http://landinghub.visualstudio.com/visual-cpp-build-tools|MSVC Tools]] - compiler (seems to be the rough equivalent of `build-essential`)
731
 * [[https://docs.microsoft.com/en-us/sysinternals/downloads/procmon|Process Monitor]] - useful debug tool
732
  * https://www.codeproject.com/Articles/560816/Troubleshooting-dependency-resolution-problems-usi - example for using Process Monitor
733
 * http://download.microsoft.com/download/7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/wdexpress_full.exe - (required by wingtk below)
734
 
735
* https://github.com/wingtk/gvsbuild - haven't tried this yet but looks amazing... 
736
737
h2. Build Handbrake Git Build
738
739
Steps for building Handbrake using AOCC:
740
741
<pre>
742
$ source /home/dsorber/Downloads/aocc/setenv_AOCC.sh
743
$ export CC=clang
744
$ export CXX=clang++
745
$ export CFLAGS="-g -O3 -mtune=native"
746
$ export CXXFLAGS=$CFLAGS
747
$ cd ~/Downloads/HandBrake/
748
$ rm -rf build/
749
$ ./configure --prefix=/opt --enable-x265 --enable-fdk-aac --gcc=/home/dsorber/Downloads/aocc/AOCC-1.1-Compiler/bin/clang
750
$ cd build
751
$ make -j17
752
$ sudo make install
753
</pre>
754
755
----
756
757
Regular build (18.04 and later):
758
<pre>
759
$ rm -rf build/
760
$ ./configure --prefix=/opt/local --enable-x265 --enable-fdk-aac
761
$ cd build
762
$ make -j17
763
$ sudo make install
764
</pre>
765
766
h2. Politically Correct Linux
767
768
* https://entertainment.slashdot.org/comments.pl?sid=11493671&cid=55759997
769
770
h2. This guy gets it
771
772
Regarding software purist ideology vs pragmatism
773
774
* https://linux.slashdot.org/comments.pl?sid=11156367&cid=55256437
775
776
h2. "Rotate" Video Playback via Metadata
777
778
<pre>
779
$ ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
780
</pre>
781
782
783
h2. Ubuntu Remove Old Kernels Oneliner
784
785
<pre>
786
$ sudo apt-get purge $(for tag in "linux-image" "linux-headers"; do dpkg-query -W -f'${Package}\n' "$tag-[0-9]*.[0-9]*.[0-9]*" | sort -V | awk 'index($0,c){exit} //' c=$(uname -r | cut -d- -f1,2); done)
787
</pre>
788
789
* [[https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu/571360#571360|Sauce]]
790
791
h2. Remove New Lines (command line)
792
793
For a file:
794
<pre>
795
$ tr -d '\n' < yourfile.txt
796
</pre>
797
798
Or for output of a command (e.g.):
799
<pre>
800
$ find . -type f -name '*.txt' | tr -d '\n'
801
</pre>
802
803
h2. Convert from .mp4 to .mkv Container
804
805
Use `avconv` to convert container without re-encoding:
806
<pre>
807
$ sudo apt-get install libav-tools
808
809
$ avconv -i filme.mp4 -c copy filme.mkv
810
</pre>
811
812
h2. Remove String From Many File Names
813
814
On Ubuntu use Perl rename utility, e.g.:
815
816
<pre>
817
$ rename 's/ \(1920x1080\) \[WaifuKenny\]//' *.mp4
818
</pre>
819
820
h2. Change Default Text Editor
821
822
I always have to Google this...
823
824
<pre>
825
$ sudo update-alternatives --config editor
826
</pre>
827
828
h2. Linux View System RAM Speed
829
830
View RAM speed (actual) on Debian/Ubuntu/Mint:
831
832
<pre>
833
$ sudo lshw -short -C memory
834
H/W path                      Device      Class          Description
835
====================================================================
836
/0/0                                      memory         64KiB BIOS
837
/0/b                                      memory         32GiB System Memory
838
/0/b/0                                    memory         [empty]
839
/0/b/1                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
840
/0/b/2                                    memory         [empty]
841
/0/b/3                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
842
/0/d                                      memory         768KiB L1 cache
843
/0/e                                      memory         4MiB L2 cache
844
/0/f                                      memory         16MiB L3 cache
845
</pre>
846
847
h2. Linux Memory Schtuff
848
849
* [[https://github.com/jbert/exmap|exmap]]
850
* https://jameshunt.us/writings/smaps.html
851
* https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
852
* http://bmaurer.blogspot.com/2006/03/memory-usage-with-smaps.html
853
854
* https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
855
856
* From: http://stackoverflow.com/questions/24484481/entry-in-proc-meminfo
857
<pre>
858
  2. Active(file), Inactive(file) has file back-end which means its original file is in disk but to use it faster it was loaded on RAM.
859
</pre>
860
861
862
* From: http://unix.stackexchange.com/questions/56879/tracking-down-missing-memory-usage-in-linux
863
864
  The "memory used by a process" is not a clear cut concept in modern operating systems. What can be measured is the size of the address space of the process (SIZE) and resident set size (RSS, how many of the pages in the address space are currently in memory). Part of RSS is shared (most processes in memory share one copy of glibc, and so for assorted other shared libraries; several processes running the same executable share it, processes forked share read-only data and possibly a chunk of not-yet-modified read-write data with the parent). On the other hand, memory used for the process by the kernel isn't accounted for, like page tables, kernel buffers, and kernel stack. In the overall picture you have to account for the memory reserved for the graphics card, the kernel's use, and assorted "holes" reserved for DOS and other prehistoric systems (that isn't much, anyway).
865
866
  The only way of getting an overall picture is what the kernel reports as such. Adding up numbers with unknown overlaps and unknown left outs is a nice exercise in arithmetic, nothing more.
867
868
 * [[http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html|Understanding memory usage on Linux]]
869
870
 * https://linux-mm.org/LinuxMM
871
872
h2. Reinstall grub on UEFI System
873
874
Reinstalling grub on a UEFI system is slightly different than on a traditional legacy BIOS system:
875
876
<pre>
877
# Mount the primary drive root partition and the boot EFI partition
878
sudo mount /dev/sda# /mnt            # Mount root (/) partition
879
sudo mount /dev/sda# /mnt/boot       # Mount boot (/boot) partition (if separate from root partition; typically not)
880
881
sudo mkdir -p /mnt/boot/efi          # Create EFI partition mount point
882
sudo mount /dev/sda1 /mnt/boot/efi   # Mount EFI partition
883
884
# Mount your virtual filesystems:
885
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
886
887
# Chroot
888
sudo chroot /mnt
889
</pre>
890
891
Now, if you have networking you'll need DNS. If using `resolvconf` (for recent versions of Ubuntu):
892
893
# Edit ` /etc/resolvconf/resolv.conf.d/head` and add the following line (OpenDNS server).  Then save and exit:
894
<pre>
895
add nameserver 208.67.222.222
896
</pre>
897
# Next enable updates and update:
898
<pre>
899
sudo resolvconf --enable-updates
900
sudo resolvconf -u
901
</pre>
902
# Now you should have DNS. Test by pinging something.
903
904
Finally, back to fixing grub. Note that the grub install should run smoothly with no errors or warnings. If you see any something is probably wrong.
905
<pre>
906
apt-get install grub-efi-amd64  # Install grub EFI bootloader (this should be all you need to do)
907
908
909
# manual steps if you need them for some reason
910
grub-install --recheck --no-floppy --force /dev/sda1  # Install grub bootloader in EFI partition
911
912
#####
913
echo "configfile (hd0,gpt#)/boot/grub.cfg" > /boot/efi/ubuntu/grub.cfg # Tell grub to load grub.cfg from /boot
914
915
update-grub                          # Create grub menu list
916
#####
917
918
exit                                 # Exit chroot
919
</pre>
920
921
Reboot and you should be back in business.
922
923
h2. Convert flac to VBR mp3 using ffmpeg/lame
924
925
<pre>
926
for file in *.flac; do name=$(echo $file | sed "s/\.flac//g"); ffmpeg -i "$file" -codec:a libmp3lame -qscale:a 0 "$name".mp3; done
927
</pre>
928
929
h2. Create UEFI/legacy BIOS Bootable ISO
930
931
* http://askubuntu.com/questions/625286/how-to-create-uefi-bootable-iso
932
933
h2. Getting rEFInd to work on Mac OS 10.11
934
935
* http://mattjanik.ca/blog/2015/10/01/refind-on-el-capitan/
936
937
h2. Convert DTS 5.1 to FLAC
938
939
<pre>
940
sudo apt-get install libdca-utils ffmpeg sound-juicer gnome-terminal easytag vlc 
941
942
for file in *.wav; do name=$(echo $file | sed "s/\.wav//g"); dcadec -o wavall "$file" > "$name"_decoded.wav; ffmpeg -i "$name"_decoded.wav "$name".flac; rm -f "$file" "$name"_decoded.wav; done
943
</pre>
944
945
Source: http://ubuntuforums.org/archive/index.php/t-1849260.html
946
947
h2. Windows Utils
948
949
* http://windirstat.info/download.html
950
* https://www.raymond.cc/blog/safely-delete-unused-msi-and-mst-files-from-windows-installer-folder/
951
952
h2. SSH Security
953
954
https://stribika.github.io/2015/01/04/secure-secure-shell.html
955
956
h2. Windows 10
957
958
* http://ultimateoutsider.com/downloads/ - GWX Control Panel to disable GWX (Windows 10 update nagging)
959
* [[https://www.safer-networking.org/spybot-anti-beacon/|Spybot Anti-Beacon]] - Disable Micro$oft "telemetry" data gathering from Windows 10, 8.x, and 7
960
961
<pre>
962
The newest version of the KB3035583 update includes a background process which scans the 
963
system's Windows Registry twice a day to see if the values for the four aforementioned registry 
964
inputs were manually edited to disable the upgrade prompt. If they were, the process will alter 
965
the values, silently re-download the Windows 10 installation files (about 6 GB in total), and 
966
prompt the user to upgrade.
967
</pre>
968
969
970
h2. gpg-agent
971
972
* http://www.infrastructureanywhere.com/documentation/additional/mirrors.html
973
974
These instructions are geared toward reprepro but should be useful in general for setting up `gpg-agent`.
975
976
977
h2. Resolve DNS While VPN Connected
978
979
How to configure dnsmasq for DNS overrides while using a VPN connection: https://chawlasumit.wordpress.com/2014/06/15/linux-mint-openconnect-vpn-dns-issues/
980
981
h2. Pretty Print Python Traceback
982
983
<pre>#!python
984
import traceback
985
986
 ...
987
988
try: 
989
    with open('/dev/null', 'w') as void:
990
        rc = not bool(subprocess.call('modprobe -r {:s}'.format(mod_name), 
991
                                      shell=True, stdout=void, stderr=void))
992
except Exception as e:
993
    print_failure_status()
994
    exc_type, exc_value, exc_traceback = sys.exc_info()
995
    print('\n')
996
    traceback.print_exception(exc_type, exc_value, exc_traceback)
997
    print('\n')
998
</pre>
999
1000
h2. Generating Random Data Files for Testing
1001
1002
One approach is to use /dev/urandom (non-blocking pseudorandom device):
1003
<pre>
1004
$ dd if=/dev/urandom bs=32M count=32 of=data_1GB.bin
1005
</pre>
1006
Unfortunately /dev/urandom is a bit slow. However, you can alternatively use openssl to generate pseudorandom numbers a bit faster:
1007
<pre>
1008
 $ openssl rand 1073741824 > data_1GB.bin
1009
 $ for run in {1..30}; do echo $run; openssl rand 1073741824 >> data_30GB.bin; done
1010
</pre>
1011
1012
h2. Cloning HDDs
1013 8
1014 1
When configuring multiple chassis it is necessary to clone an HDD. There are all sorts of disk imaging tools out there but it's hard to beat the trusty dd command. The pv (pipe viewer) portion isn't strictly necessary but it prints out a very useful textual status bar. The back ticked blockdev command reports the size of the drive in bytes, which pv then uses to determine overall progress. The bs argument to dd should correspond to the cache size of the drive for optimum performance (32MB is a sane default for most drives these days).
1015
1016
To clone a single drive to another identical drive (assuming sda is the source and sdb is the destination):
1017
<pre>
1018
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | sudo dd of=/dev/sdb bs=32M
1019
</pre>
1020
To clone to multiple drives all at once (assuming sda is the source and sdb, sdc are destinations):
1021
<pre>
1022
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | tee >(sudo dd of=/dev/sdb bs=32M) | sudo dd of=/dev/sdc bs=32M
1023
</pre>
1024
It is entirely possible to clone more drives by adding additional `>(sudo dd of=/dev/sdX bs=32M)` arguments to the tee command. Note that tee outputs to stdout so it is necessary to pipe the output of tee to the final dd command as shown above. If you don't do this then tee will spew the raw contents of the source HDD to your screen, which will make the clone take forever and look especially ugly!
1025
1026
For some reason RedHat/CentOS do not have the pv command or even a package for it in their repos!!! Therefore, boot from a Debian-based OS in order to clone.
1027
1028
h2. Generating ISOs
1029
1030
<pre>
1031
 $ genisoimage -R -J -o <output.iso> <some directory>
1032
</pre>
1033
To deal with long file names:
1034
<pre>
1035
 $ genisoimage -R -J -l -D -joliet-long -o <output.iso> <some directory>
1036
</pre>
1037
1038 2
h2. BIOS/grub
1039 1
1040 2
* http://forums.linuxmint.com/viewtopic.php?f=46&t=119832
1041
* http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html
1042
* https://wiki.archlinux.org/index.php/GRUB2
1043
* http://unix.stackexchange.com/questions/28443/does-grub2-support-putting-boot-on-a-raid5-partition
1044 1
1045
h3. Creating a BIOS Boot Partition on a GPT system
1046
1047
<pre>
1048
$ sudo parted /dev/sda
1049
(parted) mkpart primary 0 1024k
1050
(parted) set 2 bios_grub on
1051
</pre>
1052
1053 2
h2. Actiontec Router
1054
1055
* http://transition.fcc.gov/oet/ea/fccid/
1056
* http://opensource.actiontec.com/mi424wref.html
1057 1
1058
h2. Temp
1059
1060
https://www.grumpyland.com/blog/183/installing-software-raid-on-centos-567-via-ssh/
1061
<pre>
1062
# swap is on /dev/md1
1063
/dev/md1 none            swap    sw              0       0
1064
1065
# storage is on /dev/md0
1066
/dev/md0        /storage        xfs     noatime,barrier=0 0 0
1067
//faramir/production/sw /sw     cifs    username=samba,password=w00tw00t!,file_mode=0666,dir_mode=0777  0       0
1068
</pre>
1069
1070
----
1071
[[../|Back home]]