Interest

October 26th, 2009

“Interest never sleeps nor sickens nor dies; it never goes to the hospital; it works on Sundays and holidays; it never takes a vacation; it never visits nor travels; it takes no pleasure; it is never laid off work nor discharged from employment; it never works on reduced hours; it never has short crops nor droughts; it never pays taxes; it buys no food; it wears no clothes; it is unhoused and without home and so has no repairs, no replacements, no shingling, plumbing, painting, or whitewashing; it has neither wife, children, father, mother, nor kinfolk to watch over and care for; it has no expense of living; it has neither weddings nor births nor deaths; it has no love, no sympathy; it is as hard and soulless as a granite cliff. Once in debt, interest is your companion every minute of the day and night; you cannot shun it or slip away from it; you cannot dismiss it; it yields neither to entreaties, demands, or orders; and whenever you get in its way or cross its course or fail to meet its demands, it crushes you.”  – J. Reuben Clark

The first 100 things to become scarce during an emergency

October 22nd, 2009

Found this list online. How is your supply of these?

1. Generators
2. Water filters/purifiers
3. Portable toilets
4. Seasoned firewood
5. Lamp oil, wicks, lamps
6. Coleman fuel
7. Guns, ammunition, pepper spray, knives, clubs, bats, slingshots
8. Hand can openers, hand egg beaters, whisks
9. Honey, syrups, white/brown sugar
10. Rice, beans, wheat
11. Vegetable oil (for cooking)
12. Charcoal, lighter fluid
13. Water containers
14. Mini heater head (propane) (Without this item, propane won't heat a room.)
15. Grain grinder (Non-electric)
16. Propane cylinders
17. Survival guide book
18. Lamp mantles: Aladdin, Coleman, etc. (Without this item, longer-term lighting is difficult.)
19. Baby supplies: Diapers/formula, ointments/aspirin, etc.
20. Washboards, mop bucket w/wringer (for laundry)
21. Cookstoves (propane, Coleman, kerosene)
22. Vitamins
23. Propane cylinder handle holder (Small canister use is dangerous without this item)
24. Feminine hygiene/haircare/skin products
25. Thermal underwear (tops and bottoms)
26. Bow saws, axes and hatchets, wedges (also, honing oil)
27. Aluminum foil -- regular and heavy duty
28. Gasoline containers (plastic and metal)
29. Garbage bags
30. Toilet Paper, Kleenex, Paper Towels
31. Milk (powdered, condensed: shake every 3 to 4 months)
32. Garden seeds (non-hybrid)
33. Clothes pins/line/hangers
34. Coleman's pump repair kit
35. Tuna fish (in oil)
36. Fire extinguishers
37. First aid kits
38. Batteries
39. Garlic, spices, vinegar, baking supplies
40. Big dogs (and plenty of dog food)
41. Flour, yeast, salt
42. Matches
43. Writing paper/pads/pencils, solar calculators
44. Insulated ice chests
45. Workboots, belts, Levis, durable shirts
46. Flashlights, lightsticks, torches, "No. 76 Dietz" lanterns
47. Journals, diaries, scrapbooks
48. Garbage cans (great for storage, water, transporting - if with wheels)
49. Men's hygiene: Shampoo, Toothbrush/paste, Mouthwash/floss, nail clippers, etc
50. Cast iron cookware
51. Fishing supplies/tools
52. Mosquito coils/repellent, sprays/creams
53. Duct tape
54. Tarps/stakes/twine/nails/rope/spikes
55. Candles
56. Laundry Detergent (liquid)
57. Backpacks, duffel bags
58. Garden tools and supplies
59. Scissors, fabrics, sewing supplies
60. Canned Fruits, Veggies, Soups, stews, etc.
61. Bleach (plain, NOT scented: 4 to 6% sodium hypochlorite)
62. Canning supplies, jars/lids/wax
63. Knives, sharpening tools: files, stones, steel
64. Bicycles, tires/tubes/pumps/chains, etc
65. Sleeping bags, blankets/pillows/mats
66. Carbon monoxide alarm (battery powered)
67. Board games, cards, dice
68. D-con rat poison, MOUSE PRUFE II, roach killer
69. Mousetraps, ant traps, cockroach magnets
70. Paper plates/cups/utensils
71. Baby wipes, waterless and antibacterial soaps
72. Rain gear, rubberized boots, etc.
73. Shaving supplies (razors, creams, talc, after shave)
74. Hand pumps, siphons (for water and for fuels)
75. Soy sauce, vinegar, boullion/gravy/soup base
76. Reading glasses
77. Chocolate/Cocoa/Tang/Punch (water enhancers)
78. "Survival-in-a-Can"
79. Woolen clothing, scarves/earmuffs/mittens
80. Boy Scout Handbook, Leaders Catalog
81. Roll-on window insulation kit (MANCO)
82. Graham crackers, saltines, pretzels, trail mix,  jerky
83. Popcorn, peanut butter, nuts
84. Socks, underwear, T-shirts, etc. (extras)
85. Lumber (all types)
86. Wagons and carts (for transport to and from)
87. Cots, inflatable mattresses
88. Gloves: Work/warming/gardening, etc.
89. Lantern hangers
90. Screen patches
91. Tea
92. Coffee
93. Cigarettes
94. Wine/Liquors (for bribes, medicinal, etc,)
95. Paraffin wax
96. Glue, nails, nuts, bolts, screws, etc.
97. Chewing gum/candies
98. Atomizers (for cooling/bathing)
99. Hats, cotton neckerchiefs
100. Goats/chickens

Removing Mailman list members with invalid addresses

October 7th, 2009

If you have a list member with an invalid address (I ended up with one that had 2 concatenated addresses, yielding 2 @ characters which the default parser apparently does not like), the regular bin/remove_members script won’t work. You can use this trick though:


cd /path/to/mailman
bin/withlist -l listname
>>> m.removeMember('foo@example.combar@example.com')
>>> m.Save()
>>> ^D

See the Mailman wiki for more details and other things to try if even this step doesn’t work.

Deleting sendmail file pairs based on content

September 2nd, 2009

This one-liner will identify files containing a string, and then use some bash string manipulation to generate a wildcard for the pair of files sendmail creates for each message (dfn for message content, and Qfn for headers). This assumes you’re running it in the mail queue directory (/var/spool/mqueue for example).


for f in `grep -l -i viagra *`; do t=${f:10:6}; rm -f *${t}; done

The ${f:10:6} extracts the last 6 characters of the filename, then the rm command prepends that with the wildcard.

Some sample output:


[root@mail mqueue]# grep -l -i cialis *
dfn7U8Rc3X020530
dfn7UD7BUh015512
dfn7VELCbV031687

But there are actually six files:


[root@mail mqueue]# ls -l | egrep "020530|015512|031687"
-rw------- 1 root smmsp 2062 Aug 30 01:27 dfn7U8Rc3X020530
-rw------- 1 root smmsp 2232 Aug 30 06:07 dfn7UD7BUh015512
-rw------- 1 root smmsp 2069 Aug 31 07:21 dfn7VELCbV031687
-rw------- 1 root smmsp 825 Aug 30 01:27 Qfn7U8Rc3X020530
-rw------- 1 root smmsp 837 Aug 30 06:07 Qfn7UD7BUh015512
-rw------- 1 root smmsp 810 Aug 31 07:21 Qfn7VELCbV031687

So we run the command, using cialis:


for f in `grep -l -i cialis *`; do t=${f:10:6}; rm -f *${t}; done

Then there are no more files :)


