2007-03-30
Posted in Geek Stuff, Web Wandering & Opinion
at 1:55
So you bought something nice, but now you have no money for eBooks… or maybe you hate DRM and don’t feel right about buying a paperback and then torrenting a digital copy. Well, there’s lots of help out there.
I don’t remember all of the free eBook sites I’ve bumped into and bookmarked over the years, but here are the ones I can remember right now:
And last, but certainly not least, don’t forget about Wikipedia: List of digital library projects. Enjoy them and let me know about any others you find.
Permalink
2007-03-26
Posted in Geek Stuff, Web Wandering & Opinion
at 1:54
Ok, you’ve probably heard the usual examples for visualizing how big IPv6’s address space is. 7 IP addresses for every atom of every person on Earth
gets the point across, but it’s not exactly very useful… so I decided to try something more practical.
Since I like to do my experimentation in a Python interactive interpreter, I’ll share the raw shell session. First, let’s get some data to work with:
>>> people_on_earth = int(6.5e9) # 6.5 billion (approximately)
>>> ipv6_range = 2**128 # 340,282,366,920,938,463,463,374,607,431,768,211,456
>>> habitable_planets_in_our_galaxy = int(30e6) # 30 million. An estimate from a SPACE.com article I read recently.
>>> cells_in_the_human_body = 10**14 # 100 trillion (Estimate from Science NetLinks via Ask Yakoo!)
Ok, now that we’ve got some frame of reference, let’s see if we can show how huge IPv6’s address space really is. First, there’s the traditional “addresses per person” count:
>>> ipv6_range / people_on_earth
52351133372452071302057631912L
Ok, what if we became galactic conquerors and put 6.5 million humans on every Earth-like planet in our galaxy?
>>> ipv6_range / people_on_earth / habitable_planets_in_our_galaxy
1745037779081735710068L
Oh! We mustn’t forget that some people have lots of computers…
>>> ipv6_range / 4 / people_on_earth / habitable_planets_in_our_galaxy
436259444770433927517L
Nor should we forget the little wireless gizmos like cell phones…
>>> ipv6_range / 16 / people_on_earth / habitable_planets_in_our_galaxy
109064861192608481879L
Hmm… Looks like it’s time to bring out the sci-fi “big guns”. What if every person was host to a colony of Internet-connected nanobots… one for each cell?
>>> ipv6_range / cells_in_the_human_body / people_on_earth / habitable_planets_in_our_galaxy
17450377L
Ok… what if we also had… The T-1000 Butlernator? (assuming 3 per person)
>>> ipv6_range / cells_in_the_human_body / people_on_earth / habitable_planets_in_our_galaxy / 4
4362594L
And in case you’re lost, that number shows how many galaxies could sustain such IPv6 usage before we’d run out. Enjoy!
Permalink
2007-03-04
Posted in Geek Stuff
at 17:02
Have you ever had a cronjob that needs to run as root, but you can’t do so easily because of the following reasons?
- /etc/crontab is managed by your package manager
- vixie-cron ignores /etc/cron.d/
- Root’s private “
crontab -e” crontab is easily overlooked when backing up /etc
- It needs some odd interval like “every 3 days”
Well, if your interval is evenly divisible into days, (“every 2 days” is OK, “every 1.5 days” is not) then I have just the solution. Create a new cron script in /etc/cron.daily, make it executable, and put the following inside it (For our example, I’ll use two days as the interval and “emerge –sync” as the command):
#!/bin/bash
TODAY=`date +%j`
if [ $((${TODAY#0} % 2)) == 0 ]; then
/usr/bin/emerge --sync > /dev/null
fi
It’s that simple. Here’s how it works:
- Once per day, the cron daemon calls the script
- The script calls `date +%j` and gets the “day of the year” (between 1 and 365, inclusive, or 1 and 366 if it’s a leap year)
- It then strips off any leading zeros to prevent “invalid number for given base” errors. (“085″ would be “invalid octal” by bash syntax.)
- The script does a “modulo 2″ operation on it (takes the remainder of integer division by 2)
- If there is no remainder, then the current date satisfies the “every second day” requirement and the command is run.
Because I chose the evenly-numbered days using “== 0″, a non-leap year will end with a two-day interval, rather than a leap year ending with the command being called two days in a row. Use “!= 0″ if you want to change this behaviour.
The “> /dev/null” ensures that only stderr messages (usually only errors) generate status emails. I use that to keep my admin mailbox uncluttered.
UPDATE: Oops. I forgot that bash is one of the many languages which uses a zero prefix to indicate octal. I’ve corrected the example.
Permalink