Saturday, November 15, 2014

Download Newspaper on Kindle by switching on RASPBERRY PI

In my earlier post I created a cron job on raspberry pi to download the newspaper via calibre on a pre defined time. (cron job is not enabled on RASPBMC by default. You need to enable it.).

But there could be times when you dont want to keep the raspberry pi switched on all the time just to wait till morning and let the cron job download the newspaper. The alternative is to schedule the job at startup. But again there is problem that there might be instances when i am working on some other thing on Raspberry and rebooting it mutliple time in a day. In that case my kindle will be flooded with the newspaper of same day.

Solution: I created a script to be scheduled at startup which will check the current time. If the current time is between 6:30 AM - 8 AM , the newspaper will download. Otherwise no.


Make the script executable. 

chomod +x /home/pi/scripts/time.sh

The above script can be schedule on Raspberry Pi (running RASPBMC) as follows - 

1. sudo nano /etc/rc.local
2. Add below line in the last of the file- just before exit.
    
   sh /home/pi/scripts/time.sh


Now if my RASPBERRY PI is not running over night then I just switch it on in the morning and get the newspaper delivered to my kindle.

Cheerz.

Tuesday, November 11, 2014

Enabling cron job in RASPBMC

Per default running cron jobs is deactivated in Raspbmc and there are two ways to activate them.

1. In the Raspbmc GUI under Programs -> Raspbmc Settings -> System Configuration -> Service Management -> Cronjob Scheduler

2. Via SSH/FTP by modifying sys.service.cron value to “true” the settings file under /home/<your_username>/.xbmc/userdata/addon_data/script.raspbmc.settings/settings.xml – for more infos on changing settings via SSH / FTP

-Cheers 

Sunday, November 9, 2014

Get IP of Raspberry Pi as soon it starts via PushBullet

1. First of all install curl not already installed.
2. Create a shell file with below code and replace <API> and <ID>

3. make it executable
chmod +x <filename>
4. Schedule at startup. Execute below command

sudo nano /etc/rc.local
5. Add below line. 
sh /home/pi/scripts/piip.sh

Friday, November 7, 2014

Headless Calibre Server for News–RASPBMC


First of all thanks to Kovid Goyal for the wonderful software called Calibre.
One of the best features of the Calibre is to fetch news from RSS feed and send it to my Kindle in most beautiful format.

The challenge: is that I cannot keep my laptop always on so that it can send the news on the predefined time.

Solution: Using my all purpose RASPBERRY PI for the purpose.

Steps :

1. Install Calibre

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install calibre

2. Ensure that the LANG variable is set. Just because mine was not set.

export LANG=en_US.UTF-8

3. Check if it is set correctly


locale

After editing a locale file, do not forget to re-generate the locales for the changes to take effect after reboot.

The locales that can be generated are listed in the /etc/locale.gen file: their names are defined using the format [language][_TERRITORY][.CODESET][@modifier]. To generate a locale, first uncomment the corresponding line in the file (or comment to remove); when doing this, also consider the localizations that other users on the system might need. For example, for American-English uncomment en_US.UTF.8 UTF-8. When done, save the file and generate the uncommented locale(s) by executing:


# locale-gen



4. Now since we are running the headless server and calibre don’t support is by default, hence we need to use xvfb. To use this we need to first install xvfb


sudo apt-get install xvfb

5. creating email.txt file which will contain all the email to which the email will be sent and saving it to /home/pi/scripts/ (the folder which I created in my earlier posts). One email per line in file.

