Project

General

Profile

Miscellaneous » History » Version 30

Anonymous, 11/23/2024 09:12 PM
adding note

1 1
h1. Miscellaneous
2
3 30
h2. Change Windows 10 Version
4
5
* *Disconnect from internet*
6
* Go to "Settings" > "Update & Security" > "Activation" > "Change productkey"
7
* Enter @VK7JG-NPHTM-C97JM-9MPGT-3V66T@
8
* Press "Ok" and wait for the process to run
9
* Reboot after error message is displayed
10
11
Codes for all editions:
12
<pre>
13
[cmi]
14
namespace=urn:schemas-microsoft-com:unattend
15
ClientServerSplit=true
16
AnswerFileFormat=1
17
professionalworkstationn=WYPNQ-8C467-V2W6J-TX4WX-WT2RQ
18
enterpriseneval=MNXKQ-WY2CT-JWBJ2-T68TQ-YBH2V
19
serverazurecor=QN7G3-4RM92-MT6QR-PR966-FVYV7
20
serverrdshCore=NJCF7-PW8QT-3324D-688JX-2YV66
21
onecoreupdateos=NFDPX-3MV8X-THC2X-QQ9QP-P9YY6
22
serverstandardeval=BGHNQ-64HFC-WD7WG-K2T34-8477T
23
serverdatacenterevalcorCore=RNJ27-KR4TJ-DX6FB-XFJJ2-2DQMJ
24
iotenterprisek=P8Q7T-WNK7X-PMFXY-VXHBG-RRK69
25
ServerStandardEvalCor=KGKTQ-NWWW9-Q8KKW-4M2R9-66TFB
26
iotenterprise=XQQYW-NFFMW-XJPBH-K8732-CKFFD
27
educationn=84NGF-MHBT6-FXBX8-QWJK7-DRR8H
28
serverdatacentereval=K4NJQ-WBJ89-PJGPP-9MTY4-R3QK2
29
serverazurecorCore=QN7G3-4RM92-MT6QR-PR966-FVYV7
30
enterpriseseval=Y22YQ-HNV92-HWMXQ-PMDQ9-7XRGJ
31
coresinglelanguage=BT79Q-G7N6G-PGBYW-4YWX6-6F4BT
32
professionalcountryspecific=3XP6D-CRND4-DRYM2-GM84D-4GG8Y
33
core=YTMG3-N6DKC-DKB77-7M9GH-8HVX7
34
coresystemserver=6DWFN-9DBPB-99W4C-XYWKQ-VXPFM
35
serverdatacenterevalcor=RNJ27-KR4TJ-DX6FB-XFJJ2-2DQMJ
36
serverstandardcor=B2NYV-R6JT2-H9YTQ-VQ4X3-979YK
37
serverdatacentercorCore=DCXHG-67NR6-6CRMW-2PYFW-PKGD7
38
serverazurenano=9JQNQ-V8HQ6-PKB8H-GGHRY-R62H6
39
coren=4CPRK-NM3K3-X6XXQ-RXX86-WXCHW
40
EnterpriseSNEval=VW76H-NXCYD-PPWKF-JG63K-KQFGM
41
starter=D6RD9-D4N8T-RT9QX-YW6YT-FCWWJ
42
professional=VK7JG-NPHTM-C97JM-9MPGT-3V66T
43
professionaln=2B87N-8KFHP-DKV6R-Y2C8J-PKCKT
44
enterprise=XGVPP-NMH47-7TTHJ-W3FW7-8HV2C
45
education=YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
46
serverwebCore=3WN48-GVPXF-VHWK4-29Y8D-KKTD2
47
ServerTurbine=3Y8N7-3R679-4XFFH-6BTCM-X4W7X
48
serverazurestackhcicor=YP2N4-KHPFV-F2D34-PXFJH-MBK3B
49
enterprisegn=FW7NV-4T673-HF4VX-9X4MM-B4H4T
50
enterpriseg=FV469-WGNG4-YQP66-2B2HY-KD8YX
51
serverweb=3WN48-GVPXF-VHWK4-29Y8D-KKTD2
52
serverrdsh=NJCF7-PW8QT-3324D-688JX-2YV66
53
serverdatacenternanoCore=BFM6D-TKNBY-X6RGR-PHJ4G-723B6
54
ServerDatacenter=9DYFC-FNGM2-KQGHQ-BTRK4-JHYT3
55
serverstandard=J768X-NXC7R-GFB9Q-BHF4H-GCVBB
56
enterprisesn=2D7NQ-3MDXF-9WTDT-X9CCP-CKD8V
57
serverdatacenternano=BFM6D-TKNBY-X6RGR-PHJ4G-723B6
58
ServerStandardEvalCorCore=KGKTQ-NWWW9-Q8KKW-4M2R9-66TFB
59
serverstandardnano=69NHX-WQQ7G-QVBPG-4HPQP-8XDB7
60
cloudeditionn=K9VKN-3BGWV-Y624W-MCRMQ-BHDCD
61
professionaleducation=8PTT6-RNW4C-6V7J2-C2D3X-MHBPB
62
serverazurestackhcicorCore=YP2N4-KHPFV-F2D34-PXFJH-MBK3B
63
serverstandardevalCore=BGHNQ-64HFC-WD7WG-K2T34-8477T
64
serverturbinecorCore=H7XNC-JYM86-7B27X-8MJ9W-TKFX9
65
professionaleducationn=GJTYN-HDMQY-FRR76-HVGC7-QPF8P
66
professionalworkstation=DXG7C-N36C4-C4HTG-X4T3X-2YV77
67
enterprises=PJB47-8PN2T-MCGDY-JTY3D-CBCPV
68
cloudedition=KY7PN-VR6RX-83W6Y-6DDYQ-T6R4W
69
iotenterprisesk=N979K-XWD77-YW3GB-HBGH6-D32MH
70
startern=3NFXW-2T27M-2BDW6-4GHRV-68XRX
71
EnterpriseEval=VPMWD-PVNRR-79WJ9-VVJQC-3YH2G
72
serverturbinecor=H7XNC-JYM86-7B27X-8MJ9W-TKFX9
73
iotenterprises=CGK42-GYN6Y-VD22B-BX98W-J8JXD
74
ServerDatacenterCore=9DYFC-FNGM2-KQGHQ-BTRK4-JHYT3
75
wnc=TMP2N-KGFHJ-PWM6F-68KCQ-3PJBP
76
ServerTurbineCore=3Y8N7-3R679-4XFFH-6BTCM-X4W7X
77
serverazurenanoCore=9JQNQ-V8HQ6-PKB8H-GGHRY-R62H6
78
iotenterpriseseval=R63DV-9NPDX-QVWJF-HMR8V-M4K7D
79
holographic=H4MND-KF7J8-PWBTV-2P3JG-BP4FC
80
serverdatacenterevalCore=K4NJQ-WBJ89-PJGPP-9MTY4-R3QK2
81
corecountryspecific=N2434-X9D7W-8PF6X-8DV9T-8TYMD
82
serverstandardcorCore=B2NYV-R6JT2-H9YTQ-VQ4X3-979YK
83
enterprisen=WGGHN-J84D6-QYCPR-T7PJ7-X766F
84
professionalsinglelanguage=G3KNM-CHG6T-R36X3-9QDG6-8M8K9
85
serverstandardnanoCore=69NHX-WQQ7G-QVBPG-4HPQP-8XDB7
86
serverdatacentercor=DCXHG-67NR6-6CRMW-2PYFW-PKGD7
87
serverstandardCore=J768X-NXC7R-GFB9Q-BHF4H-GCVBB
88
gvlkcoresinglelanguage=7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
89
gvlkcore=TX9XD-98N7V-6WMQ6-BX7FG-H8Q99
90
gvlkprofessionalworkstationn=9FNHH-K3HBT-3W4TD-6383H-6XYWF
91
gvlkserverazurecor=FCNV3-279Q9-BQB46-FTKXX-9HPRH
92
gvlkserverrdshCore=CPWHC-NT2C7-VYW78-DHDB2-PG3GK
93
gvlkenterprisesn=92NFX-8DJQP-P6BBQ-THF9C-7CG2H
94
gvlkiotenterprises=KBN8V-HFGQ4-MGXVD-347P6-PDQGT
95
gvlkServerDatacenterCore=D764K-2NDRG-47T6Q-P8T8W-YP6DF
96
gvlkServerTurbineCore=XGN3F-F394H-FD2MY-PP6FD-8MCRC
97
gvlkcloudeditionn=6XN7V-PCBDC-BDBRH-8DQY7-G6R44
98
gvlkprofessionaleducation=6TP4R-GNPTD-KYYHQ-7B7DP-J447Y
99
gvlkcoren=3KHY7-WNT83-DGQKR-F7HPR-844BM
100
gvlkprofessional=W269N-WFGWX-YVC9B-4J6C9-T83GX
101
gvlkprofessionaln=MH37W-N47XK-V7XM9-C7227-GCQG9
102
gvlkeducationn=2WH4N-8QGBV-H22JP-CT43Q-MDWWJ
103
gvlkeducation=NW6C2-QMPVW-D7KKK-3GKT6-VCFB2
104
gvlkenterprise=NPPR9-FWDCX-D2C8J-H872K-2YT43
105
gvlkServerTurbine=XGN3F-F394H-FD2MY-PP6FD-8MCRC
106
gvlkprofessionaleducationn=YVWGF-BXNMC-HTQYQ-CPQ99-66QFC
107
gvlkprofessionalworkstation=NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J
108
gvlkcloudedition=37D7F-N49CB-WQR8W-TBJ73-FM8RX
109
gvlkenterprises=M7XTQ-FN8P6-TTKYV-9D4CC-J462D
110
gvlkcorecountryspecific=PVMJN-6DFY6-9CCP6-7BKTT-D3WVR
111
gvlkenterprisegn=44RPN-FTY23-9VTTB-MP9BX-T84FV
112
gvlkenterprisen=DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4
113
gvlkserverazurecorCore=FCNV3-279Q9-BQB46-FTKXX-9HPRH
114
gvlkenterpriseg=YYVX9-NTFWV-6MDM3-9PT4T-4M68B
115
gvlkserverrdsh=CPWHC-NT2C7-VYW78-DHDB2-PG3GK
116
gvlkServerDatacenter=D764K-2NDRG-47T6Q-P8T8W-YP6DF
117
gvlkserverstandardCore=TVRH6-WHNXV-R9WG3-9XRFY-MY832
118
gvlkserverstandard=TVRH6-WHNXV-R9WG3-9XRFY-MY832
119
120
[BuildInfo]
121
</pre>
122
123
Sauce: https://forums.mydigitallife.net/threads/how-to-upgrade-from-home-sl-to-pro-or-any-other-higher-sku-and-license-switching.85294/
124
125 26
h2. Find all files matching regex pattern
126
127
All PNG images starting with 5 digits followed by a dash:
128
<pre>
129
$ find . -regextype posix-extended -regex "\./[[:digit:]]{5}-(.*).png
130
</pre>
131
132 25
h2. Change all file or directory permissions
133
134
<pre>
135
$ find . -type d -exec chmod 755 {} \;
136
$ find . -type f -exec chmod 644 {} \;
137
</pre>
138
139 24
h2. List Root Device
140
141
<pre>
142
$ findmnt -n -o SOURCE /
143
</pre>
144
145
h2. List Block Devices with Serial Numbers
146
147
<pre>
148
$ lsblk --nodeps -o name,serial 
149
</pre>
150
151 23
h2. Useful rsync Examples
152
153
* Synchronize directories (one way):
154
<pre>
155
$ rsync -auhrP --delete --info=del,name,stats2 "/mnt/phalanx/" "/storage"
156
</pre>
157
* Copy with progress:
158
<pre>
159
$ rsync -ahr --info=progress2 some_file.mp4 /storage/
160
</pre>
161
162
163 22
h2. Patch Youtube App using Revanced Manager (6/22/2024)
164
165
h3. Install Steps
166
167
* Delete Revanced app, Micro G, Revanced manager prior installation any of mentioned apps.
168
* Download *but not install* following:
169
** Micro G - https://github.com/ReVanced/GmsCore/releases/tag/v0.3.1.3.240913
170
** Revanced Manager - https://revanced.app/patches?s=Mic
171
** 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/
172
* Install Micro G.
173
* Next install Revanced Manager
174
* Open Revanced manager
175
** Go to Patches
176
** Select an app
177
** Bottom right corner choose Storage
178
** Find YT APK you downloaded, select patch on the bottom right corner
179
* Wait for patch and compile to finish, then choose install app
180
* Open it, check if its Vanced, restart the phone.
181
* If you have stock YT app, uninstall updates and disable it
182
183
Source: https://www.reddit.com/r/revancedapp/comments/1bq92r7/me_rn_trying_to_patch_youtube_revanced/
184
185 19
h2. Combine find and GNU parallel
186
187
Example:
188
<pre>
189
$ find . -name '*.jpg' | parallel convert -geometry 120 {} {.}_thumb.jpg
190 21
$ find . -name '*.png' | parallel --eta convert '{}' -quality 90 '{.}.jpg'
191 29
$ ls -1 *.png | parallel convert '{}' -quality 90 '{.}.jpg'
192 21
$ find . -name '*.png' -delete
193 19
</pre>
194
Note @{.}@ is the filename without the @.jpg@ portion.
195
196
* See: https://www.gnu.org/software/parallel/parallel_examples.html#example-compute-intensive-jobs-and-substitution
197
198 18
h2. Setup ttyd
199
200
* Download @ttyd@ and put it in @/opt/local/bin/ttyd@:
201
** https://github.com/tsl0922/ttyd/releases
202
* Create systemd service file @/etc/systemd/system/ttyd.service@: 
203
<pre>
204
[Unit]                                                                                                                                                                                           
205
Description=TTYD
206
After=syslog.target
207
After=network.target
208
 
