Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, October 26, 2013

wget

So a few days ago I was browsing a site

http://www.speedbicycles.ch/showBike.php?enr=442

and I wanted to download the images, but there are like 72 of them and I don't want to right click each one and save them. So I was thinking since I could use wget, but I don't want to download the whole site. I just want the pictures of this sweet looking bike! So I took a look at the URL for the images and sure enough they are all using a simple naming scheme (e.g. speed_001.jpg). So what immediately comes to mind is a bash script with a for loop calling wget to download all the images for me (because you know as programmers we are lazy).
#!/bin/bash
NUM=72

for ((i=1; i<=NUM; i++)) {

    if [ $i -lt 10 ]
    then
        ADD="http://www.speedbicycles.ch/bikes/442/bigPic/speed_00${i}.jpg"
        wget ${ADD}
    else
        ADD="http://www.speedbicycles.ch/bikes/442/bigPic/speed_0${i}.jpg"
        wget ${ADD}
    fi
}

I'm not saying that this is the only way to do this, it's just what came to mind when faced with the problem.

Tuesday, August 28, 2012

Adding Environmental Paths in Ubuntu Linux

I decided to work on some Android development project on Ubuntu. I had to switch because a library I was trying to use had to be built with the Android NDK. (Windows really took a dump on me when I tried to use Cygwin). Since this was my first install of Android and Java on my linux machine, I had to setup the PATHS in order for me to use them in terminal. Here is how to add them

#open your terminal and type
nano ~/.bashrc

#Add to the top of file: (remember you have to tell linux where the sdk directory is)
#for me, I had my SDK in the home/username directory represented by ~.
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

#press ctrl + X, then Y to confirm and ENTER to exit
#More than likely, you will need to restart
#When you open terminal, you should be able to 
#type 'android' without quotations and it should bring up SDK manager