Configuring Intel Galileo Gen 2 in Linux

Firstly, you need to download latest IDE from here. Download the file named Linux-32bit or Linux-64bit which is appropriate for your system. Before start using IDE, you must disable modemmanager. Find modemmanager in your distros package manager and remove it, for Ubuntu:

sudo apt-get remove modemmanager

Then connect the Galileo to power and wait till ON led turns on. After that, connect Galileo to computer by USB cable. Open a terminal and give this command:

ls /dev/ttyACM*

Now you must see /dev/ttyACM0 port. If you see more than one port, unplug Galileo and run this command again. Plug Galileo back, and find which is Galileo’s port. After go to IDE’s folder, open a terminal and run IDE by:

sudo ./arduino

The first time you upload a sketch to Galileo, IDE will configure everything. So click File->Examples->01.Basics->Blink. A new IDE window will appear.  In that window, open Tools->Port and select your Galileo’s port. After doing that, click Tools->Board->Intel Galileo Gen2. Now you are ready to upload the blink example to Galileo. From toolbar, click Verify button and after that click Upload button. Now it will upload the blink app to Galileo and the led near the ON led will start blinking.

Selection_008

Selection_007

When you open IDE without root, uploading will probably fail because of lacking permissions. If you want to use your IDE without being root, you need to give write permission to Galileo’s port to your user. To accomplish that give this command: (see update)

sudo chmod -R 666 /dev/ttyACM0                                       (gives write permission to all)

sudo chown -R username:usermane /dev/ttyACM0          (gives write permission to username)

UPDATE: You can add yourself into dialout group to gain access serial ports instead of setting write permission to port. To do this, run this command:

sudo usermod -a -G dialout username

C# – Translating with Google Translate without Using API

I am trying to build a simple C# project for fun. I needed a translator in my project and I found Google Translate’s API which is very easy to use and clean. But it requires an api key which requires some of your credidental information. For a small fun project, I found it unnecessary. Then I wrote this code, which uses google translate’s mobile page to get translation. The mobile page stores the result in between <div dir=”ltr” class=”t0″>, </div> tags. The code just parses the result between these tags.

public static string Translate(string text, string from, string to)
{
    string page = null;
    try
    {
        WebClient wc = new WebClient();
        wc.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0");
        wc.Headers.Add(HttpRequestHeader.AcceptCharset, "UTF-8");
        wc.Encoding = Encoding.UTF8;

        string url = string.Format(@"http://translate.google.com.tr/m?hl=en&sl={0}&tl={1}&ie=UTF-8&prev=_m&q={2}",
                                    from, to, Uri.EscapeUriString(text));

        page = wc.DownloadString(url);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
        return null;
    }

    page = page.Remove(0, page.IndexOf("<div dir=\"ltr\" class=\"t0\">")).Replace("<div dir=\"ltr\" class=\"t0\">", "");
    int last = page.IndexOf("</div>");
    page = page.Remove(last, page.Length - last);

    return page;
}

Usage is like this:

string translation = Translate("Your text to translate.", "en", "tr");

It supports multiple sentences. I didnt test how long of text it supports. I didnt use any HTML parser to avoid using other libraries.

Just mind that, the code is not stable. If the pages layout changes, the code will fail. And I am not a C# expert(actually I’m not a expert on anything), so feel free to say my mistakes and if you have a better idea, please share in comments.

Watch Torrents While Downloading (Sequential Downloading)

Torrent programs download files in a random order. That causes streaming impossible. But there is a solution, you can enable sequential downloading and stream it. All you need is qBittorrent and VLC Player. Just dowload your .torrent file and open it with qBittorrent, select your download location and start downloading. Then right-click your torrent, select Download in sequential order. That’s all. Now you can open the video file with vlc player(or any player that supports incomplete file types) and watch it.

Selection_005

But there is a problem. Sequential downloading is not a very good thing. If you really want to watch the torrent while downloading, do that. But it causes low speed downloading and it’s against torrent’s logic. In normal time, never use it.

Here you can see how the progress is going. Normally, it should download the pieces of file randomly(not really random but we can call like that). But, as you can see, it downloads in order.

Selection_006

Feeder – A simple indicator app to track your feeds

