Monday, September 30, 2024
Your encrypted data is locked on this device
Sunday, December 19, 2021
QEMU/KVM/virt-manager guest can't access network in bridged mode with iptables
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT # ip6tables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
Sound stops working in Linux
If your sound stops working in linux, you may see errors about being unable to connect to ALSA, or mplayer might say "Audio device got stuck!". If you don't want to reboot, killing pulseaudio will usually do the trick:
$ pulseaudio -k
Sunday, April 11, 2021
View all packages installed from overlay in Gentoo Linux
To easily view which packages were installed from which overlay, using app-portage/eix:
eix --installed-in-overlay <optional overlay name>
If you do not specify an overlay name, it will show all packages from all overlays.
Thursday, October 8, 2020
SQL Server Management Studio (SSMS) 18.x won't save server passwords
Starting around SSMS 18.x, Microsoft changed the way credentials were stored. This caused any saved passwords from previous versions to stop working in the server connection dialog popup.
To fix this, just delete the servers from the drop-down list. Alternatively, exit SSMS, clear out the saved servers in C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\18.x\UserSettings.xml and then restart.
If you use registered servers, the saved passwords will still work and will automatically be saved into the popup. If not, you'll have to type them in again.
Friday, October 2, 2020
Force Windows to use all available cores to process NGen queue
If it seems like mscorsvw.exe is running forever, you can use this script from the official .NET github repo to force ngen to process the queue using all available CPU power.
Monday, September 21, 2020
Copy & Paste does not work in Firefox on Google Docs
Please be aware that this is a global setting and allows all websites access to your clipboard, which is a potential privacy/security risk.
Prevent Gentoo Portage from unmerging kernel sources during a world upgrade
[kernels] class = portage.sets.dbapi.OwnerSet world-candidate = False files = /usr/src
Determining the manufacturer and recording medium of a blank CD or DVD
# cdrecord -atip
# dvd+rw-mediainfo /dev/sr0
SQL: Get just the date part of a DATETIME on SQL Server 2005
In Microsoft SQL Server 2008+ there is a DATE type, and getting just the date portion of a DATETIME is as easy as a cast or convert to DATE. But, at my job, we're still using SQL Server 2005. What then?
A common technique is to cast to a float, which gives you a number where the part to the left of the decimal point is the date and the part to the right of the decimal point is the time. Wrap that in a FLOOR function to round down to the nearest whole number and you have effectively truncated the time portion. You can then cast that back to a DATETIME.
I have, however, read that doing it that way can be inefficient as it won't use DATETIME indexes. Another approach that it supposed to be more efficient is to use DATEADD and DATEDIFF like so:
1 | SELECT DATEADD([dd], 0, DATEDIFF([dd], 0, GETDATE())); |
Again, there is no reason to do that unless you are on a Microsoft SQL Server version prior to 2008.
Easily straighten a crooked scan or photo in GIMP
To easily straighten a crooked scan or photo in GIMP, don't bother with manual rotation and rulers. Just use the Measure tool (Shift-M) and draw a line along a straight edge or horizon line of your image. Then click the "straighten" button and it will rotate the image to match the line you just drew.
Determining where a CD or DVD was manufactured
SQL: TRY_CAST alternative for old versions of SQL Server
In modern versions of Microsoft SQL Server there is a TRY_CAST function which returns NULL if the type cast fails, and returns the converted value if it succeeds. This is helpful if you're trying to format numbers from non-sanitized input and somebody put malformed data into a field.
At my job, I'm still dealing with SQL Server 2005 which does not provide this function. An alternative that I found online was to use XML to accomplish the same result:
1 | CAST('' AS XML).value('sql:column("ItemHeight") cast as xs:decimal ?', 'decimal(28,10)') |
SQL: Replace repeated spaces with a single space
1 | SELECT REPLACE(REPLACE(REPLACE('some string with many spaces', ' ', ' ' + CHAR(7)), CHAR(7) + ' ', ''), ' ' + CHAR(7), ' '); |
Rosetta Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | IT'S SHOWTIME HEY CHRISTMAS TREE f1 YOU SET US UP @I LIED TALK TO THE HAND f1 HEY CHRISTMAS TREE f2 YOU SET US UP @NO PROBLEMO HEY CHRISTMAS TREE f3 YOU SET US UP @I LIED STICK AROUND @NO PROBLEMO GET TO THE CHOPPER f3 HERE IS MY INVITATION f1 GET UP f2 ENOUGH TALK TALK TO THE HAND f3 GET TO THE CHOPPER f1 HERE IS MY INVITATION f2 ENOUGH TALK GET TO THE CHOPPER f2 HERE IS MY INVITATION f3 ENOUGH TALK CHILL YOU HAVE BEEN TERMINATED |
Bit-Twiddling Hacks
1 2 | #define SWAP(a, b) ((&(a) == &(b)) || \ (((a) -= (b)), ((b) += (a)), ((a) = (b) - (a)))) |