I find myself needing this command every once in a while and I can never remember exactly how it goes. It parses through a directory (and subs) to give you a report on how many lines are in each file. It is great for working with csv files.
wc -l `find ./ -name '*.csv'`
I got this from an old post on Dev Shed forums that I participated in. I posted it here so I don’t have to keep seeking out the post every time I am trying to remember this command.
http://forums.devshed.com/showthread.php?p=1857692#post1857692
This is just a couple of good tools to find out if your server is allowing spammers to route mail through it. The nice thing about these tools is that you don’t have to know how a mail server works to test.
This first one will search a large number of major blacklists to see if your server is listed. Being blacklisted means that a number of sources have identified your server as a source of spam email. If you find yourself on one of these lists, it could be a good indication that your server is sending out spam.
http://www.mxtoolbox.com/blacklists.aspx
You can find out why you are blacklisted by a particular list by checking out their website (which is linked to in the report). Then you can repeal the listing to get your server taken off of the list. If you are listed you should definitely try to get your server off of the list, because being listed could severely reduce the delivery chances of legitimate email generated by your server.
The second tool analyzes your server by trying to connect to it in the same way a spammer would. If it does find an opening, you can have it actually try to send a message through your server, just like a spammer would (this requires you to register to the site). This is a surefire way to know if your server is capable of being abused for spamming. Because if you get the test message in your inbox, that means spammers can do the same thing.
http://www.abuse.net/relay.html
This is a function that will take a block of text and wrap hyperlink tags around anything that it recognizes as a link. It supports email addresses and anything that starts with http://, https:// or www.
It is implemented in Javascript but the regular expression code should be pretty universal.
function automagic_link(str) {
str = str.replace(/([^@ ]+)(@)([A-Za-z0-9.-]+)/gi, '$1@$3');
str = str.replace(/((http(s?):\/\/)|(www.))+([A-Za-z0-9./&=#?-~%;]+)/gi, 'http$3://$4$5');
return str;
}
This is a website that you can use to both format and optimize your css code. It can expand code so you can read and edit it or reduce your code to reduce size and increase performance. When optimizing it can even rewrite commands into the shorthand version, which is particularly nice.
http://www.cleancss.com
Here is a function to make sending email a little easier in Python.
import smtplib
import os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
def send_mail(to, subject, text, from="", files=[] cc=[], bcc=[], server="localhost"):
assert type(to)==list
assert type(files)==list
assert type(cc)==list
assert type(bcc)==list
message = MIMEMultipart()
message['From'] = from
message['To'] = COMMASPACE.join(to)
message['Date'] = formatdate(localtime=True)
message['Subject'] = subject
message['Cc'] = COMMASPACE.join(cc)
message.attach(MIMEText(text))
for f in files:
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(f, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
message.attach(part)
addresses = []
for x in to:
addresses.append(x)
for x in cc:
addresses.append(x)
for x in bcc:
addresses.append(x)
smtp = smtplib.SMTP(server)
smtp.sendmail(from, addresses, message.as_string())
smtp.close()
I got most of this code from the link below. I just cleaned it up a bit, re-prioritized the arguments and added support for both carbon copy (Cc) and blind carbon copy (Bcc).
http://snippets.dzone.com/posts/show/2038
I found this really good website for information about managing website crawlers using a robot.txt file (and meta tags). Really nice website with great information.
http://www.robotstxt.org
I have wanted to try out OpenOffice.org Base for some time now, but I have never taken the time to figure out how to make it connect to a relational database system. And as it turns out there doesn’t seem to be all that much documentation to help. Anyway I needed to figure out a way to look over the structure of a Microsoft SQL database and I didn’t have access to a Windows machine, let alone Enterprise Manager.
So OpenOffice.org uses JDBC to connect to various databases, but sadly it does not come bundled with any of the libraries required to connect and communicate. So after researching a little I came across jTDS. And with a little messing around I got it to work. Below is what I did.
-
First you have to download jTDS at http://sourceforge.net/project/showfiles.php?group_id=33291.
-
Second, uncompress the file and store it somewhere out of the way on your computer (such that you don’t accidentally move or delete it). You can store the whole folder or just the jtds-x.x.x.jar file.
-
Third, open up OpenOffice.org and go to Tools, Options…, OpenOffice.org (or NeoOffice), Java and then click on Class Path… and then Add Archive…. Choose the jtds-x.x.x.jar file and hit Open. Then keep hitting Ok until all preference windows are closed.
-
Fourth, you need to close and reopen OpenOffice.org for the change to take effect.
-
Fifth, open up Base and when the wizard comes up choose Connect to an existing database, choose JDBC from the dropdown and then hit Next.
-
Sixth, the Datasource URL is of the form below.
jtds:sqlserver://[host]:[port]/[database]
Replace [host] with the hostname of the server, replace [port] with the port that the database connects over (the default is usually 1433) and replace [database] with the name of the database.
-
Seventh, for the JDBC driver class put in the below.
net.sourceforge.jtds.jdbc.Driver
You can hit Test class if you want to. It should give you a promising message. After all of the fields are filled out hit Next.
-
Eight, on this screen you can fill out the authentication information. This should be pretty straight forward and you can test it to see that it is connecting properly. And then on the last screen you can set some final options and then save the local connected copy somewhere.
After that you should be able to see and browse the tables, build queries and have fun.
- - - - -
You can also use this jTDS driver to connect to Sybase. All you have to change the Datasource URL to this form.
jtds:sybase://[host]:[port]/[database]
- - - - -
For connecting to MySQL you can follow these same steps except you need to get the MySQL JDBC driver class from the MySQL website (http://www.mysql.com/products/connector/j).
The Datasource URL is:
mysql://[host]:[port]/[database]
And the JDBC driver class is:
com.mysql.jdbc.Driver
A fun feature from Lifehacker highlighting some great hidden goodies in popular software. My favorite is the therapist inside of Emacs (open emacs, hit escape and then type ‘xdoctor’ and hit enter).
http://lifehacker.com/371083/top-10-software-easter-eggs
Came across this on digg today. It is another reference sheet for common Linux/Unix commands and programs. It has a lot of good common uses of good programs like scp, rsync, svn, psql and mysql.
http://cb.vu/unixtoolbox.xhtml
This site is collection of free ebooks that are entirely written and maintained by the general public. It is an interesting ideas and some the books I perused through were quite well developed. Two nice things about this site is that all of the books are under a GNU license and a lot of the complete works offer pdf downloads (which is great for printing and taking the document with you).
It have texts on everything from language learning, to cookbooks, to children’s books. It is a part of the Wikimedia Foundation (which is best known for its Wikipedia project).
http://www.wikibooks.org