6. Creating a fetch_news.sh file. (Thanks to https://gist.github.com/rogeliodh/1560289). I have modified the script a little and saving it to /home/pi/scripts/ 






7. Make the script executable


chmod a+x fetch_news.sh

8. Place the latest recipe file in the same folder i.e. saving it to /home/pi/scripts/ . If you are not aware where to get the latest version go to
https://github.com/kovidgoyal/calibre/tree/master/recipes
or you may also access the same on your PC in the zip file named “builtin_recipes” on below path C:\Program Files (x86)\Calibre2\resources

9. Run the (ba)sh file to check it.


cd /scripts
sh fetch_news.sh

10. Schedule the file to run – I am setting it to 6:30 AM every morning.


crontab -e

30 6 * * * /home/pi/scripts/fetch_news.sh

press ctrl + x and y to save the file.

Tip 1: Check the date and time before setting date and time

date

if time is not correct execute below command

date +%T -s "10:13:13"

Tip 2: If you are using the same Raspberry Pi for transmission download also, then you can schedule the reduced bandwidth (for example between 60:20 - 7:00 AM as in my case) so that Calibre dont face any issue while it downloads the News RSS.

Prevent Raspberry Pi (RASPBMC) from sleeping

Observing that the raspberry pi is going down after 30 min. if no activity done on the xbmc. The problem is that i have configured sickbeard + transmission also on my raspberry pi = 24 hours downloading box.

Follow below steps to prevent raspberry from going to sleep.

sudo nano /etc/kbd/config


edit these values to:
BLANK_TIME=0
POWERDOWN_TIME=0

-Cheers 

Saturday, April 12, 2014

Configuring Apple Time Machine backup on Windows / RASPBMC

 

This part 1 of the post will deal with the configuration of the time machine backup on windows 7 machine.

Steps involved -

1. Create image file on MAC OSX 10 + i.e. Maverick

Disk Utility -> New Image -> Save As: <filename> -> Mac OS Extended (Journaled) -> Image Format -> Sparse bundle disk image

I named it as TM

2. Then unmount the sparse bundle: by right click on the desktop or command

umount <path-to-sparse-bundle>



3. Now we will go the the Windows Machine and create a folder. I created a temp folder on Windows machine C Drive.


4. Connect the folder on MAC by right click on the finder and provided the IP followed by user name and password.


5. On MAC -Once the system is connected, i navigated to the temp folder and dragged it to the favourites for easy navigation.


6. Copied the TM sparse bundle file to temp folder


7. Then resize the file created in step 1.


hdiutil resize -size 100G /Volumes/users/multimedia/temp/TM.sparsebundle



NOTE: The resizing will not affect the actual size of the file as of now. It will only tell how much file can be expanded. In other words how large backup can be taken. For me i have a estimated backup of 40 GB so i configured the file as as 100 GB.


8. Now double click on the TM sparse bundle file from temp folder so that it gets mounted.


9. Once mounted i renamed it TM which was originally mounted as New Volume


10. Now I have a new path to take the backup i.e.


/Volumes/TM


11. Configure the backup on Time Machine on this new volume via below command.


sudo tmutil setdestination /Volumes/TM

Supply the password when asked for and done. Go to the Time Machine icon on top bar and choose backup now.


When you start Time Machine, it will create a Backups directory within the sparse bundle for your backups.


12. Add the sparse bundle to login item so that it gets connected automatically next time i login backup runs smoothly.


system preferences –> Users & Groups –> on the account you will login –> login item tab –> Click on small “+” to add the TM.sparsebundle file from the temp folder under favourite folders.  


For me it is working like a breeze.


Next time we will HACK raspberry pi for this.


-Cheerz

Thursday, February 6, 2014

Place a counter on video–Adobe After Affect

After affect is there to amaze me again. I had to host a video which keep on running for a day or two in loop. Since the video was a multicast (and not video on demand), it was like a TV show, which keeps on running and anyone who logs in will watch the show from that moment and not the beginning.

I wanted to let the viewer know that amount of time left in the video so that he can wait for the next loop to start. AE comes to the rescue.

I used a wonderful script written by Dan 

Steps involved -

1. Open a new composition

2. Add the video

3. Add a text layer

4. On source text add the below code. Update line 2 as per the timer requirements. Its actually number of seconds.

image

 

 

Code ---

rate = -1;
clockStart = 300;

function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
clockTime = Math.max(clockStart + rate*(time - inPoint),0);
t = Math.floor(clockTime);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
min + ":" + padZero(sec)

Saturday, January 4, 2014

Pushbullet notifications from uTorrent

 

These steps can be used with any torrent client on windows which support post download “run program”

Download the latest package from here - http://dan-l.net/2013/02/12/pushbullet-desktop-application/

Source code of the application is given here

Then run pushbullet.exe and activate it by supplying the API key which you may get here https://www.pushbullet.com/account

Then open the uTorrent and go to options –> Preferences-> Advanced –> Run program

under run this program browser to the application (exe file) and then append it with --

note "uTorrent Notification" "%N is downloaded on Dell Laptop"

Now you may test a download.

 

Cheers.