Sunday 26 April 2015

Sublime text in "command mode"

 
I really love Sublime Text 3, it's very easy to use and powerful tool at the same time. One of the things that recently started to bother me is "command mode". Some how doing things I have done many times before like selecting word or string multiple times CRTL + D, edit them and quit the selection with ESC which is enabling "command mode". Something has changed in my setup I think, because I'm pretty sure that this did not happen before and for some time I just closed the file and reopened to get back in "insert mode". But after all, the solution was quite simple. i takes you back to "insert mode". Even better, at least in my case where I'm not using this "command mode", simply go to preferences -> settings-user and add following.
"ignored_packages":
[
    "Vintage"
]
Monday 13 April 2015

Taking and tweeting a photo with raspberry pi


At first I was going to create a timelapse of my cherry tree while blooming, then I decided to make a tweet once a day with a image.

Timelapse

Based on older post on how to make a Timelapse with Rapberry Pi camera module, I made small change. Rather than do a loop of x images I choose to use cronjob to run the script every 15 minutes. The script is simple and short.
#!/bin/bash

DIR=/home/pi/cherrytree
/usr/bin/raspistill -w 1920 -h 1080 -rot 180 -n -t 1000 -o $DIR/$(date -u +"%Y%m%d-%H%M-%S").jpg

Next add to your cronjob your interval, I use every 15 min.
*/15 * * * * /bin/bash /home/pi/cherry.sh >/dev/null 2>&1

Twitter bot

There's more than one way to cook an egg... There are also many ways to make a twitter bot.
I installed Twitter CLI
sudo apt-get install ruby-dev
gem install t
You will also have to create or have access to an twitter app to authorize the CLI interface.


Here is a simple script I use to take picture and tweet it. Every time I run this script, I just overwrite the image, but you can collect them by naming the file like in the script above.
#!/bin/bash
DIR=/home/pi/autotwitter
DATE=$(date -u +"%A %d %B %Y")
/usr/bin/raspistill -w 800 -h 460 -rot 180 -n -t 1000 -o $DIR/twitter.jpg
/usr/local/bin/t update 'Image of the day, '"${DATE}"'. #CherryBlossoms #raspberrypi #cli ' --file=$DIR/twitter.jpg
Once a day this script runs by cronjob at 12:01
1 12 * * * /bin/bash /home/pi/twitter.sh >/dev/null 2>&1
In addition to that, you can auto follow your followers in the same script by adding following line to the twitter script.
/usr/local/bin/t groupies | xargs /usr/local/bin/t follow