Why So Scared

A blog about; Programming, Music and Random Stuff

Archive for June, 2009

Batch Rename Suffixes or Prefixes Terminal

Someone on a forum I regular asked how to batch rename suffixes within the terminal.

So The filenames;
filename.rar
filename2.rar
filename3.rar

Could have a suffix added like this;
filename_[sitename].rar
filename2_[sitename].rar
filename3_[sitename].rar

Suffix

for i in *.rar; do mv “$i” “`basename $i .rar`_[sitename].rar”; done

Prefix

find *.rar -exec mv {} [sitename]_{} \;

posted by Juo in tidbit and have No Comments

Using Scrubyt to Screenscrape

At http://www.warez-dnb.com/ Im working on a bit of Ruby code that when finished is going to make 20 second samples of every single post.

I decided the simplest way to do this would to have a bot that scraped the website for Rapidshare links, went away and downloaded the links, extracted them, made the sample and then uploaded them to our FTP server. (I did say simplest, not most elegant)

After a file is upload this PHP script tests if the samples are uploaded yet. http://www.whysoscared.com/php-function-check-if-a-file-or-url-exists

To make the Ruby script I needed something that could not only screen scrape the webpage but also login. I was using hpricot but then we decided to make Rapidshare links on Warez-DnB only show up to registered users.

require ‘rubygems’
require ’scrubyt’

#only the following parts should need editing
baseurl = “http://www.warez-dnb.com/”
username = “User”
password = “Password”

data = Scrubyt::Extractor.define do
fetch “#{baseurl}?action=login”
fill_textfield ‘user’, username
fill_textfield ‘passwrd’, password
submit
fetch “#{baseurl}?topic=672″
link ‘//div/code’
end

This is the script that will actually scan each page. Using Scrubyt is super simple first it fetches the login page at Warez-DnB fills the username and password field and submits. Now its logged in.

After this the plan is to use a loop based off the RSS feed to see if the post is in the listings category and extract the Rapidshare links.

Its in fairly simple stages at the moment but ill post the majority of the script when its completed.

posted by Juo in Programming, Ruby and have No Comments

Bagel Factory Bluetooth Advert

While waiting for my 12:53 train I opened my laptop to sync some music id downloaded last night to iPhone, I’ve got bluetooth enabled at the moment so I can tether my iPhone.

I was greeted with a none obtrusive Bluetooth notification from The Bagel Factory asking me if I wanted to accept the file they where sending me.

Bluetooth Notification
I don’t know about anyone else but I get extremely bored waiting for trains, curiosity and the fact I’ve never received such a request peaked my interest enough to click “Show”.

Bagel Factory Advert
I was greeted with a PDF offering me a Free Filter Coffee (when buying a bagel). I didn’t buy a bagel and I didn’t get the free coffee but I do like the idea of this.

I think advertising over technology can be exciting and its interesting that they are trying new things.

I know this isn’t an insanely interesting blog post, I just found it rather interesting :)


Tags:
posted by Juo in Random and have Comments (2)

The Lonely Island

I discovered this band when a friend played it “I Jizzed In My Pants”, they have an equally hilarious song.

Im On A Boat

I\’m On A Boat (ft. T-Pain) – Album Version

The group “The Lonely Island” also have an album out, you can download it here. Incredibad

Tags:
posted by Juo in Music and have No Comments

Essential Software – Caffeine

When I first got my Mac I was really annoyed with how it handles flash videos, when I played a flash video that was longer than the sleep time on my Mac it would always just go to sleep and end my video. Super annoying!

The solution, either wiggle the mouse ever now and again or install Caffeine, its is a tiny program (240 KB) that puts an icon in the right side of your menu bar. Its really simple, you click it to prevent your Mac from ever automatically going to sleep again, dimming the screen or starting screen savers. Click it again and the default settings are resumed.

Caffeine Off

Off

On

On

Holding down the Command key while clicking to show the menu.

The Caffeine Menu

The Caffeine Menu

I think this is an essential app for that does lots of downloading or streaming of flash based video, it couldn’t be any simpler and I cant think of any functionality that could usefully be added, oh and did i mention its free.

(5/5) Stars

Download it here

posted by Juo in Essential Software and have No Comments