[root@mail mqueue]# for f in `grep -l -i cialis *`; do t=${f:10:6}; rm -f *${t}; done
[root@mail mqueue]# grep -l -i cialis *
[root@mail mqueue]#

One-liner to count current IP connections

September 2nd, 2009

A quick one-liner to show the IP addresses with an established connection to your server, sorted in order:

netstat -ant | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr

If you care only about a certain TCP port, say 80 for web traffic, the command becomes:

netstat -ant | grep :80 | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr

Output would look like:


36 14.21.23.10
8 14.21.23.107
7 14.21.23.114
6 14.21.2.34
5 14.21.23.108
5 14.21.23.106
5
2 14.21.13.120
1 14.21.2.23
1 14.21.13.147
1 14.21.13.130
1 14.21.13.128
1 14.21.13.122
1 14.21.13.118
1 14.21.13.112

Read the rest of this entry »

Cactus

June 26th, 2009



Cactus

Originally uploaded by brucetimberlake

Testing Flickr->WordPress connectivity…

This is a cactus that I saw in Anza-Borrego back in April while we were in San Diego for the girls’ Spring Break.

vim replace with newline

June 10th, 2009

Just a quick vi/vim tip that I’d never had to do before now.

Scenario: a file with multiple lines, each terminated with a semicolon, that needed to be broken out into separate lines for easier reading.

