-
nsurl
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.
I’m back on Facebook. I probably won’t approve your friend request, however. This tends to upset people and oddly the people who get the most upset are the people with 1000+ friends.
Here are some reasons why I won’t be friends with you on Facebook:
– I don’t want people that I don’t know very well seeing my Wall or photos. At some point in the future, people may have an incentive to make me look bad and reducing the number of people that can access my Wall, and photos, is a good way to help solve that problem. I also don’t want to be worrying all the time about managing what people are tagging and posting to my Wall.
– When I have a small group of friends, all of the updates in my News Feed are from people I care about. It’s easier to keep up with everyone in my social group.
So that’s that. The problem is that a lot of people I know only have Facebook accounts, and use them as their omnibus social media/Internet presence and for these people, adding on Facebook is their way of connecting with me. I don’t see a good way around this problem.
The good news is that if you want to keep up with me, it’s pretty easy – I have a Twitter account, this blog, a quarterly newsletter, a Bitbucket account for sharing code I’ve written recently, a Delicious account for sharing cool links I’ve read lately, and a LinkedIn.
Also, there’s a good chance I’ll add you on Facebook if we’ve spent more than an hour hanging out sometime over the last year. I don’t ever reject anyone, just keep their request pending, in the hopes that we’ll hang out more in the future.
John Graham-Cumming wrote a good post about the same topic over a year ago. I tried to find it, but it’s been swallowed by the Internet.
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.
require 'uri'
require 'net/http'
require 'net/smtp'
def send_email(to, opts={})
# Send an email. In Ruby, the ||= operator means 'only assign the
# new value if the value has not been set yet'
opts[:server] ||= 'localhost'
opts[:port] ||= 25
opts[:ehlo_domain] ||= 'localhost'
opts[:username] ||= 'username'
opts[:password] ||= 'password'
opts[:from] ||= 'youremail@domain.com'
opts[:from_alias] ||= 'First Last'
opts[:subject] ||= 'Test email'
opts[:body] ||= 'This is a test!'
# the following says 'create a new string called msg containing everything
# from here to the END_OF_MESSAGE marker'
# then, we fill in the email with all of the values we filled in above. Note
# that there has to be a newline between the subject and the body of the
# message.
# This is a plaintext message - to send HTML emails, we would need a more
# complex template.
msg = <<END_OF_MESSAGE
From: #{opts[:from_alias]} <#{opts[:from]}>
To: <#{to}>
Subject: #{opts[:subject]}
#{opts[:body]}
END_OF_MESSAGE
Net::SMTP.start(opts[:server], opts[:port], opts[:ehlo_domain],
opts[:username], opts[:password], :plain) do |smtp|
smtp.send_message msg, opts[:from], to
end
end
# test for main method
if __FILE__ == $0
# the domain we want to check
url = 'http://testdomain.com'
my_email = "myemail@gmail.com"
r = Net::HTTP.get_response(URI.parse(url))
if r.code != "200"
# we have a big problem, server is down or other
opts = {
:server => 'smtp.yoursmtpserver.com',
:port => 587, # should be 25 or 587
:ehlo_domain => 'localhost', #this doesn't matter too much
:username => 'yoursmtpusername',
:password => 'yoursmtppassword',
:from_alias => 'testdomain.com Admin',
:subject => 'The website is down',
:body => "Hey,\nan attempt to reach the homepage returned " +
"the status code " + r.code.to_s() + ". \n\nYou should check it out."
}
send_email my_email, opts
end
end
That will send an HTTP request to your website. If the request was successful, you'll get an HTTP Header Response that says 'Status Code: 200 OK'. If we don't get a 200, this means the site is definitely wrong. We may get a 200 and still have problems with the database or other, but this is meant to be a simple test. Other well known codes are 404 (File Not Found), 500 (Internal Server Error), and 418 (I'm a teapot).
Once you've got the script in place, save it as "is_server_up.rb" somewhere on a computer which has lots of uptime (your school's CS server, a remote SSH server, or otherwise). Your laptop is a bad choice because when you close your laptop, or are not connected to the Internet, the test will not be able to run. The computer hosting your website is also a bad choice because if that computer goes down, your website will be down but the script will not run.
On a Linux or Mac machine, type
$ crontab -ewhich should open up a Terminal text editor. Then type:
0-59/2 * * * * /usr/local/bin/ruby /path/to/your/file/is_server_up.rbwhere
/usr/local/bin/rubyis the path to the Ruby executable on your laptop. If you don't know where it is, try typing "which ruby" in the Terminal. If nothing comes up, you probably need to download Ruby. The
0-59/2bit says to run the script every 2 minutes. You might be worried that fetching your homepage every 2 minutes will generate an extra 720 hits to your site every day and affect your Analytics stats. However, Analytics will only measure visits from browsers that can execute Javascript, and this Ruby script will not execute any Javascript, so you are safe. Note that if you have an important site, or one which generates revenue, you probably should not use this tool - there are better tools like Pingdom that will let you know right away whether your site is down.
Liked what you read? I am available for hire.
Liked what you read? I am available for hire.