209
[Service]
210
ExecStart=/opt/local/bin/ttyd -W -p 9772 login
211
Type=simple
212
Restart=always
213
User=root
214
Group=root
215
 
216
[Install]
217
WantedBy=multi-user.target
218
</pre>
219
** Start and enable service:
220
<pre>
221
$ sudo systemctl start ttyd && sudo systemctl enable ttyd
222
</pre>
223
* Setup apache configuration (add to existing)
224
<pre>
225
        ProxyRequests Off
226
        ProxyPreserveHost On
227
        RewriteEngine on
228
        RewriteCond %{HTTP:Upgrade} websocket [NC]
229
        RewriteCond %{HTTP:Connection} upgrade [NC]
230
        RewriteRule /terminal/?(.*) "ws://localhost:9772/$1" [P,L]
231
        ProxyPass /terminal http://localhost:9772/
232
        ProxyPassReverse /terminal http://localhost:9772/
233
</pre>
234
** Enable necessary apache modules:
235
<pre>
236
$ a2enmod proxy proxy_http proxy_wstunnel mod_rewrite
237
</pre>
238
239
240 17
h2. Increase tmux scrollback
241
242
<pre>
243
$ cd 
244
$ echo "set -g history-limit 9999999" >> ~/.tmux.conf
245
</pre>
246
247 16
h2. Setup VNC
248 15
249
On the server side:
250
# Install @x11vnc@:
251
<pre>
252
$ sudo apt install x11vnc net-tools
253
</pre>
254
# Set VNC password:
255
<pre>
256
$ x11vnc -storepasswd
257
</pre>
258
# Start VNC service from command line:
259
<pre>
260
$ sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/dsorber/.vnc/passwd -rfbport 5900 -shared
261
</pre>
262
# To start at boot using systemd service create: @/etc/systemd/system/x11vnc.service@:
263
<pre>
264
[Unit]
265
Description=x11vnc remote desktop server
266
After=multi-user.target
267
268
[Service]
269
Type=simple
270
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/dsorber/.vnc/passwd -rfbport 5900 -shared
271
272
Restart=on-failure
273
274
[Install]
275
WantedBy=multi-user.target
276
</pre>
277 28
** Setup service
278
<pre>
279
$ sudo systemctl daemon-reload
280
$ sudo systemctl enable x11vnc.service 
281
$ sudo systemctl start x11vnc.service
282
</pre>
283 15
284
On the client side:
285
# Install @remmina@:
286
<pre>
287
$ sudo apt install remmina
288
</pre>
289
# Open @remmina@, select "VNC", and type in the server's IP address.
290
291
* Source: https://forums.linuxmint.com/viewtopic.php?t=369092
292
293 14
h2. sshuttle
294 15
295
Poor man's VPN:
296 14
297
<pre>
298
$ sshuttle --dns -NHr dsorber@phalanx.homelinuxserver.org:3268  192.168.0.0/16
299
</pre>
300
301 13
h2. Batch Convert PNG to JPG
302
303
NOTE: @convert@ comes from ImageMagick
304
<pre>
305
& ls -1 *.png | parallel --eta convert '{}' -quality 90 '{.}.jpg'
306
</pre>
307
308 12
h2. Crop Video with ffmpeg
309
310
<pre>
311
$ ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4
312
</pre>
313
314
* @out_w@ is the width of the output rectangle
315
* @out_h@ is the height of the output rectangle
316
* @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) 
317
318
Test using @ffplay@:
319
<pre>
320
$ ffplay -i input -vf "crop=out_w:out_h:x:y"
321
</pre>
322
323 10
h2. Build Custom Windows ISOs
324
325
* https://uupdump.net/
326 11
* https://forums.mydigitallife.net/threads/kms_vl_all-smart-activation-script.79535/
327 10
328 9
h2. Script to Convert Local manpages to html
329
330
Note use @zcat@ if the manpages are compressed:
331
332
<pre>
333
#!/bin/bash
334
335
mkdir -p html
336
for file in *; do
337
        if [ -f $file ] && [ "${file: -3}" != ".sh" ]; then