Solution:

In vim, use \r in the search-and-replace command to indicate a new line:

:%s/;/;\r/g

Email forwarding to multiple recipients with cPanel

February 26th, 2009

At first I thought I’d have to do something complicated like an email list. But I found out that you just have to create multiple single forwarder entries with the same “Address to forward” for each, and the different recipients in each “Forward to email address” field per entry.

Example:


boardofdirectors@example.com -> joe.blow@example.net
boardofdirectors@example.com -> jane.smith@example.org

sudo and local passwords vs SSH

February 12th, 2009

Just tracked down a problem with sudo at work. The error message

sudo: pam_authenticate: Module is unknown

would show up when doing “sudo su -”

An initial strace shows that libkeyutils was being looked for:

open("/lib64/tls/x86_64/libkeyutils.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/tls/x86_64", 0x7fffe8902810) = -1 ENOENT (No such file or directory)
open("/lib64/tls/libkeyutils.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/tls", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/lib64/x86_64/libkeyutils.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/x86_64", 0x7fffe8902810)   = -1 ENOENT (No such file or directory)

but was not installed on the server. A “correct” server shows:

[root@host ~]# rpm -qa | grep keyutils|sort
keyutils-libs-1.2-1.el5
keyutils-libs-1.2-1.el5
keyutils-libs-devel-1.2-1.el5
keyutils-libs-devel-1.2-1.el5

Without keyutils installed, the SSH keys we had set up weren’t able to be processed. PAM then fell back to local passwords, which was not set for the particular user in question.

Anyway, just hoping this helps someone else in the future.

Subversion repository structure for web applications

January 28th, 2009

If you are coding a lot of web applications, it helps to have a standard directory structure that you start with. That you always know where files should go, etc. This page contains my (current) take on the topic.

These steps assume you already have Subversion set up and working. If it’s on a remote machine, use the appropriate protocol designator (http://svn://, etc.) below where you see file://.

Alternatively, you could just put the directory creation commands into a script and run that script every time you needed to set up a new project. But we should all be using some sort of version control system, now shouldn’t we?

Just copy and paste the commands into a terminal session on your workstation or server, and that should be all you need to do to set this up. You will need to make some changes for your actual repository path and project names, of course. I’m just putting sample stuff in my examples.

Set up your desired directory “skeleton” in a temporary directory. Note that this uses a “shortcut” feature of <code>mkdir</code> that allows you to specify multiple subdirectories at once. The format is important – no spaces after the , etc.

cd ~
mkdir -p skeleton/{branches,tags,trunk/{data,db,doc,util,www/{include/{css,js},media/img}}}

You now have a directory system that looks like this:

/home/user
          /skeleton
                   /data
                   /db
                   /doc
                   /util
                   /www
                       /include
                               /css
                               /js
                       /media
                             /img

This will yield a website structure like this:

[web_root]
          /include
                  /css
                  /js
          /media
                /img

Of course you can add other directories as needed to further organize the website, but this will give you a good beginning, and help keep things organized. You will always know the path to CSS and Javascript files, regardless of where on the site you reference them in your HTML.

  • /data is where any “test” data goes that you need to prepopulate the project. This may not be relevant for the app you are building, so you could leave this one out.
  • /db contains SQL scripts used to create and populate any needed databases and tables. Be sure to add migration or update/upgrade scripts if the schemas change at some point during the project’s lifecycle.
  • /doc is for any and all project documentation. Be sure to paste important emails into text files and stash them in here!
  • /util is where any supporting scripts (Perl, shell, etc.) would go.
  • /www is the root dir for the website content.
  • /www/include is where any included files would go (think PHP’s require and include commands).
  • /www/include/css is where all your CSS files go. You are using CSS, right?
  • /www/include/js is where all Javascript goes. Javascript should be included in your HTML and PHP files via the <script src="...">, not inline.
  • /www/media should be pretty obvious. I like to use subdirectories for each media type to help keep things organized. Almost every project uses at least one image someplace, so I default to creating the /www/media/img directory in the skeleton. Later, if I need video, audio, flash, etc., I would make new subdirectories for them as well.

Once the directories are set up, I put some “marker” files in certain directories as well, which get filled in for the specific project once I start working on it:

cd ~/skeleton/trunk
touch FAQ HISTORY LICENSE README RELEASE-NOTES UPGRADE
touch doc/ABOUT

I also put empty index.html files into the various web directories, to prevent direct access to them when the project is deployed on a live server:

touch www/include/index.html
touch www/include/css/index.html
touch www/include/js/index.html
touch www/media/index.html
touch www/media/img/index.html

Set up a default CSS file (customize per your own experiences, needs, etc.) and stick it in the /include/css directory. See Five Steps to CSS Heaven for more ideas.

cd include/css
touch style.css

echo "/* Design and Code (c) Company Name, Inc. */" >> style.css
echo "html, body { padding: 0; margin: 0; }" >> style.css
echo >> style.css
echo "body {" >> style.css
echo "	font: normal 12px/1.5em sans-serif;" >> style.css
echo "	background: #fff; }" >> style.css
echo >> style.css
echo "/* Headings H1-H6 */" >> style.css
echo "h1 { }" >> style.css
echo >> style.css
echo "h2 { }" >> style.css
echo >> style.css
echo "h3 { }" >> style.css
echo >> style.css
echo "h4 { }" >> style.css
echo >> style.css
echo "h5 { }" >> style.css
echo >> style.css
echo "h6 { }" >> style.css
echo >> style.css
echo "/* Paragraph and Link Styles */" >> style.css
echo "p { }" >> style.css

cd ../..

Note that I use the “echo >>” mechanism rather than an actual file so that you can copy/paste all these commands and it will “just work” – no file editor needed at this stage.

Next, create a new project repository:

svnadmin create --fs-type fsfs /path/to/repos/projectname

Finally, import the directory structure into the project:

svn import ~/skeleton file:///path/to/repos/projectname -m "Initial project 'projectname' setup"

Gives this result:

Adding /home/user/skeleton/trunk
Adding /home/user/skeleton/trunk/HISTORY
Adding /home/user/skeleton/trunk/LICENSE
Adding /home/user/skeleton/trunk/www
Adding /home/user/skeleton/trunk/www/media
Adding /home/user/skeleton/trunk/www/media/index.html
Adding /home/user/skeleton/trunk/www/media/img
Adding /home/user/skeleton/trunk/www/media/img/index.html
Adding /home/user/skeleton/trunk/www/include
Adding /home/user/skeleton/trunk/www/include/css
Adding /home/user/skeleton/trunk/www/include/css/index.html
Adding /home/user/skeleton/trunk/www/include/css/style.css
Adding /home/user/skeleton/trunk/www/include/index.html
Adding /home/user/skeleton/trunk/www/include/js
Adding /home/user/skeleton/trunk/www/include/js/index.html
Adding /home/user/skeleton/trunk/www/index.html
Adding /home/user/skeleton/trunk/db
Adding /home/user/skeleton/trunk/doc
Adding /home/user/skeleton/trunk/doc/ABOUT
Adding /home/user/skeleton/trunk/RELEASE-NOTES
Adding /home/user/skeleton/trunk/UPGRADE
Adding /home/user/skeleton/trunk/FAQ
Adding /home/user/skeleton/trunk/data
Adding /home/user/skeleton/trunk/README
Adding /home/user/skeleton/trunk/util
Adding /home/user/skeleton/branches
Adding /home/user/skeleton/tags

Committed revision 1.

Your project is now ready to check back out and start working on:

cd ~
svn co file:///path/to/repos/projectname/trunk work

Gives this result:

A work/HISTORY
A work/LICENSE
A work/www
A work/www/media
A work/www/media/index.html
A work/www/media/img
A work/www/media/img/index.html
A work/www/include
A work/www/include/css
A work/www/include/css/index.html
A work/www/include/css/style.css
A work/www/include/index.html
A work/www/include/js
A work/www/include/js/index.html
A work/www/index.html
A work/db
A work/doc
A work/doc/ABOUT
A work/RELEASE-NOTES
A work/FAQ
A work/UPGRADE
A work/data
A work/README
A work/util
Checked out revision 1.

A final note — if you are using Subversion, DO NOT mess with the .svn directories anyplace within your project! When you are deploying the project to a web server (testing, production, etc.), you can just exclude them (use the -C switch for rsync, for example).

Keywords for the search engines: subversion repository directory structure template layout example sample recommended web app webapp application