Today via Lobsters: Write code that is easy to delete, not easy to extend. I think I like programmingisterrible.com.
Tag Archives: change
Math keeps changing
An interesting article on lobste.rs today on the JavaScript Math implementation: Math keeps changing. The comic really resonated with me:
chvt
So today I read How To Switch Between TTYs Without Using Function Keys In Linux and learned about the `chvt` command which can change the virtual terminal on the host’s physical console. This is gonna come in handy!
pwned
I wrote the below BASH function today. It’s good because it performs super well compared to the alternative commands (which are commented out below above the new commands):
own() { echo "Taking ownership..." #chown -R jj5:jj5 . find . \! -user jj5 -or \! -group jj5 -execdir chown jj5:jj5 "{}" \; [ "$?" = 0 ] || { echo "Could not take ownership in '$PWD'."; exit 1; } echo "Fixing directory permissions..." #find . -type d -execdir chmod u+rwx "{}" \; find . -type d -and \( \! -perm /u=r -or \! -perm /u=w -or \! -perm /u=x \) -execdir chmod u+rwx "{}" \; [ "$?" = 0 ] || { echo "Could not fix directory permissions in '$PWD'."; exit 1; } echo "Fixing file permissions..." #find . -type f -execdir chmod u+rw "{}" \; find . -type f -and \( \! -perm /u=r -or \! -perm /u=w \) -execdir chmod u+rw "{}" \; [ "$?" = 0 ] || { echo "Could not fix file permissions in '$PWD'."; exit 1; } }
The basic premise is don’t do work which doesn’t need to be done!
Passing selected value into HTML select onchange handler
So you have a <select> element and you want to call a handler, but you need to pass the selected value to the handler because you have multiple instances of the same <select> and can’t access them by ID (because there is many, one of which will have the new selected value, but you don’t know which). The solution is to pass in the newly selected value, like this:
<select onchange='handle_change( this.value )'>
Easy-peasy!
Change user’s password in Kerberos with kadmin
To change a user’s Kerberos password (on charity):
sudo kadmin -p root -w `cat /home/jj5/kadmin_root_pass` -q 'cpw eguser'
Where ‘eguser’ is the username of the account being changed.
Change a user’s User ID on Mac OS X
Did this. Hope I haven’t fucked my computer!
info: mpt raid status change
Getting spammed courtesy my Debian VMWare image, notifying me of an “mpt raid status change”. Looked here and fixed the problem with:
# /etc/init.d/mpt-statusd stop # update-rc.d -f mpt-statusd remove
Change root password in MySQL
Needed to set a MySQL root password. Found this article which suggested a way when no password is yet configured:
mysqladmin -u root password NEWPASSWORD
And a way when a password is already configured:
mysqladmin -u root -p'oldpassword' password newpass
Note: you use ‘mysqladmin’ not ‘mysql’.
Setting user expiry with ‘chage’
Learned about the chage command today. Can be used to set the expiry of a Linux account. There’s some more information about disabling user accounts.