338
                echo $file
339
                #echo "${file%.*}"
340
                pandoc --from man --to html < $file > html/${file%.*}.html
341
        fi
342
done
343
</pre>
344
345 6
h2. Display Total rsync Progress
346
347
<pre>
348 7
$ rsync -a --no-i-r --info=progress2 /path/to/src /path/to/dest/
349 6
</pre>
350
351
NOTE: @-v@ does not work with @--info=progress2@
352
353
Source: https://serverfault.com/a/441724/472586
354
355 5
h2. Slice Video File 
356
357
<pre>
358
$ ffmpeg -ss 00:01:00 -to 00:02:00  -i input.mp4 -c copy output.mp4
359
</pre>
360
361
Explanation of the command:
362
363
* -i: This specifies the input file. In that case, it is (input.mp4).
364
* -ss: Used with -i, this seeks in the input file (input.mp4) to position.
365
* 00:01:00: This is the time your trimmed video will start with.
366
* -to: This specifies duration from start (00:01:40) to end (00:02:12).
367
* 00:02:00: This is the time your trimmed video will end with.
368
* -c copy: This is an option to trim via stream copy. (NB: Very fast)
369
370 4
h2. Add new drive SW RAID5
371
372
# Format drive if needed (see below for steps).
373
# Add new drive to SW RAID:
374
<pre>
375
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1
376
</pre>
377
# Grow array:
378
<pre>
379
$ sudo mdadm --grow --raid-devices=4 /dev/md0
380
</pre>
381
382
h2. Replace failed SW RAID drive
383
384
# If drive is brand new be sure to create a partition on it:
385
<pre>
386
sorber@file2:~$ sudo parted /dev/sdg
387
GNU Parted 3.3
388
Using /dev/sdg
389
Welcome to GNU Parted! Type 'help' to view a list of commands.
390
(parted) mklabel gpt
391
(parted) mkpart primary 2048s 100%                                        
392
(parted) print                                                            
393
Model: ATA ST2000DM008-2FR1 (scsi)
394
Disk /dev/sdg: 2000GB
395
Sector size (logical/physical): 512B/4096B
396
Partition Table: gpt
397
Disk Flags: 
398
399
Number  Start   End     Size    File system  Name     Flags
400
 1      1049kB  2000GB  2000GB               primary
