Tech Notes

Apache: Disable Caching ======================= .htaccess: <filesMatch "\.(html|pl|php|js|css)$"> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </ifModule> </filesMatch> Bitcoin: Compile bitcoind ========================= git clone https://github.com/bitcoin/bitcoin.git cd bitcoin git tag | sort -V git checkout v0.17.1 git status ./autogen.sh ./configure --disable-tests --disable-bench // these tests you won't run take FOREVER to compile make check sudo make install Bitcoin: Limit bitcoind outbound rate (700 Kbps in this example) ================================================================ In BTC source: contrib/qos Verify it: :~/Downloads/bitcoin/contrib/qos$ tc qdisc show qdisc noqueue 0: dev lo root refcnt 2 qdisc htb 1: dev enp2s0 root refcnt 2 r2q 10 default 16 direct_packets_stat 3 direct_qlen 1000 :~/Downloads/bitcoin/contrib/qos$ tc class show dev enp2s0 class htb 1:11 parent 1:1 prio rate 700Kbit ceil 700Kbit burst 1599b cburst 1599b class htb 1:10 parent 1:1 prio rate 1Gbit ceil 1Gbit burst 1375b cburst 1375b class htb 1:1 root rate 1Gbit ceil 1Gbit burst 1375b cburst 1375b For Ubuntu-anything, since it uses NetworkManager instead of /etc/network/interfaces, put the script in /etc/NetworkManager/dispatcher.d, and add to it: # Only run this script on interface UP events interface=$1 event=$2 if [ $event != "up" ] then return 0 fi Bitcon: Mining Parameters ========================= [Pool, Antminer U3] sudo cgminer -o stratum+tcp://stratum.slushpool.com:3333 -u joz.U3 -p a --au3-freq 225 --au3-volt 800 [Pool, Antminer U3] sudo bfgminer -S antminer:all --set antminer:chip=BM1382 --set antminer:voltage=x775 --set antminer:clock=x0882 --set antminer:timing=0.0162 -o stratum+tcp://stratum.slushpool.co m:3333 -u joz.U3 -p a --no-local-bitcoin -L bfg.log [Real Solo, Antminer U3] sudo cgminer --au3-freq 225 --au3-volt 800 -o http://127.0.0.1:8332 -u joz -p ****** --btc-address 1JozTWyxK6x6dcxM1ei2ifAMboi6EGYvDd --btc-sig "Joz loves Strizzle v.much" 2>cg.log [Real Solo, Antminer U3] sudo bfgminer -S antminer:all --set antminer:chip=BM1382 --set antminer:voltage=x775 --set antminer:clock=x0882 --set antminer:timing=0.0162 -o http://127.0.0.1:8332 -u joz -p ****** --generate-to 1JozTWyxK6x6dcxM1ei2ifAMboi6EGYvDd --coinbase-sig "Joz loves Strizzle v.much" -L bfg.log [Real Solo, NewPac + Antminer U3] sudo cgminer -o http://127.0.0.1:8332 -u joz -p ****** --suggest-diff 32 --btc-address 1JozTWyxK6x6dcxM1ei2ifAMboi6EGYvDd --btc-sig "Joz loves Strizzle v.much" --gekko-newpac-freq 200 --api-listen 2>>cg.log [Real Solo, Compac-F + NewPac] sudo cgminer -o http://127.0.0.1:8332 -u joz -p ****** --suggest-diff 442 --btc-address 1JozTWyxK6x6dcxM1ei2ifAMboi6EGYvDd --btc-sig "Joz loves Strizzle v.much" --gekko-start-freq 200 --gekko-newpac-freq 200 --gekko-compacf-freq 345 --api-listen 2>>cg.log Bitcoin: Segwit Discount ======================== Segwit Fee discount is based on utxo address (sending FROM) Bitcoin: lncli commands ======================= lncli openchannel <node pubkey> <local amount> -- sat_per_byte <sats/byte on-chain fee> lncli closechannel <funding_tx> --sat_per_byte <sats/byte on-chain fee> lncli walletbalance lncli sendpayment --pay_req= lncli addinvoice <amt> qrencode -o <file_loc> 'data' lncli sendpayment --keysend -d <pubkey> -a <amt_sat> --data 7629168=$(echo -n "<text message>" | xxd -pu -c 10000) (7629168 = the three ASCII characters of the word 'tip' represented as an integer) CGI === In order to get a script to execute without error, you have to tell it to direct output to the browser rather than to STDOUT. In Perl, for example, this is done by setting the content type to text/html (only needs to be done once at the top of the file): print "Content-type: text/html\n\n"; # HTTP HEADER cgminer: JSON failed to decode GBT errors when solo mining ========================================================== This is due to unused COINBASE_FLAGS being removed as of Bitcoin Core v0.20.0 Edit cgminer.c: - if (!previousblockhash || !target || !version || !curtime || !bits || !coinbase_aux || !flags) { + if (!previousblockhash || !target || !version || !curtime || !bits) { /* Followed by flags */ + if (flags) { len = strlen(flags) / 2; pool->scriptsig_base[ofs++] = len; hex2bin(pool->scriptsig_base + ofs, flags, len); ofs += len; + } Chrome AdBlock: Hide twitter recommended people to follow ========================================================= twitter.com##div.wtf-module Chrome: Restore search engine keyword ===================================== When typing keyword and something else auto-completes, select that something else, and do shift+del Chrome: Disable Chrome's Print Dialog ===================================== add "--disable-print-preview" to the shortcut CSS: Centering Images ===================== style="margin:0px auto;display:block;" DOSBox ====== - The pixelshader you like (for Turbo C) is CRT.D3D - List of 8:5 Resolutions: 320 x 200 640 x 400 768 x 480 1024 x 640 1152 x 720 1280 x 800 1440 x 900 1680 x 1050 1920 x 1200 2048 x 1280 2304 x 1440 2560 x 1600 2880 x 1800 3840 x 2400 5120 x 3200 7680 x 4800 EditPlus: Default Font ====================== Courier New, Regular, 9 Ethereum Wallet =============== Since it's almost impossible to sync entire full blockchain now, sync it light, passing the following flags to the node software (geth): "Ethereum Wallet.exe" --node-datadir d:\Blockchains\Ethereum --node-syncmode light --node-cache 512 exiftool ======== Strip it all: exiftool -all= <file> Strip just GPS: exiftool -gps:all= <file> Exif GPS Coordinates ==================== Geotagged coordinates may look like: GPSLatitudeRef N GPSLatitude 34 2.80 0 GPSLongitudeRef W GPSLongitudeRefude 118 15.11 0 -- This is in "Degrees and decimal minutes" (DMM) format. Incorporating GPSLatitudeRef and GPSLongitudeudeRef into the coordinates (N&E being + and S&W being -), yields these true DDM coordinates: 34 2.80, -118 15.11 ...which can be input into Google Maps. Firefox: Stop video autoplay ============================ about:config media.autoplay.allow-muted = false Firefox: Mouse Wheel Scroll Speed ================================= general.smoothScroll.mouseWheel.durationMaxMS 500 mousewheel.acceleration.factor 5 mousewheel.acceleration.start 1 mousewheel.min_line_scroll_amount 1 Firefox: Enable GPU Acceleration & WebRender (GPU-based 2D rendering engine) ============================================================================ layers.acceleration.force-enabled = true gfx.webrender.all = true FLAC: Decompress entire directory ================================= for %f in (*.flac) do flac –d "%f" Ï Git: Remove Sensitive Data from Repository ========================================== >> git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' --prune-empty --tag-name-filter cat -- --all Optionally: >> echo "YOUR-FILE-WITH-SENSITIVE-DATA" >> .gitignore >> git add .gitignore >> git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore" >> git push origin --force --all To remove them from tagged releases: >> git push origin --force --tags Google Sheets: Add leading text to a formula result =================================================== =IF((C5-B5)>0,"+$"&C5-B5,C5-B5) GPG Verify Signature ==================== 1. Import the public key gpg --keyserver pool.sks-keyservers.net --recv-keys <Hex Key Address> (i.e., 0x54DDD393) 2. Verify the sig file gpg --verify "VeraCrypt Setup 1.19.exe.sig" Hiren's Boot CD on a Flash Drive ================================ Flash the ISO with UNetbootin, then in the HBCD folder rename isolinux.cfg to syslinux.cfg and copy it to the root, overwriting the original syslinux.cfg file. HxCFloppyEmulator: Convert floppy .raw to .img (or other) ========================================================= Load it in HxCFloppyEmulator and then Export it to your desired format iTunes Library on Different Partition (Windows) =============================================== You gotta hard link C:\Users\<username>\Music\iTunes to D:\Backup\iTunes: mklink /j iTunes D:\Backup\iTunes ...and don't forget the iPhone backups location: mklink /j C:\Users\<username>\AppData\Roaming\Apple Computer\MobileSync "D:\Backup\iPhone Backups" iTunes Download High-Res Album Art from Apple ============================================= 1. Search for it on the Apple Music website. 2. View the image 3. Change end of URL to desired res (ex: 1000x1000bb) -- For higher quality do 1000x1000-999 -- You can go even higher res like 10000x10000-999 to get art that is way bigger than your audio file! LAME: Quality ============= LAME: use VBR with -V 2 (--preset fast standard). V 3 through 5 are actually cool with me quality-wise, but anything above (below) V 2 includes the Y switch, which can deteriorate high frequencies (>=16Khz). Switch Preset Target Range Y Switch ------ ---------------------- ------ --------- -------- -b 320 --preset insane 320 320 CBR -V 0 --preset fast extreme 245 220...260 -V 1 225 190...250 -V 2 --preset fast standard 190 170...210 -V 3 175 150...195 Y -V 4 --preset fast medium 165 140...185 Y -V 5 130 120...150 Y -V 6 115 100...130 Y -V 7 100 80...120 Y -V 8 85 70...105 Y -V 9 65 45...85 Y 320 kbps CBR MP3s are a total waste of space because the only reason for mp3/aac/etc in the first place is saving space while maintaining great quality. The quality benefit of 320 kbps MP3s over 192 kbps VBR is almost 0, while the space requirement is 67% higher. For iTunes MP3 Encoder ---------------------- It uses the Fraunhofer MP3 encoder, which has different VBR settings. To create the equivalent of a LAME 192 VBR MP3, the settings in iTunes MP# Encodder are: Stereo Bit Rate: 160 kbps [x] Use Variable Bit Rate Encoding (VBR) Quality: Highest Sample Rate: Auto Channels: Auto Stereo Mode: Joint Stereo [ ] Smart Encoding Adjustments [ ] Filter Frequencies Below 10 Hz FLAC to MP3 a folder in Linux ----------------------------- This also copies over some ID3 tags: for a in ./*.flac; do < /dev/null ffmpeg -i "$a" -qscale:a 2 "${a[@]/%flac/mp3}"; done Minecraft [Mac]: "Unable to start Minecraft, if you are running from a dmg, please drag to Applications and try again" ====================================================================================================================== chgrp -R staff Minecraft.app chmod -R g+w Minecraft.app Opera: bold active tab on bottom ================================ C:\Program Files\Opera\skin\standard_skin.zip\skin.ini [Pagebar Button Skin.bottom.selected] ..add.. Text Bold = 1 MSSQL: Get all tables ============================= select * from INFORMATION_SCHEMA.TABLES MSSQL: Search for a column ========================== select COLUMN_NAME, TABLE_NAME from INFORMATION_SCHEMA.COLUMNS where column_name like '%MyColumn%' MSSQL: "Move" a table from one DB to another (on same instance) =============================================================== TRUNCATE TABLE table2; INSERT INTO table2 SELECT * FROM db1.dbo.table1; ...and to move only some stuff over: INSERT table2 SELECT * FROM table1 WHERE [Conditions] MSSQL: Copy a table from one DB to another ========================================== select * into DestDB.dbo.JnlPayments from SourceDB.dbo.JnlPayments MS SQL Server: Cannot open user default database. login failed. =============================================================== 1. Options -> Connect to database -> master 2. Login 3. alter login [username] with default_database = master PHP 7/FastCGI permission issues with sessions ============================================= /etc/php-fpm-7.3.d/www.conf listen.owner = www-data listen.group = www-data service php-fpm restart Q3A: Modify entities by extracting .ent file from map ===================================================== q3map2 -exportents q3dm16.bsp *edit* q3map2 -onlyents sz-q3dm13.ent Q3A: Decompile a map ==================== q3map2 -convert -format map q3dm16.bsp QL: Use q3map2 on QL ==================== add '-game quakelive' QL: Convert a Q3 map to QL ========================== q3map2 -game quake3 -convert -format quakelive cpm10.bsp QL: Map Levelshots ================== Make sure the jpeg is saved as non-progressive. QL: Map Thumbnails ================== Crop your levelshot to 1.33 AR, then resize it to 256x256, and it goes in levelshots/preview QL: Automatically Record Demos ============================== cg_autoAction 0/1 Steam Workshop Update ===================== steamcmd +login joz3d +workshop_build_item /home/joz/ShinaZ/ShinaZ_Pak.vdf +quit Snipping Tool: Change save extensions to lower-case =================================================== Search for value string 50 00 4E 00 47, and change the extensions in that correspondig text-string area to lower case. TiVo Desktop Plus: Fix "can't find the specified file" transfer errors ====================================================================== The TiVo service is sending expired cookies after valentine's day. Add the following line to the bottom of curl.conf*: cookie = "sid=abc" * The file is located in: Windows XP = %USERPROFILE%\Local Settings\Application Data\TiVo Desktop Windows Vista and later = %USERPROFILE%\AppData\Local\TiVo Desktop TrueCrypt: Minimum Container Size ================================= Minimum container size (FAT) must be +275 KB bigger than you want. (275 KB are eaten for some reason [by the file system I think] when creating it) Vim: Shrink tab size ==================== ~/.exrc set ts=4 Wikipedia: Find userid and edit count for a user ================================================ http://en.wikipedia.org/w/api.php?action=query&list=users&ususers=Joz3d&usprop=editcount WordPress: Remove title from home page and move content up to reclaim space =========================================================================== In style.css (of child theme if you have one): body.home #main { top: -30px; padding-top: 0; } .home .entry-header { display: none; } Wordpress: Change font size for posts only ========================================== In style.css (of child theme if you have one): .post { font-size: 18px; } Wordpress: Change font size for comments only ============================================= In style.css (of child theme if you have one): .comment p { font-size: 18px; } Linux: Change Time Zone ======================= ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime Set the ZONE entry in /etc/sysconfig/clock (e.g. "America/Los_Angeles") Linux: Beep =========== tput bel Linux: Extract contents of an RPM ================================= rpm2cpio package.rpm | cpio -dimv Linux: tar flag to including leading slash (absolute paths) =========================================================== P, or --absolute-names Linux: Find the biggest directories =================================== du (--exclude=[anydir]) | sort -n Linux: Find the biggest files in the directory ============================================== ls -lSrh Linux: Menu buttons in Gnome ============================ gconf-editor -> apps -> metacity -> general -> button_layout Linux: Mount Windows File Share =============================== mount -t cifs -o username=<username>,password=<pass>,file_mode=0777,dir_mode=0777,vers=2.0 //Host/Incoming /mnt/loc Linux: Cooler than uname ======================== neofetch Linux: Drive Diagnostics ======================== smartctl -a /dev/nvmeX SMART Info nvme smart-log /dev/nvmeX hdparm -Tt /dev/sdX Basic Read Speed dd if=/dev/zero of=/tmp/speed oflag=direct bs=128k count=16k Basic Write Speed Linux: Erase an SSD =================== hdparm --security-set-pass lol /dev/sdX hdparm --security-erase-enhanced lol /dev/sdX Linux: Erase a HDD ================== dd if=/dev/urandom of=/dev/sdc bs=1M status=progress Linux: Image a Partition (dd) ============================= dd if=/dev/sda2 bs=64K status=progress | gzip -c > /loc/of/backup/name.img.gz (Restore): gunzip -c /loc/of/backup/name.img.gz | sudo dd of=/dev/sda2 status=progress Linux: Image a Partition (partclone - which only copies used space) =================================================================== sudo partclone.ext4(.ntfs;.etc) -c -s /dev/src_partition | gzip -c > Image.pcl.gz (Restore): gzip -c -d /Backup/Image.pcl.gz | partclone.ext4 -r -o /dev/dst_partition Linux: Veracrypt Data Partition + Time Machine Partition on Same Disk ===================================================================== sudo fdisk /dev/sda (or whatever your backup disk is - THIS WILL ERASE ALL DATA ON IT) p - print partition table i - show partition info g - create gpt partition table n - new partition First sector: 2048 (for example) Last sector: 7333246975 (for example) n - new partition First sector: (default) Last sector: (default - should be last possible sector) t - change partition type (to fat) w - write table to disk and exit mkfs.fat /dev/sda2 *In Veracrypt create new volume against /dev/sda1 (for example)* *On Mac, go to Disk Utility, select desired Time Machine partition, format as APFS* *Open Time Machine and select the new APFS partition* Linux: Hide Grub menu with multiple OS's ======================================== /etc/default/grub GRUB_DEFAULT=0 GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=0 AND you have to edit /etc/grub.d/30_os-prober and comment out the adjust_timeout function call --because for some reason, you can see that adjust_timeout() forces the menu style and changes a 0s timeout to a 10s Now ESC will bring up Grub menu Linux: Add a raw disk to a VirtualBox virtual machine ===================================================== 1. Add yourself to the disk group sudo usermod -a -G disk <username> 2. Logout/in 3. Run Virtualbox as root (?) 4. Change permission to the physical drive sudo chmod o+rw /dev/sdx 5. Create a vmdk mapped to the raw disk VBoxManage internalcommands createrawvmdk -filename whatever.vmdk -rawdisk /dev/sdx 6. Add the vmdk to the VM. Linux: VirtualBox USB Passthrough iPhone ======================================== 1. sudo usermod -a -G vboxusers <username> 2. Logout/in (?) 3. Install VirtualBox Extension Pack to enable USB3 (xHCI) Controller 4. Connect your iPhone 5. Go to the VM's Settings --> USB and create a Device Filter for the iPhone (second option down with the green plus, so you can auto-create the filter based on what's currently connected) Linux: Creating a VM for Windows iTunes, with Data on Host ========================================================== Host://Media/Audio as a shared folder to VM://Z:\Audio (location of iTunes Library and all files) Host://Media/Backup/iPhone Backups as a shared folder to VM://Z:\iPhone Backups (location of iPhone backups) Shift+Click iTunes Select Z:\Audio\iTunes\iTunes Library.itl Cmd %appdata%\Roaming\Apple Computer\MobileSync (Apple Installed) -or- C:\Users\Name\Apple\MobileSync (Windows Store Installed) mklink /d Backup "Z:\iPhone Backups" Linux: Record Screen (Q3A) ========================== ffmpeg -f alsa -ac 2 -i pulse -f x11grab -y -r 60 -s 1920x1080 -i :0.0 -vf eq=gamma=1.45 -vcodec huffyuv out.avi Linux: Combine Vidoes ===================== Create a file with the source vid list: file 'vid1.mp4' file 'vid2.mp4' etc ffmpeg -f concat -i combine.txt -c copy newvid.mp4 Linux: Find out what is locking a drive from dismount/eject =========================================================== lsof | grep /mountpoint Linux: Find out which app is using which port ============================================= netstat -tulpn Linux: Tor Config ================= apt package: tor Point whatever you wanna tor to SOCKS port 9050 If it doesn't support SOCKS, use torsocks (apt package) $ torsocks <application> If you wanna use Nyx for tor session control/analysis (or anything else that requires a ControlPort): $ tor --hash-password <password> /etc/tor/torrc Uncomment "ControlPort 9051" line Also uncomment "HashedControlPassword" and put password from above there. Restart tor Electrum over Tor ----------------- ./electrum -1 -s electrums3lojbuj.onion:50001:t -p socks5:localhost:9050 -1 means connect to only a single node (best privacy, but must trust that node). Connecting without the -1 will connect to the specified node as the main node connection, along with 7 other nodes for block headers, nodes which will be a mix of onion and not. -s specifies a node to connect to -p flag helps when initially launching a first time install that isn't configured, so that it doesn't connect out to clearnet by default. Linux: Add OpenCL to FOSS amdgpu kmod on unsupported Linux release/kernel ========================================================================= 1. Download latest AMDGPU-PRO package from https://www.amd.com/en/support 2. change /etc/os-release to whatever version it bitches about 3. amdgpu-pro-install --opencl=legacy,pal --headless --no-dkms Linux: Enable overclocking on AMD video cards ============================================= /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="amdgpu.ppfeaturemask=0xffffffff" update-grub reboot Linux: Bring monitor back when using an Nvidia card + KVM ========================================================= apt install read-edid edid-decode sudo get-edid -m 0 > edid.bin # View the output of this command and verify you have the right monitor. # You can tell via the vendor, resolutions, serial number, all that jazz. cat edid.bin | edid-decode sudo mv edid.bin /etc/X11/edid.bin /usr/share/X11/xorg.conf.d/10-nvidia.conf: Section "Device" Identifier "Device0" Option "CustomEdid" "HDMI-0:/etc/X11/edid.bin" Option "IgnoreEDID" "false" Option "UseEDID" "true" EndSection (Will this work in /etc/X11/xorg.conf? - StackExchange user said it didn't for them) Linux: Service Manipulation Under systemctl =========================================== service --status-all systemctl disable tor.service Linux: Convert Pics =================== Single: convert image.png image.jpg Batch: mogrify -format jpg *.tga mogrify -format jpg -quality 90 *.tga Linux: Search within Zip Files ============================== for f in *.pk3; do echo "$f: "; unzip -l $f | grep -i <file>; done Linux: Get Radiant to start from menu ===================================== bash -c "cd /home/joz/Apps/GtkRadiant; ./radiant.bin" Linux: Tarball backup system essentials ======================================= sudo tar zcvf JozHome.tar.gz --exclude=.backup --exclude=Dropbox --exclude='Fast Data' --exclude=Media --exclude=.mozilla --exclude=Downloads/*.iso --exclude=.cache --exclude=.dropbox* --exclude=.links2 --exclude=Apps/tor-browser* --exclude=Desktop --exclude=fontconfig --exclude=Music --exclude=Public --exclude=Pictures --exclude=Templates --exclude=Videos --exclude=.config/BraveSoftware --exclude=.config/discord /home/joz /etc /usr/games/q* Linux: Properly change Window Manager to Compiz from Xfwm4 ========================================================== (If you use the widely recommended 'compiz --replace' as autostart, first of all that's a waste, secondly it will mess up keyboard shortcut bindings) Xfce starts the window manager specified in: /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml or, in Xubuntu: /etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml Replace the Client0_Command property: <value type="string" value="xfwm4"/> from 'xfwm4' to 'compiz' Linux: XFCE fix refresh rate reset when "disconnecting" ======================================================= /etc/udev/rules.d/10-screen.rules: ACTION=="change", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/joz/.Xauthority", RUN+="/home/joz/Apps/120hz.sh" /home/joz/Apps/120hz.sh: #!/bin/sh xrandr -r 60 # Do this rate 60 call because this actually wakes the display... xrandr -r 120 # ...then set the actual rate we want. sudo udevadm control --reload-rules Test: udevadm trigger Linux: Extract an AppImage ========================== ./your.AppImage --appimage-extract Linux: Setup rules to do stuff when plugging devices ==================================================== /etc/udev/rules.d (Everything require root): Make your own whatever number-device.rules: SUBSYSTEM=="usb", ACTION=="add", ENV{DISPLAY}=":0", ENV{HOME}="/home/user", ENV{ID_SERIAL_SHORT}=="<serial>", RUN+="/location/of/script.sh" SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_SERIAL_SHORT}=="<serial>", RUN+="/location/of/script.sh" udevadm control --reload ...use any of the ENV variables to identify devices. You can spy on what happens when you plug/unplug devices to see these variables by doing: udevadm monitor --env Linux: Make mounting work right in udev ======================================= // By default systemd-udevd creates its own filesystem namespace, // so the mount is not visible in the principal namespace) // Change this by creating: /etc/systemd/system/systemd-udevd.service containing: .include /usr/lib/systemd/system/systemd-udevd.service [Service] PrivateMounts=no then: sudo systemctl daemon-reload sudo service systemd-udevd --full-restart Linux: Mount remote fs over ssh (i.e., Web Server) ================================================== sshfs website.com:remote/dir mountpoint fusermount -u mountpoint Linux: Basilisk II Install sheep_net driver to enable network access ==================================================================== cd macemu/BasiliskII/src/Unix/Linux/NetDriver make sudo make dev sudo chown <user account> /dev/sheep_net sudo make install sudo modprobe sheep_net Linux: modprobe: ERROR: cound not insert 'whatever_module': Exec format error ============================================================================= Usually because the module is compiled against a different/older kernel version. Recompile it for your current kernel. Linux: Recognize Razer devices after kernel update ================================================== (You have to recompile the razerkbd kernel module against the new kernel) sudo dkms install openrazer-driver/2.5.0 (or whatever version of openrazer is installed) sudo modprobe razerkbd Replug razer devices razer-cli -l Linux: Modify file creation date ================================ touch -t YYYYMMDDhhmm.ss (-mt to change modified date) Linux: File manipulation loop ============================= for file in `ls *.viv`; do touch -r $file $file.mp4; done Mac: Reset NVRAM ================ Hold Command + Option + P + R on boot. Information stored in NVRAM includes: - Speaker volume - Screen resolution - Startup disk selection - Any recent kernel panic information Mac: Reset SMC (System Management Controller) ============================================= MacBook: Shut down, plug in power, press Shift (left) + Control + Option + Power, release all at the same time, turn on. MacBook (removable battery): Shut down, disconnect power, remove battery, hold power button for 5 seconds, release, reconnect battery, reconnect power, turn on. Non-MacBook: Shut down, disconnect power, wait 15 seconds, reconnect power, wait 5 seconds, turn on. SMC controls: - Fans - Lights - Power - Video - System Performance (if system is running slow even though CPU is free) Mac: Apple Hardware Test (10.7+)/Apple Diagnostics ================================================== Hold 'd' on boot. Mac: Boot into single user mode (terminal) ========================================== Hold Command + S on boot. Mac: Enable read/write FS in single user mode ============================================= mount -o update / Mac: Boot verbosely =================== Hold Command + V on boot. Mac: Black screen after booting (with cursor and notifications) =============================================================== (Login Window plist file got corrupted) fsck -fy mount -o update / cd /Library/Preferences rm com.apple.loginwindow.plist reboot Mac: Boot without checking system for OS compatibility ====================================================== Add the -no_compat_check kernel flag to /Macintosh HD/Library/Preferences/SystemConfiguration/com.apple.Boot.plist: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Kernel Flags</key> <string>-no_compat_check</string> </dict> </plist> Mac: Reclaim input devices after accidentally re-enabling SIP ============================================================= Boot into Recovery Mode. Disable SIP: csrutil status; csrutil disable On your OS partition: rm /System/Library/PrelinkedKernels/prelinkedkernel touch /System/Library/Extensions to create a new prelinkedkernel Mac: Enable NTFS writing ======================== Add the following to /etc/fstab and then umount/remount your drive. LABEL=”VOLUME_NAME_WITHOUT_QUOTES” none ntfs rw,auto,nobrowse Mac: SHA256 =========== shasum -a 256 <file> Mac: Encrypt a file =================== openssl enc -aes-256-cbc -in /Path/name.ext -out /Path/name.ext To decrypt: same, but just add '-d' Mac: Show dd Progress (verbose) =============================== ctrl+t Mac: dd with a nice progress bar since they don't have status=progress ====================================================================== brew install pv sudo dd if=/dev/disk2 | pv -s <size of copy, i.e. 128G> | sudo dd of=/dev/disk3 bs=4m Mac: Remove Spotlight Title Bar Icon ==================================== $ cd /System/Library/CoreServices/ $ sudo mv Search.bundle/ Search2.bundle/ Kill SystemUIServer Mac: Open a file with TextEdit from Command Line ================================================ open -e file.txt Mac: Drag a Window from Anywhere ================================ defaults write -g NSWindowShouldDragOnGesture -bool true cmd+ctrl+click n' drag Undo it: defaults delete -g NSWindowShouldDragOnGesture Raspberry Pi: Get Edimax EW-7811U WiFi adapter to stay online ============================================================= /etc/modprobe.d/8192cu.conf: options 8192cu rtw_power_mgnt=0 rtw_enusbss=0 Raspberry Pi: Change Clock to 12h + American Tool-Tip ===================================================== Clock Format: %I:%M %p Date Tooltip: %A, %b %d Raspberry Pi: Stop mouse from being placed on app menu button on startup ======================================================================== /home/pi/.config/lxsession/LXDE-pi/autostart Remove the line: @point-rpi (you could probably modify the source of point-rpi/recompile to place the mouse cursor wherever you want on startup) Raspberry Pi: Disable Screen Blanking ===================================== /etc/lightdm/lightdm.conf Add in the [SeatDefaults] section: [SeatDefaults] xserver-command=X -s 0 -dpms Raspberry Pi: Backup SD Card (macOS) ==================================== diskutil list dd if=/dev/diskX of=~/SDCardBackup.dmg Restore: dd if=~/SDCardBackup.dmg of=/dev/diskX diskutil eject /dev/rdisk3 Windows NTFS ============ File Name Limit: 255 Total Path Limit: 260 Windows XP: List what programs are using what ports =================================================== netstat -abnv Windows XP: Extend a volume =========================== (yes for the primary drive): cmd; diskpart; list volume; select volume #; extend size=n; exit Windows XP: For Future Confusion Repair ======================================= Disabled APSDaemon (or whatever) from startup. This is for wirelessly syncing iPhone. Windows XP: Windows Explorer custom start folder ================================================ %SystemRoot%\explorer.exe /n, /e,C:\Incoming Windows Shutdown timer ====================== shutdown -s -t [seconds] Windows XP: Prevent an app from running ======================================= Control Panel -> Adminstrative Tools -> Local Security Policy -> Software Restriction Policies -> Additional Rules -> New Path Rule Windows Server 2003: Disable annoying shutdown/reboot ===================================================== gpedit.msc; computer configuration -> adminstrative templates -> system -> shutdown event tracker -> select "disabled"; cmd; gpupdate /force Windows 7: Add USB 3 Drivers to Installer ========================================= 1.) Create a folder on the system drive named "winpe". 2.) Inside of this folder create a folder named "usb3" and another folder named "mount". 3.) Get your USB 3 Driver (inf files, etc). 4.) Put the driver in the "winpe\usb3" folder you created. 5.) Grab the sources\boot.wim file from the Windows 7 install and put it in your "winpe" folder. 6.) Open an administrative console, navigate to your "winpe" folder, and execute these commands: dism /mount-wim /wimfile:boot.wim /index:2 /mountdir:mount dism /image:mount /add-driver /driver:usb3\nameofdriverhub.inf dism /image:mount /add-driver /driver:usb3\nameofdriverxhc.inf dism /unmount-wim /mountdir:mount /commit -or just add all the drivers in the folder- dism /image:mount /add-driver:"usb3" /recurse 7.) Copy/move the boot.wim file from the "winpe" folder back to the sources folder on the Windows 7 install, and you're ready to go! Windows 7: Delete Reserved Partition during Setup ================================================= On the first setup screen, press Shift+F10 for a command prompt. diskpart list disk select disk 0 clean create partition primary select partition 1 active format fs=ntfs quick exit Windows 7: Check if TRIM is enabled =================================== fsutil behavior query DisableDeleteNotify 0 = on 1 = off ...to enable/disable TRIM: fsutil behavior set DisableDeleteNotify 0/1 Windows 7: Stop Windows from Restarting Your Computer After Updates =================================================================== Regedit: HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU (WindowsUpdate, AU may not exist) In AU create/edit the key NoAutoRebootWithLoggedOnUsers (DWORD [32-bit] Value) to be 1. Windows 7: Windows Explorer custom start folder =============================================== %windir%\explorer.exe /e,D:\Incoming Windows 7: Remove Favorites from Windows Explorer ================================================= Change registry key: HKEY_CLASSES_ROOT\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder\Attributes from a0900100 to a9400100. Windows 7: Remove Libraries from Windows Explorer ================================================= Change registry key: HKEY_CLASSES_ROOT\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}\ShellFolder\Attributes from b080010d to b090010d. Windows 7: Remove Command Bar in Explorer ========================================= Need to modify Shellstyle.dll in your theme's folder. Default Aero: %windir%\Resources\Themes\Aero\Shell\NormalColor\ Classic theme: %windir%\System32 1. Download Resource Hacker and open Shellstyle.dll in it. 2. Go to "UIFILE -> 1 -> 1033". 3. Add following code after the line <style resid="FolderBandStyle">: <Element padding="rect(0rp,0rp,0rp,-28rp)"/> 4. Compile the script. 5. Save the file to a different location. 6. Back up the original Shellstyle.dll and replace it with your new one. 7. Reboot or log out/in. Windows 7: Sort files before folders in Explorer ================================================ HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell --> Delete BagMRU --> Delete Bags HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell --> Delete BagMRU --> Delete Bags Windows 7: Remove -Shortcut suffix from shortcuts ================================================= HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer Change the "link" binary value data to 00 00 00 00. Windows 7: Disable Zip Folders ============================== Delete: HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31} (need to do Permissions -> (Select) Administrators -> (Check) Full Control -> Advanced -> Owner -> Administrators -> (Check) Replace owner on subcontainers and objects) Windows 7: Create a hard link ============================= File mklink /h <link> <target> Folder mklink /j <link> <target> Windows 7: Disable Open File Security Warning ============================================= Internet Options -> Security -> Custom level... -> Miscellaneous -> Launching applications and unsafe files -> Enable IE will now complain each time you open it. To disable the complaint: [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Security] "DisableSecuritySettingsCheck"=dword:00000001 Windows 7: Change Taskbar Text Color ==================================== 1. Use "UniversalThemePatcher" to patch: themeService.dll themeui.dll uxtheme.dll 2. Take ownership of C:\Windows\Resources\Themes\Aero\aero.msstyles Find the file in the file manager, right click -> Properties -> Security (tab) -> Advanced -> Owner (tab) -> Edit -> Select Administrator or you -> Ok Ok Ok Ok... until you're out. 3. Use "Resource Hacker" to open c:\Windows\Resources\Themes\Aero\aero.msstyles 4. Go to VARIANT -> NORMAL -> 1033 5. Go to the menu Action -> Save resource as a *.res file ... 6. Save it. 7. Open it with a Hex Editor (I used "xvi32") 8. Go to the address 2DC75 9. Around there, a bit below, there should be 3 "FF"'s. Change them to whichever hex color you want. 10. Save the file from your Hex Editor. 11. Back in Resource Hacker, right click on 1033 and select "Replace Resource ..." 12. Select "Open file with new resource..." 13. Select the file you saved from the hex editor. 14. Select "1033". 15. Hit "Replace". 16. Save As... 17. Overwrite the original aero.msstyles. (C:\Windows\Resources\Themes\Aero\aero.msstyles) 18. Log off & log back on, or reboot. Windows 7: Old-style Alt+Tab ============================ HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer Create a new 32-bit DWORD on the right-hand side called AltTabSettings, and assign the hex value as 1. Windows 7: Get rid of OSPPSVC.EXE persistency after quitting Office =================================================================== HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform Create a new DWORD called InactivityShutdownDelay ...and set the value to a decimal number, which indicates the # of seconds after the last Office app is quit to kill OSPPSVC.EXE (300 is the recommended default). Windows 7: Find Default Web Browser =================================== HKEY_CLASSES_ROOT\http\shell\open\command (Default) Windows 7: Show all tasks services they host (command line) =========================================================== tasklist /svc Windows 7: Kill a task (command line) ===================================== taskkill /F /IM <name> Windows 7: Uptime (command line) ================================ systeminfo | Select-String 'boot time' Windows 7: Lots of system info on the command line ================================================== systeminfo Windows 7: Thumbnail Cache Location =================================== %localappdata%\Microsoft\Windows\Explorer\*.db (On WinXP the thumbs.db files were in the original files' respective folders) Windows 7: Rebuild Icons ======================== Kill Explorer cmd: %localappdata% del iconcache.db (may be hidden) Start Explorer Windows 10: Rename Home Folder ============================== 1. CMD as Admin > net user administrator /active:yes 2. Log into hidden Administrator account 3. Change C:\Users\username Folder to desired name 4. Computer Management > Users – Rename User Account to aforementioned desired name 5. Regedit > Find Next (F3) > C:\Users\Original Username > Edit Strings (roughly 3 or 4 results) to Use New desired name 6. Restart 7. Log into newly renamed user account 8. CMD as Admin > net user administrator /active:no Windows 10: Remove Navigation Pane extras from File Explorer ============================================================ Change the value of "ThisPCPolicy" string to Hide in each key: Pictures: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag Videos: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag Downloads: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag Music: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag Documents: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag Desktop: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag (need to create "ThisPCPolicy" for Desktop) 3D Objects is a little different: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace ^-- Delete: {0DB7E03F-FC29-4DC6-9020-FF41B59E513A} key under both of those Dropbox: HKEY_CLASSES_ROOT\CLSID\{E31EA727-12ED-4702-820C-4B6445F28E1A} Set System.IsPinnedToNamespaceTree value to 0. ...but getting rid of Quick Access also kills drag-and-drop from right pane to left, so make sure: Computer\HKEY_CLASSES_ROOT\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder DWORD value "Attributes" is a0100000, not a0600000. Windows 10: Extract Product Key =============================== wmic path SoftwareLicensingService get OA3xOriginalProductKey Windows: Do a sha256sum ======================= certUtil -hashfile <filename> SHA256 Windows Networking Commands =========================== net config workstation Basic info about workstation's network config net config server Basic info about a system's server network services ipconfig (/all) Detailed info about the system's TCP/IP config ipconfig /displaydns Show local DNS cache ipconfig /flushdns Flush local DNS cache net use Shows a list of network mappings Windows 7: Environment Variables ================================ Variable Typical Location -------- ---------------- %SYSTEMDRIVE% C:\ %HOMEDRIVE% C:\ %SYSTEMROOT% C:\Windows %WINDIR% C:\Windows %PROGRAMFILES% C:\Program Files %PROGRAMFILES(X86)% C:\Program Files (x86) %COMMONPROGRAMFILES% C:\Program Files\Common Files %COMMONPROGRAMFILES(x86)% C:\Program Files\Common Files (x86) %PROGRAMDATA% C:\ProgramData %USERPROFILE% %SYSTEMDRIVE%\Users\<username> %HOMEPATH% \path_to_user_profile %LOCALAPPDATA% %USERPROFILE%\AppData\Local %TEMP% %TMP% %LOCALAPPDATA%\Temp %PUBLIC% C:\Users\Public %LOGONSERVER% \\{domain_logon_server} %USERDOMAIN% Great Windows 7 Utils ===================== Active Captions HoverSnap (except for multiple monitor setups) WizMouse ClassicShell Performance Monitor Windows 10: Change Mouse Wheel Scroll Direction =============================================== 1. Mouse Properties -> Hardware -> Properties -> Details -> Hardware IDs -> VID*** entry (e.g. VID_045E&PID_0039 ) 2. Registry -> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID\ [Hardware ID from Step 1]\[whatever subcats]\DeviceParameters\FlipFlopWheel = 1 Windows: Convert Internal Drive to Windows-To-Go ================================================ Utilities --------- 1. Lexar USB Tool 2. Macrium Reflect 3. WinToUSB Instructions ------------ 1. Enter System BIOS, Boot Options: a. Disable 'Fast Boot' b. Set Boot Order to be USB, then Internal drive 2. Boot system regularly off internal drive 3. Plug flash drive in 4. Run lexar_usb_tool/BootIt.exe as admin a. Flip the removable bit on the flash drive (to mark the flash drive as a local drive so that Macrium Reflect can clone to it) b. Unplug/replug the flash drive 5. Use Macrium Reflect to clone the internal drive to the flash drive 6. Run WinToUSB to convert the flash drive to 'Windows To Go' 7. Boot off the flash drive!