Bracing against the wind  
www.documentroot.com  

Saturday, January 30, 2010

Given Molarity and Ka, Solve For PH

In water, when [H+] and [A-] are produced, [H+] and [A-] are approx equal (call it x). If Ka is very small compared to M (which it usually is), then you can usually reduce it to sqrt(M*Ka).

x^2/(M-x) = Ka
x = sqrt(M*Ka-Ka^2/4)-Ka/2
ph = -log(x)

Labels:


[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Wednesday, January 20, 2010

itoa

With the same sort of mild insanity that afflicts many standards making bodies, itoa has been removed from gcc.
char* itoa(int val, char *buf, int base) {
int m = sizeof(int)*(base >=10 ? 4 : 8)-1;
int i = m;
int j = 0;

if (base > 100 || base < 2)
return NULL;

if (val < 0) {
val = -val;
buf[0]='-';
j = 1;
} else if (!val) {
buf[0]='0';
buf[1]='\0';
return buf;
}

for(; val && i ; --i, val /= base)
buf[i] = '0' + (val % base);

for (;i < m; ++i, ++j) {
buf[j]=buf[i+1];
}

buf[j]='\0';
return buf;
}

[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Monday, January 18, 2010

Detected aborted journal

Got the error message "Detected aborted journal" and "Remounting filesystem read-only".

Since it was a remote server I wanted to fix it without rebooting to single user mode, or hopefully, not reboot at all.

# run fuser -v -m /home/ and shut down processes accessing drive (mounted as /home, extra slash needed)
fuser -v -m /home/
/etc/init.d/httpd stop
fuser -v -m /home/
# kill some bash process i'd left open
fuser -k -m /home/


# no more procs? ... unmount
umount /home

# ditch journal
tune2fs -O ^has_journal /dev/sda6

# fix drive
fsck /dev/sda6

# put back journal
tune2fs -j /dev/sda6

# remount
mount /home

# start needed services

/etc/init.d/httpd start
/etc/init.d/postgresql start


# pager goes off... "system back up"... yay

Labels:


[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Friday, January 15, 2010

List all perl modules that can be yum installed

I have to do this from time to time. Handy way to list all the perl modules needed to install. Useful when upgrading perl or building a new box.

List all modules needed by all code in the current directory:


grep "^use [A-Z]" * | perl -pe 's/\r//g; s/.*?:use //; s/ .+//; s/;[ \t]*$//;' | sort | uniq


Same as above, but massaged and piped to yum provides:


grep "^use [A-Z]" * | perl -pe 's/\r//g; s/.*?:use //; s/ .+//; s/;[ \t]*$//;' | \
sort | uniq | perl -pe 's/(.*)/perl($1)/' | \
xargs yum provides | grep -E '^([1-9]:)?perl' | perl -pe 's/^[1-9]://; s/ :.*//; s/-[0-9].*?$//' | \
grep -v perl$ | sort | uniq


Suitable for piping to xargs yum install....

Labels:


[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Tuesday, January 12, 2010

Convert Putty Key to OpenSSH

puttygen.exe can convert to openssh.

Working on making Ubuntu my desktop O/S at the office. Seems OK. The computer there was completely useless (hanging/crashing, didn't matter what Vista service pack I installed), now it's not (fast).

We'll see if I run into a situation where I need windows. I doubt it. The OpenOffice apps work way better than MS Office, etc.

[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Monday, January 11, 2010

ENOM DNS Outage Why and How

There are 2 reasons why ENOM is down.

The first is that it's easy to spoof UDP packets because consumer and commercial provider routers (botnet sources) don't filter inbound packets based on the list of expected subnets for that interface. Sounds confusing?

How about this: Anyone can easily fake the IP address they are coming from and their ISP won't notice because they are lazy about configuring things.

Routing involves looking at packets and sending them places. Safe routing ASLO involves looking at source addresses and refusing to accept them if they come from somewhere unexpected. After all, how much harder is it to do 2 lookups in 2 dynamic tables? Only twice as hard. But companies are lazy, and only do 1. Saving them very little money, but costing the world in reliability.

There was a class-action lawsuit that charged it was CISCO's responsibility to provide this by default (ddos-ca.org). The suit was dropped because of related concessions and developments by Microsoft. But CISCO/Linksys/Netgear failed to respond - and they still have failed. Their devices will all, by default, faithfully route spoofed botnet packets all day long - and so will most major ISP's with high end routers.

Tell me, is that ENOM's fault? No. It's the people who route spoofed packets fault - both router vendors and ISP's.

But the second is that ENOM fails to hand out DNS servers correctly. For 5 million domains, they should hand out about 100 ip's in groups of 5 IP's per user. Also, the servers should be "lots of inexepnsive" dns servers, not "a few big servers", which are an easy target.

Please read this for more information on properly distributing risk.

[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Thermohaline Thrash

Back from Hawaii, and it's so cold on the mainland!

Got me thinking it's a thermohaline thrash.

The "thermohaline cycle" allows warm, low density, low-salinity water to flow north while cold, dense and salty water flows south. This is why England, even though it's so far north, isn't frozen.

"Thermohaline thrash" would be a new wrinkle where carbon warming causes Greenland melting, which slows down the thermohaline flow by reducing the salinity of the arctic water, this makes for a cooler arctic air winter, but this then increases salinity by causing more freezing, which fixes the slowdown, causing a hotter summer further down the line. These seasonal waves of hot/cold can overlap and interact chaotically, causing extreme seasons of hot summers and cold winters.

Thrash (rapid chaotic flipping between two states) is typical of dynamic systems undergoing transition to a new stable state.

Just like the stock market, prior performance is not a good indicator of future.

My bet is that this Anthropocene period will have a lot of unique features. Thermohaline thrashing might be one of them.




[View/Post Comments] [Digg] [Del.icio.us] [Stumble]

Home | Email me when this weblog updates: | View Archive

(C) 2002 Erik Aronesty/DocumentRoot.Com. Right to copy, without attribution, is given freely to anyone for any reason.


Listed on BlogShares | Bloghop: the best pretty good | Blogarama | Technorati | Blogwise