401
402
(parted) quit
403
</pre>
404
# If needed, mark bad drive as failed:
405
<pre>
406
$ sudo mdadm --manage /dev/md0 --fail /dev/sdd
407
</pre>
408
# Add new drive to replace failed:
409
<pre>
410
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1 /dev/sdg1
411
</pre>
412
# Improve rebuild speed slightly:
413
<pre>
414
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_min"
415
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_max"
416
</pre>
417
# Monitor rebuild:
418
<pre>
419
$ watch -n1 cat /proc/mdstat 
420
</pre>
421
422
h2. Get detailed drive information
423
424
<pre>
425
$ udevadm info --query=all --name=/dev/sda
426
</pre>
427
428 1
h2. Split flac with cue
429
430
<pre>
431
$ sudo apt install cuetools shntool
432
433
$ shnsplit -f file.cue -t %n-%t -o flac file.flac
434
</pre>
435
436
h2. Fix Chrome Display Glitches
437
438
Somewhere around Chrome 86 display glitches started happening on wake. Here is how to fix:
439
440 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.
441 1
442
h2. Setup SSH Public Key
443
444
# 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.
445
<pre>
446
$ ssh-keygen -t rsa
447
</pre>
448 3
 *NOTE:* for NetBeans to use/recognize the ssh key you must use the old PEM format:
449 1
<pre>
450
$ ssh-keygen -m PEM -t rsa
451
</pre>
452
# Now use `ssh-copy-id` to copy the key to the remote machine (for example):
453
<pre>
454
$ ssh-copy-id -i ~/.ssh/phalanx_rsa.pub dsorber@phalanx
455
</pre>
456
457
h2. Read Windows Product Key from ACPI Firmware
458
459
Boot into Linux and run:
460
461
<pre>
462
$ sudo strings /sys/firmware/acpi/tables/MSDM
463
</pre>
464
465
h2. Windows 10 Install and SysPrep Instructions
466
467
Very good instructions: https://theitbros.com/sysprep-windows-10-machine-guide/
468
469
470
h2. Search and Replace on Binary Files
471
472
A good hex editor can do search and replace on binary files but sometimes that's not practical:
473
474
* BBE - https://sourceforge.net/projects/bbe-/
475
 BBE is a binary editor with SED-like syntax:
476
<pre>
477
$ bbe -e 's/\x0a\x0d\x0a/\x0d\x0a/' infile > outfile
478
</pre>
479
* binwalk - https://github.com/ReFirmLabs/binwalk
480
 binwalk can search for hex strings (and do many other things)
