Example:
Thursday, August 18, 2016
Calculating date offsets with datemath
Example:
Monday, August 8, 2016
Use bleachbit to clear out unwanted file dregs
From: https://bbs.archlinux.org/viewtopic.php?id=131374
Monday, June 27, 2016
Getting support for BLU phones
Tuesday, November 3, 2015
Mount partition from multi-partition drive image
$ sudo fdisk -lu sda.img
...
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
...
Device Boot Start End Blocks Id System
sda.img1 * 56 6400000 3199972+ c W95 FAT32 (LBA)
Calculate the offset from the start of the image to the partition startSector size * Start = (in the case) 56 * 512 = 28672
Mount it on /dev/loop0 using the offset
$ sudo losetup -o 28672 /dev/loop0 sda.img
Now the partition resides on /dev/loop0. You can fsck it, mount it etc$ sudo fsck -fv /dev/loop0
$ sudo mount /dev/loop0 /mnt
Unmount$ sudo umount /mnt
$ sudo losetup -d /dev/loop0
Tuesday, September 29, 2015
JavaScript Contexts and Scopes
Basically, I wasn't using the "bind" function for my object references.
// Define the class. var Construct = Construct || (function() { // Constructor. var Construct = function(name) {}; // Additional functions. Construct.prototype = { sayHello: function() { alert("Hello"); } schedule_WRONG: function() { setTimeout(this.sayHello, 1500); }, schedule_RIGHT: function() { setTimeout(this.sayHello.bind(this), 1500); }, }; // Return the type. return Construct; })(); $(function() { // Construct the object. var f = new Construct(); f.schedule(); });
Friday, July 10, 2015
Disable debug logging in KDE 5
According to https://bbs.archlinux.org/viewtopic.php?id=193123 its an easy fix to disable debug logging although the kdebugdialog5 program doesn't actually do anything.
Add the lines:
QT_LOGGING_RULES="*.debug=false"
export QT_LOGGING_RULES
to /usr/bin/startkde near the top.Friday, April 17, 2015
Directing stdout and stderr
# Send stdout to sample.s, stderr to sample.err
myprogram > sample.s 2> sample.err
# Send both stdout and stderr to sample.s
myprogram &> sample.s # New bash syntax
myprogram > sample.s 2>&1 # Older sh syntax
# Log output, hide errors.
myprogram > sample.s 2> /dev/null
Thursday, April 9, 2015
Formatting code on blogger.com
<h1>Highlighted Python</h1> <pre class="brush: python; highlight: [5, 15]; html-script: true"> Python code goes in here </pre>
# Testing with Python here if x > 5: """ Print stuff """ print("x is more than 5") print("done")
These are the includes you can use.
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
Sunday, March 15, 2015
Playing DVDs in Arch
I've never had this much trouble before, most of my DVDs simply wouldn't play at all. I installed tons of libraries, cleaned scratches, nothing... And no error messages from any of several programs gave me a clue as to the problem.
Finally I found a post mentioning having no region set on a DVD drive. I found and downloaded "regionset" and sure enough that did the freaking trick.
~ $ regionset /dev/sr0
Current drive parameters for /dev/sr0:
RPC Type: Phase II (Hardware)
RPC Status: no region code set (bitmask=0xFF)
Vendor may reset the RPC 4 times
User is allowed change the region setting 5 times
Would you like to change the region setting for this drive? [y/n]: y
Enter the new region number for your drive [1..8]: 1
New RPC bitmask is 0xFE, ok? [y/n]: y
Region code set successfully.
After which everything played just peachy.
Thursday, February 5, 2015
Gnu Parallel
From: https://en.wikipedia.org/wiki/GNU_parallel
The idea is to convert code such as:
for x in `cat list` ; do
do_something "$x"
done | process_output
Into
cat list | parallel do_something | process_output
Another simple example someone posted on the Arch Wiki (s/printf/echo/):
printf "world\nasynchronous processing" | parallel "echo hello, {}"
hello, world
hello, asynchronous processing
Wednesday, February 4, 2015
OpenSSL: Find certificate whose CSR was generated by a given private key
It can be confusing to determine which certificate file and which private key go together if you don't know exactly what you are looking for. At least one way to determine whether a given key was used to generate the Certificate Signing Request of a given cert is to compare their modulus values (shortened/obscured by md5 hashing).
Show the value for the private key.
$ openssl rsa -noout -modulus -in private_key.key | openssl md5
(stdin)= cab197... some stuff ... c68caa2
Show the value for the cert.
$ openssl x509 -noout -modulus -in signed_cert.crt | openssl md5
(stdin)= cab197... same stuff ... c68caa2
If the values match they go together.
I got my certificates in a bunch of formats and couldn't figure out which to use, so I brute forced the solution:
$ for file in `ls *c[er][rt]` ; do echo -n $file && openssl x509 -noout -modulus -in $file | openssl md5 ; done
some_file.crt (stdin)= cab197... c68caa2
other_file.cer (stdin)= 2241f7... D08923
...
Convert ide bus to virtio in Windows guests on Proxmox
This is the exact procedure from http://forum.proxmox.com/threads/5248-Is-it-possible-to-convert-to-Virtio:
With "BUS" you mean IDE I suppose. Yes, it's possible, just you could risk that Win2008 ask you for a reactivation (hardware change can trigger it).
Sure on the wiki you find the answer, that is the same way you usually follow when installing as Virtio from the beginning.
In short, shutdown Win2008 and simply add a very small HD (like 1GB) with Virtio type to your Win2008 guest from web interface, and have the cdrom pointing to the ISO with the virtio drivers for kvm (latest and greatests, virtio-win-1.1.11-0.iso at the moment, see http://alt.fedoraproject.org/pub/alt...st/images/bin/).
Boot Win2008 that will detect the new 1GB HD and ask you for drivers. Install them (the ones in P { margin-bottom: 0cm; }'Wlh' dir on the .iso) and shutdown. Remove the additional hd AND your current HD (will be listed beyond as unused HD), and then re-add it picking it from the unused section, but this time with VIRTIO interface. Boot the VM and enjoy!
Of course, I don't take resposability for the success of the above, so do a backup first, just in case...
By the way, we have a VSphere setup here now, I have been messing with it for a week and it is HORRENDOUS by comparison to Proxmox as far as ease of use and administration. The interface is the most unintuitive jumbled unorganized thing I have ever seen. Now I grant you that I am still new at it, but things that are SO obvious on proxmox are either difficult or impossible on VCenter.
There are many different interfaces for doing the same things, some options are allowed some places not others, its really confusing.
Tuesday, February 3, 2015
Copy contact between address books in Thunderbird
"Hold down the Ctrl key at the same time as you drag and drop the contact record from one book to another in order to copy rather than move the data."
Thank you to http://forums.mozillazine.org/viewtopic.php?f=39&t=1970171