I am a fan of rss-atom thing. It just simple and very fast way get the latest things. As I said, the main beauty in it is simplicity. Here is an app to make it even simpler, Feeder. It’s just an indicator for tracking your feeds. It supports RSS and ATOM. It’s simple yet powerful. You can add a lot of feeds without worrying about space because you can add feeds as submenus. Even further, you can both add feeds as submenus and normal-style at the same time. Also you can categorize your feeds. Just create some categories from settings and add your feeds to them. You need to active categories view from settings to do that.

Here is some screenshots:

normal and submenu style feeds
contents of submenu feed
contents of submenu feed
feeds with categories
feeds with categories

To add a feed, just click Add Feed Source, paste your feed’s url then click load. After loading, you can change feed settings as you want, you can even change favicon with the one you want. After adding feed, you can easily edit it.

Source and download links: https://github.com/isamert/feeder/releases/tag/v1.0

Using Shared Folders in VirtualBox (Ubuntu Derivatives)

The easiest and the safest way to share some files between guest os and your default os is using shared folders. Just follow these steps and start using your shared folders.

-Firstly, you need to install guest additions to guest os. To accomplish that in ubuntu(for other distributions you need to find equivalent package)

sudo apt-get install virtualbox-guest-dkms

– After that, maybe you need to restart virtualbox. Start device again and select Shared Folder Settings… in Devices menu.

Menu_013

-Click + button from left, select a folder to share and edit other settings as you like, but be sure to check Auto-mount, sometimes it can be hard to mount manually.

Selection_003

-After restarting guest os, the folder probably be mounted under /media directory. (It can be mounted under /mnt or /mnt/hgfs folders, look for these folders if you cant find under /media). And it’s just that. If you are getting an error like “You don’t have permissions to see this folder” while accessing to folder, you just need to add your user to vboxsf group by giving this command(in guest os):

sudo usermod -a -G vboxsf your_user_name

Selection_004

You need to log out and log back in(in guest os of course). From then, you can easily share your files between guest and host os.

-Additionally, you can learn your user name in terminal by this command:

echo $(logname)

Starting Genymotion and VirtualBox Devices From Terminal

Genymotion is a very nice tool for emulating Android devices. Generally to start a device, you can open genymotion and double-click the device you want to start. But if you dont want to mess with genymotion app and start device directly, you can do it simply like this.

Open a terminal, and give this command to list VirtualBox devices:

VBoxManage list vms

Copy the device name and run with this command:

player –vm-name DEVICE_NAME

Thats it. If you get an error like “No command ‘player’ found”, this means you installed genymotion elsewhere. Find the folder genymotion installed(like /home/user/genymotion), there must be a file called “player”. So your new command is:

/home/user/genymotion/player –vm-name DEVICE_NAME.

Also you can open the device without genymotion tools(directly from VirtualBox and you can open any device, not only android devices).:

VBoxManage startvm gui DEVICE_NAME

terminal

After that, you can create a desktop file that launches the device. File contents should look like this:

[Desktop Entry]
Version=1.0
Type=Application
Name=Android 5.1 Emulator
Icon=an_icon_that_you_want.png
Exec=player –vm-name DEVICE_NAME
Comment=Run Android Device Directly
Categories=Development;
Terminal=false

and save it as Android_Device.desktop. Right-click to file, click Properties, go to Permissions tab and thick Allow executing file as program. Now you can run your device from this file. Also you can copy this file to /home/USER/.local/share/applications, from then this device will be shown in your programs menu.

Thanks to this post.

FocalTech Touchpad(Asus Touchpads) Drivers for Ubuntu and Derivatives

If you have an asus laptop and your touchpad is not working, the fix is probably here. AFAIK, asus laptops uses focaltech touchpads and they are not supported in linux. To get 2-finger scrolling, pinch zoom like fatures you need to install drivers. Open a terminal and type:

xinput list

If you see something called “PS/2 FocalTech FocalTech Touchpad” (probably says it’s in emulation mode) this driver is what you need but it only works with kernel 3.19(as the author says), to see what kernel are you using type:

uname -r

If the output starts with 3.19 you can feel free to install this driver, to install just add the ppa and install the package:

sudo add-apt-repository ppa:hanipouspilot/focaltech-dkms
sudo apt-get update
sudo apt-get install focaltech-dkms

and just reboot your computer. If you dont want to reboot, restart the psmouse:

sudo modprobe -r psmouse
sudo modprobe psmouse

Now, everthing must work fine, 2-finger scrolling, pinch zoom etc. To check other features check mouse settings in system settings.