481
<pre>
482
$ binwalk -R "\x0a\x0d\x0a" infile
483
484
WARNING: Signature '0    string    \x0a\x0d\x0a    Raw signature (\x0a\x0d\x0a)' is a self-overlapping signature!
485
486
DECIMAL       HEXADECIMAL     DESCRIPTION
487
--------------------------------------------------------------------------------
488
242           0xF2            Raw signature (\x0a\x0d\x0a)
489
412           0x19C           Raw signature (\x0a\x0d\x0a)
490
580           0x244           Raw signature (\x0a\x0d\x0a)
491
749           0x2ED           Raw signature (\x0a\x0d\x0a)
492
. . .
493
</pre>
494
495
h2. Wake-on-LAN WOL
496
497
Must be enabled on interface; need MAC
498
<pre>
499
$ sudo apt install etherwake
500
$ sudo etherwake <target MAC> -i <outgoing interface>
501
502
$ sudo etherwake b4:2e:99:a5:1e:f0 -i enp30s0
503
</pre>
504
505
h2. Allocator Shim
506
507
From Chromium, this is really interesting
508
* https://chromium.googlesource.com/chromium/src/base/+/master/allocator/README.md
509
510
However it is not clear how to use it outside of Chromium.
511
512
h2. Update Geany
513
514
# Install prereq packages (this obviously only needs to be done once):
515
<pre>
516
$ sudo apt install libgtk-3-dev libgtkspell-dev libgtkspell3-3-dev
517
</pre>
518
# Set compile flags:
519
<pre>
520
$ export CFLAGS="-O3 -march=native" 
521
$ export CXXFLAGS=$CFLAGS
522
</pre>
523
# Build geany and set to install in /opt so it won't collide with the packaged version:
524
<pre>
525
$ tar xf geany-1.30.tar.bz2
526
$ cd geany-1.30/
527
$ ./configure --prefix=/opt/local --enable-gtk3
528
$ make -j20
529
$ sudo make install
530
</pre>
531
# Set PKG_CONFIG_PATH environment variable so we can build the plugins.
532
<pre>
533
$ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/
534
</pre>
535
# Build geany-plugins:
536
<pre>
537
$ tar xf geany-plugins-1.30.tar.bz2 
538
$ cd geany-plugins-1.30/
539
$ ./configure --prefix=/opt/local --enable-gtk3
540
$ make -j20
541
$ sudo make install
542
</pre>
543
544
h2. Find and replace across multiple files
545
546
<pre>
547
$ find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g'
548
</pre>
549
550
h2. Useful IPMI commands
551
552
553
Power measurement on the SuperMicro (probably won't work on Dell chassis as they have some proprietary version of ipmi):
554
555
<pre>
556
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.136.108 dcmi power reading
557
</pre>
558
559
Check power status (i.e. on/off) of chassis:
560
<pre>
561
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power status
562
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power off
563
</pre>
564
565
Get IPMI IP address (look for "IP Address"):
566
<pre>
567
sudo ipmitool lan print 
568
</pre>
569
570
h2. Full sshfs Connect Command
571
572
<pre>
573
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/
574
</pre>
575
576
h2. Side-by-side Color Diff
577
578
<pre>
579
$ sudo apt-get install colordiff
580
$ colordiff -y --suppress-common-lines data.txt /ryftone/data.txt
581
</pre>
582
583
h2. x86 ABI
584
585
* https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
586
587
h2. clang-format and clang-tidy
588
589
* http://www.labri.fr/perso/fleury/posts/programming/using-clang-tidy-and-clang-format.html
590
591
h2. Shared Library and Related Resources
592
593
* http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
594
* https://blog.qt.io/blog/2011/10/28/rpath-and-runpath/
595
* http://www.bnikolic.co.uk/blog/linux-ld-debug.html
596
* http://insanecoding.blogspot.com/2012/07/creating-portable-linux-binaries.html
597
* https://stackoverflow.com/questions/4156055/static-linking-only-some-libraries
598
599
h2. Ubuntu: List Grub Entries
600
601
<pre>
602
gawk  'BEGIN {                                                                                                                       
603
  l=0                                                                                                                                
604
  menuindex= 0                                                                                                                       
605
  stack[t=0] = 0                                                                                                                     
606
}                                                                                                                                    
607
608
function push(x) { stack[t++] = x }                                                                                                  
609
610
function pop() { if (t > 0) { return stack[--t] } else { return "" }  }                                                              
611
612
{                                                                                                                                    
613
614
if( $0 ~ /.*menu.*{.*/ )                                                                                                             
615
{                                                                                                                                    
616
  push( $0 )                                                                                                                         
617
  l++;                                                                                                                               
618
619
} else if( $0 ~ /.*{.*/ )                                                                                                            
620
{                                                                                                                                    
621
  push( $0 )                                                                                                                         
622
623
} else if( $0 ~ /.*}.*/ )                                                                                                            
624
{                                                                                                                                    
625
  X = pop()                                                                                                                          
626
  if( X ~ /.*menu.*{.*/ )                                                                                                            
627
  {                                                                                                                                  
628
     l--;                                                                                                                            
629
     match( X, /^[^'\'']*'\''([^'\'']*)'\''.*$/, arr )                                                                               
630
631
     if( l == 0 )                                                                                                                    
632
     {                                                                                                                               
633
       print menuindex ": " arr[1]                                                                                                   
634
       menuindex++                                                                                                                   
635
       submenu=0                                                                                                                     
636
     } else                                                                                                                          
637
     {                                                                                                                               
638
       print "  " (menuindex-1) ">" submenu " " arr[1]                                                                               
639
       submenu++                                                                                                                     
640
     }                                                                                                                               
641
  }                                                                                                                                  
642
}                                                                                                                                    
643
644
}' /boot/grub/grub.cfg
645
</pre>
646
647
* https://askubuntu.com/a/941993/392271
648
649
650
h2.GCC Disable Unused Variable Warnings
651
652
<pre>
653
#pragma GCC diagnostic push
654
#pragma GCC diagnostic ignored "-Wunused-variable"
655
( your problematic library includes )
656
#pragma GCC diagnostic pop
657
</pre>
658
659
See: https://stackoverflow.com/a/22708539/73878
660
661
h2. Fix Steam after NVidia driver update
662
663
Since this has now bitten me twice... Steam requires the 32 bit version of the GL library.
664
665
<pre>
666
$ sudo apt install libnvidia-gl-418:i386
667
</pre>
668
669
h2. Restart Cinnamon from TTY
670
671
# Cinnamon freezes
672
# Switch tty. I usually go to tty6, `Ctrl+Alt+F6`
673
# If you need to login first, do so.
674
# 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).
675
# 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.
676
677
Sauce: https://askubuntu.com/a/198935/392271
678
679
h2. Ubuntu Set Specific Kernel to Boot
680
681
* Use this command to get a list of available options:
682
<pre>
683
$ grep -Ei 'submenu|menuentry ' /boot/grub/grub.cfg | sed -re "s/(.? )'([^']+)'.*/\1 \2/"
684
menuentry  Ubuntu
685
submenu  Advanced options for Ubuntu
686
    menuentry  Ubuntu, with Linux 4.4.0-34-generic
687
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (upstart)
688
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (recovery mode)
689
menuentry  System setup
690
</pre>
691
* Backup grub configuration, just in case:
692
<pre>
693
$ sudo cp /etc/default/grub /etc/default/grub.bak
694
</pre>
695
* Edit grub configuration and change `GRUB_DEFAULT` to something like this:
696
<pre>
697
$ sudo vim /etc/default/grub
698
699
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic"
700
</pre>
701
* Update grub configuration
702
<pre>
703
$ sudo update-grub
704
</pre>
705
* See also: https://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry
706
707
h2. Ubuntu Networking Resources
708
709
* https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
710
* https://help.ubuntu.com/lts/serverguide/network-configuration.html.en
711
* https://netplan.io/
712
713
h2. Win10 Licensing Info
714
715
* https://www.windowscentral.com/how-change-product-key-windows-10
716
* https://www.tenforums.com/tutorials/49586-determine-if-windows-license-type-oem-retail-volume.html
717
* https://www.tenforums.com/windows-updates-activation/104569-win-10-activation-expiring-volume-license.html
718
719
h2. Python GTK Development Resources
720
721
* https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html
722
* https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Box.html#Gtk.Box.pack_start
723
* https://lazka.github.io/pgi-docs/Gtk-3.0/mapping.html
724
725
h2. cpufrequtils Governor Configuration
726
727
These instructions are intended for Ubuntu 16.04 and later (using systemd init).
728
729
* Check the available and currently set governors. Ubuntu has an โ€œondemandโ€ service that sets the governor to ondemand after boot.
730
<pre>
731
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
732
conservative ondemand userspace powersave performance schedutil
733
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
734
ondemand
735
</pre>
736
737
* Configure cpufrequtils to set the governor to performance at boot
738
<pre>
739
$ echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
740
GOVERNOR="performance"
741
</pre>
742
743
* Disable the automatic ondemand service. 
744
<pre>
745
$ sudo systemctl disable ondemand
746
</pre>
747
748
* Reboot.
749
750
* Now check that the governor is set to performance for every CPU:
751
<pre>
752
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
753
performance
754
performance
755
performance
756
performance
757
โ€ฆ
758
performance
759
performance
760
performance
761
</pre>
762
763
* Check current CPU speeds:
764
<pre>
765
$ watch -n 1 bash -c 'cpufreq-info | grep "current CPU frequency"'
766
</pre>
767
768
h2. rsync via ssh example
769
770
<pre>
771
$ rsync --info=progress2 -ahz --compress-level=9 -e "ssh -i ~/ryft-pat-f1.pem" data/ ryftuser@18.205.65.5:/ryftone/regression/pubmed/data/
772
</pre>
773
774
h2. Read Performance using AIO
775
776
Use this fio command (run from temp directory on disk in question) to measure max disk read performance:
777
778
<pre>
779
$ 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
780
</pre>
781
782
Note that DIRECT_IO is required when using AIO. (see also: https://askubuntu.com/a/991311/392271)
783
784
h2. Remove Source Files While Creating Tarball
785
786
This is handy as it saves on disk space.
787
<pre>
788
$ tar --remove-files -cf pictures.tar Pictures/
789
</pre>
790
791
h2. Linux Find and Remove Files
792
793
Find and remove files (even with spaces in the path) using case insensitive matching for the wildcard:
794
<pre>
795
$ find . -type f -iname "*.jpg" -print0 | xargs -0 rm
796
</pre>
797
798
h2. Convert ASCII hex to binary
799
This problem seems to come up every so often. There is no need for a one-off solution:
800
801
<pre>
802
$ xxd -r -p input.txt output.bin
803
</pre>
804
805
https://stackoverflow.com/questions/7826526/transform-a-hex-info-to-binary-using-linux-command
806
807
h2. Well Said
808
809
https://developers.slashdot.org/comments.pl?sid=12326098&cid=56908942
810
811
h2. Hex Editor
812
813
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.
814
815
Download from here: https://github.com/EUA/wxHexEditor
816
817
You'll need the latest version of libwxgtk<version>-dev package.
818
819
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.
820
821
Finally, to get it installed in the right place:
822
<pre>
823
sudo make install DESTDIR=/opt/local BINDIR=bin DATADIR=share
824
</pre>
825
826
h2. Preprocessor Fun
827
828
To invoke the preprocessor directly:
829
<pre>
830
gcc -E -DSOME_DEFINE=SOME_VALUE somefile.c 
831
</pre>
832
833
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."
834
835
h2. Convert Oversampled .flac to 16 bit 44.1 khz .flac
836
837
<pre>
838
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox {} -b 16 -r 44100 output/{/.}.flac"
839
840
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox -v 0.98 {} -b 16 -r 44100 output/{/.}.flac"
841
</pre>
842
843
h2. Aligned C++ STL Types
844
845
<pre>
846
#include <vector>
847
#include <boost/align/aligned_allocator.hpp>
848
849
template <typename T>
850
using aligned_vector = std::vector<T, boost::alignment::aligned_allocator<T, 4096>>;
851
</pre>
852
853
h2. Command line convert .png to .jpg
854
855
<pre>
856
$ for x in *.png; do convert $x $(basename $x .png).jpg; done
857
</pre>
858
859
You can also add the "`-quality 90`" option if needed.
860
861
h2. Determine CPU Family Name
862
863
<pre>
864
$ gcc -march=native -Q --help=target|grep march
865
</pre>
866
867
h2. Convert .flac to .m4a (AAC)
868
869
Requires `ffmpeg` built with libfdk_aac:
870
871
<pre>
872
$ /opt/bin/ffmpeg -i input.flac -vn -c:a libfdk_aac -vbr 3 output.m4a
873
</pre>
874
875
All together using `find` and `parallel` for magic:
876
<pre>
877
$ find . -type f -name "*.flac" | parallel -j16 "/opt/bin/ffmpeg -i {} -vn -c:a libfdk_aac -vbr 4 {/.}.m4a"
878
</pre>
879
880
h2. PyGObject
881
882
This is the magic needed to have stuff happen quasi asynchronously using PyGObject (GTK+):
883
884
<pre>
885
# Yield to the main loop temporarily
886
while Gtk.events_pending():
887
    Gtk.main_iteration()
888
</pre>
889
890
h2. FUSE Code
891
892
 *https://pastebin.com/wavKntiu
893
894
h2. Use Windoze Schtuffs
895
896
 * 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)
897
 * [[http://landinghub.visualstudio.com/visual-cpp-build-tools|MSVC Tools]] - compiler (seems to be the rough equivalent of `build-essential`)
898
 * [[https://docs.microsoft.com/en-us/sysinternals/downloads/procmon|Process Monitor]] - useful debug tool
899
  * https://www.codeproject.com/Articles/560816/Troubleshooting-dependency-resolution-problems-usi - example for using Process Monitor
900
 * http://download.microsoft.com/download/7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/wdexpress_full.exe - (required by wingtk below)
901
 
902
* https://github.com/wingtk/gvsbuild - haven't tried this yet but looks amazing... 
903
904
h2. Build Handbrake Git Build
905
906
Steps for building Handbrake using AOCC:
907
908
<pre>
909
$ source /home/dsorber/Downloads/aocc/setenv_AOCC.sh
910
$ export CC=clang
911
$ export CXX=clang++
912
$ export CFLAGS="-g -O3 -mtune=native"
913
$ export CXXFLAGS=$CFLAGS
914
$ cd ~/Downloads/HandBrake/
915
$ rm -rf build/
916
$ ./configure --prefix=/opt --enable-x265 --enable-fdk-aac --gcc=/home/dsorber/Downloads/aocc/AOCC-1.1-Compiler/bin/clang
917
$ cd build
918
$ make -j17
919
$ sudo make install
920
</pre>
921
922
----
923
924
Regular build (18.04 and later):
925
<pre>
926
$ rm -rf build/
927
$ ./configure --prefix=/opt/local --enable-x265 --enable-fdk-aac
928
$ cd build
929
$ make -j17
930
$ sudo make install
931
</pre>
932
933
h2. Politically Correct Linux
934
935
* https://entertainment.slashdot.org/comments.pl?sid=11493671&cid=55759997
936
937
h2. This guy gets it
938
939
Regarding software purist ideology vs pragmatism
940
941
* https://linux.slashdot.org/comments.pl?sid=11156367&cid=55256437
942
943
h2. "Rotate" Video Playback via Metadata
944
945
<pre>
946
$ ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
947
</pre>
948
949
950
h2. Ubuntu Remove Old Kernels Oneliner
951
952
<pre>
953
$ 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)
954
</pre>
955
956
* [[https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu/571360#571360|Sauce]]
957
958
h2. Remove New Lines (command line)
959
960
For a file:
961
<pre>
962
$ tr -d '\n' < yourfile.txt
963
</pre>
964
965
Or for output of a command (e.g.):
966
<pre>
967
$ find . -type f -name '*.txt' | tr -d '\n'
968
</pre>
969
970
h2. Convert from .mp4 to .mkv Container
971
972
Use `avconv` to convert container without re-encoding:
973
<pre>
974
$ sudo apt-get install libav-tools
975
976
$ avconv -i filme.mp4 -c copy filme.mkv
977
</pre>
978
979
h2. Remove String From Many File Names
980
981
On Ubuntu use Perl rename utility, e.g.:
982
983
<pre>
984
$ rename 's/ \(1920x1080\) \[WaifuKenny\]//' *.mp4
985
</pre>
986
987
h2. Change Default Text Editor
988
989
I always have to Google this...
990
991
<pre>
992
$ sudo update-alternatives --config editor
993
</pre>
994
995
h2. Linux View System RAM Speed
996
997
View RAM speed (actual) on Debian/Ubuntu/Mint:
998
999
<pre>
1000
$ sudo lshw -short -C memory
1001
H/W path                      Device      Class          Description
1002
====================================================================
1003
/0/0                                      memory         64KiB BIOS
1004
/0/b                                      memory         32GiB System Memory
1005
/0/b/0                                    memory         [empty]
1006
/0/b/1                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
1007
/0/b/2                                    memory         [empty]
1008
/0/b/3                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
1009
/0/d                                      memory         768KiB L1 cache
1010
/0/e                                      memory         4MiB L2 cache
1011
/0/f                                      memory         16MiB L3 cache
1012
</pre>
1013
1014
h2. Linux Memory Schtuff
1015
1016
* [[https://github.com/jbert/exmap|exmap]]
1017
* https://jameshunt.us/writings/smaps.html
1018
* https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
1019
* http://bmaurer.blogspot.com/2006/03/memory-usage-with-smaps.html
1020
1021
* https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
1022
1023
* From: http://stackoverflow.com/questions/24484481/entry-in-proc-meminfo
1024
<pre>
1025
  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.
1026
</pre>
1027
1028
1029
* From: http://unix.stackexchange.com/questions/56879/tracking-down-missing-memory-usage-in-linux
1030
1031
  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).
1032
1033
  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.
1034
1035
 * [[http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html|Understanding memory usage on Linux]]
1036
1037
 * https://linux-mm.org/LinuxMM
1038
1039
h2. Reinstall grub on UEFI System
1040
1041
Reinstalling grub on a UEFI system is slightly different than on a traditional legacy BIOS system:
1042
1043
<pre>
1044
# Mount the primary drive root partition and the boot EFI partition
1045
sudo mount /dev/sda# /mnt            # Mount root (/) partition
1046
sudo mount /dev/sda# /mnt/boot       # Mount boot (/boot) partition (if separate from root partition; typically not)
1047
1048
sudo mkdir -p /mnt/boot/efi          # Create EFI partition mount point
1049
sudo mount /dev/sda1 /mnt/boot/efi   # Mount EFI partition
1050
1051
# Mount your virtual filesystems:
1052
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
1053
1054
# Chroot
1055
sudo chroot /mnt
1056
</pre>
1057
1058
Now, if you have networking you'll need DNS. If using `resolvconf` (for recent versions of Ubuntu):
1059
1060
# Edit ` /etc/resolvconf/resolv.conf.d/head` and add the following line (OpenDNS server).  Then save and exit:
1061
<pre>
1062
add nameserver 208.67.222.222
1063
</pre>
1064
# Next enable updates and update:
1065
<pre>
1066
sudo resolvconf --enable-updates
1067
sudo resolvconf -u
1068
</pre>
1069
# Now you should have DNS. Test by pinging something.
1070
1071
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.
1072
<pre>
1073
apt-get install grub-efi-amd64  # Install grub EFI bootloader (this should be all you need to do)
1074
1075
1076
# manual steps if you need them for some reason
1077
grub-install --recheck --no-floppy --force /dev/sda1  # Install grub bootloader in EFI partition
1078
1079
#####
1080
echo "configfile (hd0,gpt#)/boot/grub.cfg" > /boot/efi/ubuntu/grub.cfg # Tell grub to load grub.cfg from /boot
1081
1082
update-grub                          # Create grub menu list
1083
#####
1084
1085
exit                                 # Exit chroot
1086
</pre>
1087
1088
Reboot and you should be back in business.
1089
1090
h2. Convert flac to VBR mp3 using ffmpeg/lame
1091
1092
<pre>
1093
for file in *.flac; do name=$(echo $file | sed "s/\.flac//g"); ffmpeg -i "$file" -codec:a libmp3lame -qscale:a 0 "$name".mp3; done
1094
</pre>
1095
1096
h2. Create UEFI/legacy BIOS Bootable ISO
1097
1098
* http://askubuntu.com/questions/625286/how-to-create-uefi-bootable-iso
1099
1100
h2. Getting rEFInd to work on Mac OS 10.11
1101
1102
* http://mattjanik.ca/blog/2015/10/01/refind-on-el-capitan/
1103
1104
h2. Convert DTS 5.1 to FLAC
1105
1106
<pre>
1107
sudo apt-get install libdca-utils ffmpeg sound-juicer gnome-terminal easytag vlc 
1108
1109
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
1110
</pre>
1111
1112
Source: http://ubuntuforums.org/archive/index.php/t-1849260.html
1113
1114
h2. Windows Utils
1115
1116
* http://windirstat.info/download.html
1117
* https://www.raymond.cc/blog/safely-delete-unused-msi-and-mst-files-from-windows-installer-folder/
1118
1119
h2. SSH Security
1120
1121
https://stribika.github.io/2015/01/04/secure-secure-shell.html
1122
1123
h2. Windows 10
1124
1125
* http://ultimateoutsider.com/downloads/ - GWX Control Panel to disable GWX (Windows 10 update nagging)
1126
* [[https://www.safer-networking.org/spybot-anti-beacon/|Spybot Anti-Beacon]] - Disable Micro$oft "telemetry" data gathering from Windows 10, 8.x, and 7
1127
1128
<pre>
1129
The newest version of the KB3035583 update includes a background process which scans the 
1130
system's Windows Registry twice a day to see if the values for the four aforementioned registry 
1131
inputs were manually edited to disable the upgrade prompt. If they were, the process will alter 
1132
the values, silently re-download the Windows 10 installation files (about 6 GB in total), and 
1133
prompt the user to upgrade.
1134
</pre>
1135
1136
1137
h2. gpg-agent
1138
1139
* http://www.infrastructureanywhere.com/documentation/additional/mirrors.html
1140
1141
These instructions are geared toward reprepro but should be useful in general for setting up `gpg-agent`.
1142
1143
1144
h2. Resolve DNS While VPN Connected
1145
1146
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/
1147
1148
h2. Pretty Print Python Traceback
1149
1150
<pre>#!python
1151
import traceback
1152
1153
 ...
1154
1155
try: 
1156
    with open('/dev/null', 'w') as void:
1157
        rc = not bool(subprocess.call('modprobe -r {:s}'.format(mod_name), 
1158
                                      shell=True, stdout=void, stderr=void))
1159
except Exception as e:
1160
    print_failure_status()
1161
    exc_type, exc_value, exc_traceback = sys.exc_info()
1162
    print('\n')
1163
    traceback.print_exception(exc_type, exc_value, exc_traceback)
1164
    print('\n')
1165
</pre>
1166
1167
h2. Generating Random Data Files for Testing
1168
1169
One approach is to use /dev/urandom (non-blocking pseudorandom device):
1170
<pre>
1171
$ dd if=/dev/urandom bs=32M count=32 of=data_1GB.bin
1172
</pre>
1173
Unfortunately /dev/urandom is a bit slow. However, you can alternatively use openssl to generate pseudorandom numbers a bit faster:
1174
<pre>
1175
 $ openssl rand 1073741824 > data_1GB.bin
1176
 $ for run in {1..30}; do echo $run; openssl rand 1073741824 >> data_30GB.bin; done
1177
</pre>
1178
1179
h2. Cloning HDDs
1180 8
1181 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).
1182
1183
To clone a single drive to another identical drive (assuming sda is the source and sdb is the destination):
1184
<pre>
1185
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | sudo dd of=/dev/sdb bs=32M
1186
</pre>
1187
To clone to multiple drives all at once (assuming sda is the source and sdb, sdc are destinations):
1188
<pre>
1189
 $ 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
1190
</pre>
1191
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!
1192
1193
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.
1194
1195
h2. Generating ISOs
1196
1197
<pre>
1198
 $ genisoimage -R -J -o <output.iso> <some directory>
1199
</pre>
1200
To deal with long file names:
1201
<pre>
1202
 $ genisoimage -R -J -l -D -joliet-long -o <output.iso> <some directory>
1203
</pre>
1204
1205 2
h2. BIOS/grub
1206 1
1207 2
* http://forums.linuxmint.com/viewtopic.php?f=46&t=119832
1208
* http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html
1209
* https://wiki.archlinux.org/index.php/GRUB2
1210
* http://unix.stackexchange.com/questions/28443/does-grub2-support-putting-boot-on-a-raid5-partition
1211 1
1212
h3. Creating a BIOS Boot Partition on a GPT system
1213
1214
<pre>
1215
$ sudo parted /dev/sda
1216
(parted) mkpart primary 0 1024k
1217
(parted) set 2 bios_grub on
1218
</pre>
1219
1220 2
h2. Actiontec Router
1221
1222
* http://transition.fcc.gov/oet/ea/fccid/
1223
* http://opensource.actiontec.com/mi424wref.html
1224 1
1225
h2. Temp
1226
1227
https://www.grumpyland.com/blog/183/installing-software-raid-on-centos-567-via-ssh/
1228
<pre>
1229
# swap is on /dev/md1
1230
/dev/md1 none            swap    sw              0       0
1231
1232
# storage is on /dev/md0
1233
/dev/md0        /storage        xfs     noatime,barrier=0 0 0
1234
//faramir/production/sw /sw     cifs    username=samba,password=w00tw00t!,file_mode=0666,dir_mode=0777  0       0
1235
</pre>
1236
1237
----
1238
[[../|Back home]]