Sunday
May012011

Clean out old items from your Downloads folder using find & crontab

I got a bit lazy when it came to cleaning out my downloads folder. Old .DMG files, installer files and other detritus were bloating my Download folder so that the stack view in my Dock was becoming a pain to use.

I decided to adopt a bash script we run in the office at home to aid me in my quest for a tidy Downloads folder! By leveraging the find command in bash, a user can create a script that can find any files in a directory that match certain criteria, e.g. type, file name and date created/modified.

In my case, once found, the files will be deleted. Instead of using -mtime to determine age, you can also use -atime or -ctime. I'll leave it up to yourselves to read about that though! For a downloads folder and maybe for different file types,  -atime may be more appropriate for some of you. However, since I'm dealing with installer files, -mtime will suffice!

Once the script has been created, apply to your user crontab at whatever interval you so desire!

#!/bin/bash
#
#       Delete files older than 21 days in Downloads.
#
echo "Deleting (M)PKG, DMG and ZIP files that are older than 21 days in Downloads."
 
# Delete all (M)PKG's older than 21 days
find ~/Downloads/ -name "*.pkg" -type f -mtime +21 -delete
find ~/Downloads/ -name "*.mpkg" -type f -mtime +21 -delete
 
# Delete all DMG's older than 21 days
find ~/Downloads/ -name "*.dmg" -type f -mtime +21 -delete
 
# Delete all ZIP's older than 21 days
find ~/Downloads/ -name "*.zip" -type f -mtime +21 -delete
Sunday
Mar132011

Ruby Script: Remaining Mobile BB Data Allowance

I recently changed to Three.ie as my mobile broadband provider. They provide a nice handy way of checking remaining monthly data allowance via their "my3.three.ie" service. Signing in is handled automatically on their side based on the network you're using. Handy!

Since I've been messing around with Ruby a bit I figured I'd try and make a ruby script that would check my remaining data for me! My efforts are below!

Please comment on any improvements that you think I can make. Especially relating to the instance vs. class variables!

I use this script in combination with a bash script to display data on my desktop using GeekTool. The bash script attempts to ping the mobile gateway's IP address. If it is available, the ruby script is executed. Simples!

 

 

#!/bin/bash
#
#	Pings once to see if my Huawei B260a mobile gateway is reachable
#	if yes, execute Ruby data allowance checker
#	else, exit
#
ping -c 1 -t 2 192.168.4.1 >/dev/null
if [[ $? == 0 ]]; then
	ruby ~/Programming/Ruby/MyStuff/threeMobileBroadband.rb
else
	exit
fi

 

 

#!/usr/bin/env ruby
#
require 'rubygems'
require 'mechanize'

class ThreeMobileBroadband

@@baseURL = "https://my3.three.ie"
  
def login
  @agent = Mechanize.new

  # First Single Sign On page
  @landing1 = @agent.get 'https://my3.three.ie/myaccount/postPayFreeUnits.do'
  @landing2 = @agent.get @landing1.links[0].uri
  # Then click the continue button presented to get to account options section
  @@usagePage = @agent.post("#{@@baseURL}#{@landing2.forms[0].action}")
end

def getRemainingData
  # Parse for remaining data table
  @usageValue =  @@usagePage.parser.xpath('//div/div/div/div/table/tbody/tr/td').to_s
  # Get the data, and sub out HTML, then sub out whitespace, then split into array at a close bracket
  @data = @usageValue.gsub(/<\/?[^>]*>/, "").gsub(/\s+/, "").split(/\)/)
  return @data[1]#.inspect
end

def remainingDataAsOf
  # Parse for caption containing the date & time the remaining data was checked
  @asOfDate = @@usagePage.parser.xpath('//div/div/div/caption/span').to_s.gsub(/<\/?[^>]*>/, "").gsub(/\*\s+/, "")
  return @asOfDate
end

end

three = ThreeMobileBroadband.new
three.login

puts "3 Mobile Broadband Pro"
puts "-----------"
puts "#{three.getRemainingData} MB remaining\n"
print "#{three.remainingDataAsOf}\n"
puts "-----------"
Friday
Feb182011

Troubleshooting: Cisco 877 on Eircom ADSL2+

During the actual configuration of the Cisco 877s 2 weeks ago some issues arose which needed some debugging! All commands shown below were entered via global configuration mode.

 

Cisco 877 with a Linksys WAG160N on top!

DNS lookups and SSL connection issues:

Initially we had some issues with DNS lookups and connections to SSL secured services like HTTP and IMAPS. It turned out that I had failed to alter the MTU values! I didn't actually think that I had to! My bad!

 

The internal VLAN interfaces needed their maximum segment size (MSS) values  adjusted to compensate for the 8 extra bytes needed by the PPPoE header.

int vlan1
ip tcp adjust-mss 1452
exit

The GRE tunnel interfaces also needed some adjustment. This presented as being unable to access services on the other end of the VPN. Again, the MSS values needed to be lowered to account for the GRE header and IPsec headers.

 

int tun0
ip tcp adjust-mss 1300
exit

 

ADSL2+ sync problems

There was also some issues getting DSL sync and proper downstream/upstream speeds. Initially, with the ATM interface set to automatic, it was only getting 7meg down. To achieve the full speed I set the DSL operating mode explicitly to ADSL2+.

 

Still no joy though! I lost DSL sync. This was countered by setting the DSL sync mode to ANSI on the ATM interface. Once that was done, the DSL sync'd and proper speeds were achieved.

Below are the commands used on the interface.

int atm0
dsl sync mode ansi
dsl operating-mode adsl2+
exit
Monday
Feb072011

Configuring a Cisco 877 Integrated Services Router on Eircom Business Broadband

I decided to finally go ahead and get some Cisco gear!

To start off nice and easy, I elected to get some devices that would prove useful at home. To that end, I decided to get two Cisco 870 Series Integrated Services Routers. These would allow for me to experiment more with IOS out of college as well as providing some more security related services for Dad. Namely, a site-to-site VPN linking home with the office.

Click to read more ...

Friday
Feb042011

Collected thoughts on IPv6

So at 14:30 today (3/2/11) the IPv4 unicast address space was declared fully depleted.

ARIN (@TeamARIN), the body in charge of US Internet regulation released the blog post linked below.

http://teamarin.net/education/v6adoption/

Their post links to the summary of the event that occurred earlier today. It also contains links for an IPv6 specific wiki.

Click to read more ...

Saturday
Jan222011

My attempt at a #nowplaying app for Mac OS X!

For a video, click here :: http://www.twitvid.com/AWSBQ