Friday, May 30, 2008
Rails Conf -- Joel Spolsky
I really liked Joel's keynote at Rails Conf 2008. I have always read Joel on Software and thought he was a kool aid drinking Microsoft guy, but he did not come off as such. He was thoughtful and practiced. More later.
Saturday, May 17, 2008
Apple "regedit"/ changing Terminal.app default settings
There was not much on google for this. I recently clicked the "Use Settings as Defaults" in the "Window Settings" in Terminal.app for Mac OS X 10.4.11. This screwed me over because I was secure shelled into a remote machine at the time. What this did was save the last execution string in the Mac OS X defaults settings. So then every time I launched terminal, it would ssh into that last server! Bunk.
Well, I did not know about the whole "defaults" command in Mac OS X, I was looking for some config file in my home directory to no avail. Terminal.app is a system binary that squirrels away its settings in the internal os database. To fix this issue, you must access this internal database using the "defaults" process. Here is the exact syntax:
defaults read | less <------in less: hit '/' and type in: ssh -l, once you find the "section" label
defaults write com.Apple.Terminal ExecutionString ""
now we have knocked this problem out. This will also allow you to alter all kinds of things in your os.
Well, I did not know about the whole "defaults" command in Mac OS X, I was looking for some config file in my home directory to no avail. Terminal.app is a system binary that squirrels away its settings in the internal os database. To fix this issue, you must access this internal database using the "defaults" process. Here is the exact syntax:
defaults read | less <------in less: hit '/' and type in: ssh -l, once you find the "section" label
defaults write com.Apple.Terminal ExecutionString ""
now we have knocked this problem out. This will also allow you to alter all kinds of things in your os.
Wednesday, April 23, 2008
How to take a bootable CDROM image and allow a PXE client to boot from it
This took me awhile to figure this out. I had 30 clients that booted from a cdrom (they did not have an internal hard drive). They all ran the same cdrom image. When my company needed to expand, I thought it best to choose a thin client with no moving parts (this is a dusty dirty environment where the acidic dust wears bearings out!). The new thin clients have no hdd or cdrom, they must boot from the network. This cdrom image is proven over time and I wanted to continue to use it. Here is what I did:
Considerations: This is a linux/GNU environment, other OS are not considered.
1. Created a server to boot from (PXE server, DHCP server, NFS server)
2. Made a copy of the cdrom and mounted the copy, such as: # mount -t iso9660 /dev/cdrom /mnt/cdrom
3. Ensure /mnt/cdrom is readable by the world, such as: # chmod -R 754 /mnt/cdrom
TFTP/PXE setup
1. You will need to ensure that you have an initrd that will "do the right thing" when the linux kernel that boots from PXE. Here are the steps to manually recreate a initrd, this is not too hard:
a. Mount your initrd someplace, such as: # mount -o loop /boot/initrd /tmp/initrd
b. This image is read-only so you will need to copy it out and then edit it, such as: # tar cpvf initrd.tar /tmp/initrd && tar xvf initrd.tar /tmp/initrd_new
c. So now edit the 'linuxrc' or whatever your initrd uses as a 'init' script (the script that gets everything going).
d. when you edit this linuxrc, you will need to nfs mount the location that contains the files from the cdrom you mounted, such as: # nfsmount x.x.x.x:/mnt/cdrom
e. now create your new initrd image for use to pxe boot, such as: #mkfs.initrd initrd_new initrd
f. now put this initrd into where your pxe server expects it to be
FINALLY:
Reboot your computer into the same image that is tested.
Considerations: This is a linux/GNU environment, other OS are not considered.
1. Created a server to boot from (PXE server, DHCP server, NFS server)
2. Made a copy of the cdrom and mounted the copy, such as: # mount -t iso9660 /dev/cdrom /mnt/cdrom
3. Ensure /mnt/cdrom is readable by the world, such as: # chmod -R 754 /mnt/cdrom
TFTP/PXE setup
1. You will need to ensure that you have an initrd that will "do the right thing" when the linux kernel that boots from PXE. Here are the steps to manually recreate a initrd, this is not too hard:
a. Mount your initrd someplace, such as: # mount -o loop /boot/initrd /tmp/initrd
b. This image is read-only so you will need to copy it out and then edit it, such as: # tar cpvf initrd.tar /tmp/initrd && tar xvf initrd.tar /tmp/initrd_new
c. So now edit the 'linuxrc' or whatever your initrd uses as a 'init' script (the script that gets everything going).
d. when you edit this linuxrc, you will need to nfs mount the location that contains the files from the cdrom you mounted, such as: # nfsmount x.x.x.x:/mnt/cdrom
e. now create your new initrd image for use to pxe boot, such as: #mkfs.initrd initrd_new initrd
f. now put this initrd into where your pxe server expects it to be
FINALLY:
Reboot your computer into the same image that is tested.
Thursday, April 17, 2008
Deleting all messages in an Exim4 queue
All that is needed in this line is to substitute a pattern to find the messages you want:
mailq | sed -n '/\*\*\*/p' | awk '{print $3}' | xargs exim -Mrm
mailq | sed -n '/\*\*\*/p' | awk '{print $3}' | xargs exim -Mrm
Wednesday, March 26, 2008
Python: How to find a list of keys for a given value in a dictionary
Here is a straight-forward, easy to understand way to find a list of keys in a dictionary for a given value (that may or may not be in the dictionary)
def GetListOfKeysForGivenValueInDict(dictionary,value):
keys = []
for k,v in dictionary.items():
if v == value:
keys.append(k)
return keys
usage:
def GetListOfKeysForGivenValueInDict(dictionary,value):
keys = []
for k,v in dictionary.items():
if v == value:
keys.append(k)
return keys
usage:
dictionary = {1:2,3:4,5:4}
value = 4
keys_list = GetListOfKeysForGivenValueInDict(dictionary, value)
print keys_list
result:
[3,5]
Monday, December 3, 2007
How to write custom rules for spamassassin
How to configure the spam filter for custom rules
do you really need to do this?
answer: if the customer is getting spam that is solicted or unsolicted and it is not marked spam and the customer is concerned, then yes. It is best to leave the filter alone until really needed because the kind of change you will be making will be global
* Ssh into your mail server and gain root privileges
* edit /etc/mail/spamassassin/local.cf
* add filters to the bottom of the file indicating your filter text
* here is an example that would work for marking email containing the phrase "foo bar is king" as spam:
body NO_FOO /foo bar is king/i
score NO_FOO 5.0
* save off local.cf
* restart the spam filter as such:
/etc/init.d/spampd restart (this depends on your implementation)
do you really need to do this?
answer: if the customer is getting spam that is solicted or unsolicted and it is not marked spam and the customer is concerned, then yes. It is best to leave the filter alone until really needed because the kind of change you will be making will be global
* Ssh into your mail server and gain root privileges
* edit /etc/mail/spamassassin/local.cf
* add filters to the bottom of the file indicating your filter text
* here is an example that would work for marking email containing the phrase "foo bar is king" as spam:
body NO_FOO /foo bar is king/i
score NO_FOO 5.0
* save off local.cf
* restart the spam filter as such:
/etc/init.d/spampd restart (this depends on your implementation)
Monday, October 29, 2007
How to use rbot, svnwatch.rb plugin and post-commit to log svn commits to an IRC channel
I have not seen this all in one place so here it is: (Obviously if you do not know what I am talking about here, then you do not need this)
How to setup svn (subversion) logging when a commit is made
1. using Debian, issue this command as root: apt-get install rbot
2. using other Linux'es, install the ruby gem, first search for it: sudo gem list --remote rbot
3. pick the rbot you want (get the latest stable) and install the gem
4. run rbot, the first time you run it, rbot will check to see if you have a ~/.rbot directory, if not, then the setup script runs
5. answer most questions as the defauit. The questions you need to fill in are the irc user, the irc server, the irc channel to join
6. ensure the irc channel to join is in the format: #our_cool_channel somepassword
7. once rbot loads and starts running, check to see if the rbot user you made up actually joined the irc channel. If it did, continue, of not, then go back and troubleshoot
8. Shutdown rbot by sending a CTRL-c to the term, then start it back up in "daemon" mode: rbot -b
9. Add "svnwatch.rb" to ~/.rbot/plugins/ This file should be on RobbyOnRails somewhere, search for it
10. Add the post-commit file somewhere (also on RobbyOnRails) where apache can run it when a commit is made, I recommend something like /usr/local/bin
11. create a symlink to the post-commit script in the hooks directory of each svn project you will to run this post-commit script for
12. For example, I want to have a script log to the irc channel when a commit is made to liberty sweet. So I would: ln -s /usr/local/bin/post-commit /home/svn/src/cool_project/hooks/post-commit
13. What this does is run the post-commit in /usr/local/bin/post-commit which fires off a commit message (on port 7666 by default) to rbot, which is logged into the channel.
How to setup svn (subversion) logging when a commit is made
1. using Debian, issue this command as root: apt-get install rbot
2. using other Linux'es, install the ruby gem, first search for it: sudo gem list --remote rbot
3. pick the rbot you want (get the latest stable) and install the gem
4. run rbot, the first time you run it, rbot will check to see if you have a ~/.rbot directory, if not, then the setup script runs
5. answer most questions as the defauit. The questions you need to fill in are the irc user, the irc server, the irc channel to join
6. ensure the irc channel to join is in the format: #our_cool_channel somepassword
7. once rbot loads and starts running, check to see if the rbot user you made up actually joined the irc channel. If it did, continue, of not, then go back and troubleshoot
8. Shutdown rbot by sending a CTRL-c to the term, then start it back up in "daemon" mode: rbot -b
9. Add "svnwatch.rb" to ~/.rbot/plugins/ This file should be on RobbyOnRails somewhere, search for it
10. Add the post-commit file somewhere (also on RobbyOnRails) where apache can run it when a commit is made, I recommend something like /usr/local/bin
11. create a symlink to the post-commit script in the hooks directory of each svn project you will to run this post-commit script for
12. For example, I want to have a script log to the irc channel when a commit is made to liberty sweet. So I would: ln -s /usr/local/bin/post-commit /home/svn/src/cool_project/hooks/post-commit
13. What this does is run the post-commit in /usr/local/bin/post-commit which fires off a commit message (on port 7666 by default) to rbot, which is logged into the channel.
Subscribe to:
Posts (Atom)
