Push a file to your Smartphone

This is a quick tip. If you need to push a notification to your smartphone, or even send a file, I recently stumbled upon "Pushbullet".
I was looking for a solution to send a file (with automatic download) to my phone, via bash script on my raspberry pi. I've been using pushover for a while, but as far as I know, it doesn't support files

I have read the Pushbullet API, and came to realise that sending a file have 3 steps

1. Getting credentials to send the file
2. Upload the file to a remote server
3. Send a notification of "file" type with the download url

Of course, you can do 1 and 2 youself if you have access to a place which stores the file (I also managed to send a dropbox download link)

You need to sign up for Pushbullet via web, to get the api key, and also install the app on your smartphone (obviously)

So here is the bash script (It's not elegant - but it works)
Continue reading "Push a file to your Smartphone"

Share

GDoc/LaTeX compilation GUI with Tkinter/Python [w/ code]

¡Hola mis amigos!
I'm learning spanish, but I'm also annoyed with collaborating on LaTeX papers. That's why I've created the GDoc-LaTeXifier so the syntax will be clear when I collaborate on a paper with a remote friend.
But now we both want to compile a PDF on our machines. So I've created the tiny shell script that downloads the paper and runs PDFLaTeX.
The problem is that this opens a new terminal window and runs the script. I've been able to sort it out so that it closes the terminal window when it's done, by on my friend's mac it doesn't, so he ends up with a ton of open windows.
Enter - the GDoc/LaTeX compiler GUI.
Continue reading "GDoc/LaTeX compilation GUI with Tkinter/Python [w/ code]"

Share

Reading a directory in C++ (Win32 & Posix)

Just a snippet of code if someone out there needs it. I keep coming back to it, so I thought why not share it...

#include <iostream>

#ifndef WIN32
#include <dirent.h>
#endif

using namespace std;

void open_imgs_dir(char* dir_name, std::vector<std::string>& file_names) {
	if (dir_name == NULL) {
		return;
	}

	string dir_name_ = string(dir_name);
	vector<string> files_;

#ifndef WIN32
//open a directory the POSIX way

	DIR *dp;
	struct dirent *ep;     
	dp = opendir (dir_name);
	
	if (dp != NULL)
	{
		while (ep = readdir (dp)) {
			if (ep->d_name[0] != '.')
				files_.push_back(ep->d_name);
		}
		
		(void) closedir (dp);
	}
	else {
		cerr << ("Couldn't open the directory");
		return;
	}

#else
//open a directory the WIN32 way
	HANDLE hFind = INVALID_HANDLE_VALUE;
	WIN32_FIND_DATA fdata;

	if(dir_name_[dir_name_.size()-1] == '\\' || dir_name_[dir_name_.size()-1] == '/') {
		dir_name_ = dir_name_.substr(0,dir_name_.size()-1);
	}

	hFind = FindFirstFile(string(dir_name_).append("\\*").c_str(), &fdata);	
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (strcmp(fdata.cFileName, ".") != 0 &&
				strcmp(fdata.cFileName, "..") != 0)
			{
				if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{
					continue; // a diretory
				}
				else
				{
					files_.push_back(fdata.cFileName);
				}
			}
		}
		while (FindNextFile(hFind, &fdata) != 0);
	} else {
		cerr << "can't open directory\n";
		return;
	}

	if (GetLastError() != ERROR_NO_MORE_FILES)
	{
		FindClose(hFind);
		cerr << "some other error with opening directory: " << GetLastError() << endl;
		return;
	}

	FindClose(hFind);
	hFind = INVALID_HANDLE_VALUE;
#endif
	
	file_names.clear();
	file_names = files_;
}

Enjoy
Roy.

Share

Useful ImageMagick and FFmpeg shortcuts for Win SendTo menu

Hello

Quickly sharing some useful scripts I've "developed" over the summer to cope with some image resizing / video ripping / transcoding, etc.
Instead of using some specialized GUI software for transcoding I thought why not simply put useful options in the Windows file browser "Send To..." context menu. That way I can right-click the file I want to work with and just send it to some tool to do the job.

Here it is...
Continue reading "Useful ImageMagick and FFmpeg shortcuts for Win SendTo menu"

Share

The Raspberry Pi is Here

A few months back I placed an order for a raspberry pi. For those who don't know what it is, it is a really cool project which is basically a computer for 35$ (Shipping for me almost doubled it, but that's to be expected). It is a board, which as 256MB Ram, SD-Card slot, 2 USB Slots, an RCA Slot for analog video, and a headphone jack for analog audio.

It is originally a project for schools, to help today's kids get started with (python, but not only) programming.

To be exact with what the project guys are describing it:

The Raspberry Pi is a credit-card sized computer board that plugs into a TV and a keyboard. It's a miniature ARM-based PC which can be used for many of the things that a desktop PC does, like spreadsheets, word-processing and games. It also plays High-Definition video.
Here are some FAQs

The OS of this board is stored on an SD Card. I have bought a class 10 16gb SD Card off of eBay for this purpose.

So few days ago, the board arrived! I finally found myself playing with it, and it's so much fun

Here are some common suggestions for usages: Continue reading "The Raspberry Pi is Here"

Share

Bootloading an ATmega88 for Arduino [w/ code]

Just wanted to put up a small tut on how to put an Arduino bootloader on an ATmega88.

I very roughly followed: 
http://www.ladyada.net/learn/avr/avrdude.html
And 
http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard (Although they make it way too complicated)
And ATMEL's datasheet for ATmega88 is also very good to have open at all times: 
http://www.atmel.com/Images/2545s.pdf

First, put everything on a breadboard: (This took me a while... Thanks D.Mellis and M.Feldmeier!!)

(Fritzing is awesome)
Continue reading "Bootloading an ATmega88 for Arduino [w/ code]"

Share

Online places to buy hardware

Hi
I always strive to be more open with my knowledge, so I decided to publish more posts of lesser "scientific" value and more just helpful stuff in various domains.
This time I want to share a list of website where you can purchase hardware for hacking and building.
Many are unhappy with the one-stop-shop Mc. Master-Carr and looking for an alternative. So here is what I found:

That's it!
Roy.

Share

Android frame animation revisited [w/ code]

So, been working hard on my projects, and discovered some interesting things in Android possibilities for frame animation. Last time I was using an HTML approach, because of memory consumption issues with using ImageViews. However now my approach is using View.onDraw(Canvas) to draw BMPs straight off files, in an asynchronous way, and it seems to work pretty good.
Let me tell you how I did it
Continue reading "Android frame animation revisited [w/ code]"

Share