ca ca en pt en en en en en en en en en en fr en en en en en en en en en en en en en en en fr sv en en en en en eu it en nl en en en en en en en en en en en en en en en en en en en en en en fr en en en en en fr en fr en en fr en en fr en en fr en en en en en fr en en en fr en en en en en en en en en en en en en en en en en en en en en en en en en en en en en fr la en en en en en en en en en en en en en fr en en en en en en en en en en en en en en en en en en en en en en en
The personal blog of Alex Rudenko
Nov 30th, 2014 3:48 pm | Comments
Setting Up SMTP Relay Using Postfix on Ubuntu 14.04
Sep 21st, 2014 10:33 am | Comments
This is a small script to setup Postfix relay server on Ubuntu 14.04:
Replace smtp.example.com with your SMTP server host name and mail@example.com with your mailbox. The script should prompt you to enter the password for the mailbox.
Non-interactive SSH Login Using Password
Sometimes it’s handy to automate some remote tasks. It’s good if there is key authentication set up, but what if only the login by password is avaiable. In this case, if you run a command like “ssh root@my.srv” you’ll be prompted to type in the password.
You can avoid the prompty by providing the password using the sshpass app:
It works with ssh and scp commands like this:
sshpass -p password ssh ..goes normal ssh parameters.. sshpass -p password scp ..source.. ..dest..
Learning VCL: How to Build a VCL Component Demo
Sep 21st, 2014 9:21 am | Comments
Make sure you have the recent version of the VCL gallery component:
Install node modules required to generate the demo:
Make sure you have the node 0.10.* installed because the generation of examples fails for nodejs 0.11.* due to an issue in the connect module:
This will start a local web server and it will open the example page in the browser. By default, http://localhost:8000/example.html should be opened:
If you navigate to the root http://localhost:8000/, you’ll see all available examples for the component.
Converting FLV to MP4 With Ubuntu Linux and Avconv
Sep 21st, 2014 9:12 am | Comments
The FLV files aren’t good for everything. Therefore, one my want to convert an FLV file to an MP4 file. This can be done simply by using the avconv tool:
avconv -i video.flv -codec copy video.mp4
The resulting video will have the same quality as original FLV because the codec “copy” was used. If you don’t have the avconv installed, install the libav-tools package to get it:
Extending Your Ubuntu Desktop With Custom Indicator Applets Using Python3
Aug 31st, 2014 1:37 pm | Comments
In this blog post, I will explain how to develop your own indicator applet for the Ubuntu’s Unity desktop. The applet will reside in the top panel. The applet icon will indicate a state we’ll be monitoring. On a click on the icon, a menu will be presented which will allow changing the state.
Before I start digging into the implementation details, I would like to elaborate on why one may need to develop his own indicator applet:
monitor web sites or web services. E.g. notify you when there are new messages in your gmail account
monitor and control local filesystem. E.g. notify you when a certain configuration setting changes
anything else that you want to be shown in the top panel
In this blog post, we’ll develop an applet that monitors a website (http://habrahabr.ru) and notifies you if the website’s content has been changed. In order to detect that the content has been changed the applet will calculate a md5 hash of the content and will compare it with the current hash every 60 seconds. Of course, this may not be too usefull since the changes of the entire page does not necessarily mean that the actual content (e.g. articles) was changed. This may be improved by extracting a meaningful part of the web page and calculating the md5 hash of it only.
In order to launch an indicator applet, you will need:
All of these are available in Ubuntu’s repositories: apt-get install python3 libgtk-3-0 python-appindicator
Let’s create a python file and call it indicator.py. First, let’s define that it’s a python3 executable:
Then let’s import the libraries that we need:
1 2 3 4 5 6 7
import sys import urllib.request import hashlib import lxml.html from gi.repository import Gtk from gi.repository import AppIndicator3 as appindicator from gi.repository import GLib
Our main class will be called MyIndicator. It will have several methods. The first one is called init and in this method we will actually configure the application applet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
def __init__(self): self.hash = '' self.ind = appindicator.Indicator.new( "Test", "indicator-messages", appindicator.IndicatorCategory.APPLICATION_STATUS) self.ind.set_status (appindicator.IndicatorStatus.ACTIVE) self.ind.set_attention_icon("new-messages-red") self.menu = Gtk.Menu() item = Gtk.MenuItem() item.set_label("Clear") item.connect("activate", self.clear) self.menu.append(item) item = Gtk.MenuItem() item.set_label("Exit") item.connect("activate", self.quit) self.menu.append(item) self.menu.show_all() self.ind.set_menu(self.menu)
The main method will check the website and then it will launch the applet:
1 2 3 4
def main(self): self.check_site() GLib.timeout_add_seconds(60, self.check_site) Gtk.main()
The check_site method will actually do the job of checking the website and telling if the content has changed. The icon of the applet is changed to the red one by changing the status of the indicator to ATTENTION. The icon for the attention state was previously defined in the init method using set_attention_icon(“new-messages-red”) method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
def check_site(self): remote_data = urllib.request.urlopen('http://habrahabr.ru').read() self.remote_hash = hashlib.md5(remote_data).hexdigest() if self.hash == '': self.hash = self.remote_hash print("======INITIAL======") print(self.remote_hash) else: print("======TRIGGERED======="); print("Local hash: " + self.hash) print("Remote hash: " + self.remote_hash) if self.hash != self.remote_hash: print("======ATTENTION======="); self.ind.set_status(appindicator.IndicatorStatus.ATTENTION) return True
The quit method is called when an user clicks on the Quit menu item of the indicator:
def quit(self, widget): Gtk.main_quit()
And finally the main function of the program:
if __name__ == '__main__': indicator = MyIndicator(); indicator.main();
The complete source code is below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#!/usr/bin/env python3 import sys import urllib.request import hashlib import lxml.html from gi.repository import Gtk from gi.repository import AppIndicator3 as appindicator from gi.repository import GLib class MyIndicator: def __init__(self): self.hash = '' self.ind = appindicator.Indicator.new( "Test", "indicator-messages", appindicator.IndicatorCategory.APPLICATION_STATUS) self.ind.set_status (appindicator.IndicatorStatus.ACTIVE) self.ind.set_attention_icon("new-messages-red") self.menu = Gtk.Menu() item = Gtk.MenuItem() item.set_label("Clear") item.connect("activate", self.clear) self.menu.append(item) item = Gtk.MenuItem() item.set_label("Exit") item.connect("activate", self.quit) self.menu.append(item) self.menu.show_all() self.ind.set_menu(self.menu) def main(self): self.check_site() GLib.timeout_add_seconds(60, self.check_site) Gtk.main() def clear(self, widget): self.hash = self.remote_hash self.ind.set_status(appindicator.IndicatorStatus.ACTIVE) def check_site(self): remote_data = urllib.request.urlopen('http://habrahabr.ru').read() self.remote_hash = hashlib.md5(remote_data).hexdigest() if self.hash == '': self.hash = self.remote_hash print("======INITIAL======") print(self.remote_hash) else: print("======TRIGGERED======="); print("Local hash: " + self.hash) print("Remote hash: " + self.remote_hash) if self.hash != self.remote_hash: print("======ATTENTION======="); self.ind.set_status(appindicator.IndicatorStatus.ATTENTION) return True def quit(self, widget): Gtk.main_quit() if __name__ == '__main__': indicator = MyIndicator(); indicator.main();
First, let’s make indicator.py executable by running: chmod a+x indicator.py. Then we can execute it: ./indicator.py . The applet should appear in the top panel.
Getting Started With a New CSS Framework Called Visual Component Library (VCL)
Aug 18th, 2014 11:01 pm | Comments
In this post I will introduce a new CSS framework called VCL that provides a plenty of highly reusable and modular CSS components which work together nicely. The VCL stands for Visual Component Library and it aims at solving very similar problems as Twitter Bootstrap. I will show how to get started with VCL using a page of a simple web blog as an example. The resulting web page will look as shown in the next image. As you can see it has very simple and minimalistic design.
The VCL documentation as well as the source code is available on GitHub. A meta repository for all VCL modules is available here.
You will need a current version of NodeJS (I use 0.11.13) and NPM installed because all VCL modules are published as NPM modules. Also you will need a HTTP web server such as Apache HTTP or Nginx.
Building your own VCL distribution
First, download a template which I prepared for this tutorial from here. It’s a zip archive so extract it to any folder. I will use `~/myvcl`.
As you can see the folder contains several files and a folder:
fonts folder is just a copy of fonts from FontAwesome
index.styl is the main script that defines how other VCL modules are processed
package.json is a description of the VCL distro containing references to all needed VCL modules
vcl-override.styl is a file where one can override default VCL styles
vcl-theme-terms.styl is a file where one can define some variables which may used later on in the styles. For instance, colors.
vcl-var-override.styl is a file where variables exposed by the VCL modules can be defined
Open a terminal and execute “npm install” from the `~/myvcl` folder. After that a node_modules folder will appear in `~/myvcl` which will contain all available VCL modules.
From the `~/myvcl` folder run the VCL preporcessor to build your VCL distro:
node ./node_modules/vcl-preprocessor/bin/vcl.js index.styl compiled.css
You should see “✔ Succesfully compiled input to compiled.css” in the terminal if everything is fine.
Designing a page with VCL
Now when we have a compiled version of VCL. We can start designing a blog page. First, let’s create a folder within the HTTP web server’s root folder and copy compiled.css in there and the fonts folder into the parent folder. I use Apache HTTP server. Its root folder is /var/www and I create a folder /var/www/vcl_blog/public. So I can access it via a web browser at http://localhost/vcl_blog/public/.
In the /var/www/vcl_blog/public/ folder create a file called index.html and place the following content in there:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>VCL Blog</title> <link rel="stylesheet" href="compiled.css"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div class="vclGridRow vclVAlignMiddle"> <div class="vclGridSpan-3 vclAlignCentered"><a href="#"><h1> VCL blog </h1></a></div> <div class="vclGridSpan-12"> <nav id="nav" class="vclHorizontalNav vclHorizontalNavLight" role="navigation"><ul> <li> <a href="#">About Me </a> </li> <li> <a href="#">Posts </a> </li> <li> <a href="#">Portfolio </a> </li> <li> <a href="#">Contact </a> </li> </ul> </nav> </div> </div> <div class="vclGridRow"> <div class="vclGridSpan-3 vclAlignCentered"> <h2>Recent blog posts</h2> <nav id="nav" class="vclTreeNav vclTreeNavLight" role="navigation"><ul> <li class="vclAlignLeft"> <a href="#">Blog post # 1 <span>by Alex</span> </a> </li> <li class="vclAlignLeft"> <a href="#">Blog post # 2 <span>by Alex</span></a> </li> <li class="vclAlignLeft"> <a href="#">Blog post # 3 <span>by Alex</span></a> </li> <li class="vclAlignLeft"> <a href="#">Blog post # 4 <span>by Alex</span></a> </li> </ul> </nav> <h2>Blog search</h2> <div class="vclInputGroup"> <input autocomplete="off" type="text"> <span class="vclInputGroupButton"><button class="vclButtonStd vclSquare"><span><i class="fa fa-search"></i></span></button></span> </div> </div> <div class="vclGridSpan-12 vclAlignLeft"> <h2>Blog post # 1</h2> <hr> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in metus a magna lacinia dapibus quis sit amet felis. Etiam id ante mi. In a justo ac ipsum pretium gravida sit amet ultrices urna. Sed tempor luctus bibendum. Donec consequat ipsum eu urna mattis, at vestibulum sem porta. Integer posuere placerat ante sed tristique. Maecenas adipiscing sapien sit amet massa sollicitudin, at lobortis ante vehicula. Proin sagittis orci ut pretium fermentum. Nunc eleifend massa ut tristique placerat. Proin hendrerit luctus dui sit amet tincidunt. Nam vel auctor arcu. Quisque sit amet orci ipsum. Integer laoreet fermentum nulla, eleifend dapibus odio tincidunt sed. Vestibulum ut augue et ante sagittis ullamcorper. Nullam at ligula vitae lacus molestie ullamcorper id ac mauris. Maecenas aliquam libero purus, et suscipit felis feugiat id.</p><p> Sed posuere quam velit, quis consequat ante sagittis ac. Suspendisse non lectus id libero blandit volutpat. Nullam sagittis felis feugiat justo adipiscing, non volutpat elit ornare. Nunc dignissim mauris ac erat luctus rhoncus. Quisque vulputate purus turpis, luctus suscipit urna sollicitudin id. Aenean lacinia, erat at hendrerit interdum, mi nisl malesuada elit, quis mattis tellus felis in mi. Proin molestie neque ac augue adipiscing, vitae tempus ante tempor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec erat non augue ullamcorper bibendum.</p><p> Phasellus vestibulum arcu sed arcu varius, dapibus eleifend velit pellentesque. Morbi risus nisl, rhoncus sit amet dui vel, pellentesque porttitor nibh. Proin vitae ullamcorper tortor, non cursus purus. Ut elementum varius turpis, nec placerat mi fringilla vitae. Vivamus semper mattis auctor. Nam scelerisque eget lacus non adipiscing. Duis vitae purus vulputate, laoreet velit et, sodales enim. Cras congue vulputate metus, eget pretium ligula ultrices nec. Curabitur eget justo at erat rutrum dignissim in id massa. Phasellus vehicula, nibh eget imperdiet vulputate, lacus elit sodales lorem, sagittis adipiscing dui risus vitae magna. Etiam pharetra interdum tortor, eu semper felis rhoncus in. Duis id tellus sagittis, eleifend libero eget, accumsan augue. Vivamus faucibus enim vitae orci tristique, tincidunt suscipit tellus porta. Fusce felis dui, scelerisque a rutrum vitae, lobortis et mauris. Fusce vel posuere lacus. Quisque laoreet, tellus nec adipiscing cursus, odio dui consequat felis, lobortis accumsan neque dui quis erat.</p><p> Etiam commodo porttitor tellus quis fermentum. Donec lacinia magna tellus, at tempus sapien sodales in. Vestibulum scelerisque condimentum dui, lacinia convallis mi faucibus quis. Quisque nec mi aliquet, egestas turpis imperdiet, venenatis nisl. Proin vehicula ante neque, eget semper dui elementum ac. Pellentesque laoreet bibendum ultricies. Suspendisse et ullamcorper dolor. Nulla venenatis lacus mollis neque consectetur posuere. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent et diam sit amet ante facilisis dapibus non vitae nunc. In non diam mollis, cursus neque eu, consectetur nunc.</p><p> Sed quis semper leo, vitae tristique sapien. Vivamus molestie rhoncus ultricies. Vestibulum id interdum est. Fusce non ultricies felis. In tempor placerat blandit. Sed eros est, feugiat eget semper ac, facilisis nec massa. Aenean et quam vel erat gravida suscipit. </p> </div> </div> <div class="vclGridRow"> <div class="vclGridSpan-15 vclAlignCentered"> 2014 (c) Alex Rudenko </div> </div> </body> </html>
Basically, once you’ve done this you can open index.html in the browser (e.g. http://localhost/vcl_blog/public/index.html) and you’ll see the end result. But let me explain what’s written in the index.html
First, we include our compiled version of VCL using:
Using the CSS class vclGridRow we define a new row of our layout. Class vclVAlignMiddle specifies the vertical alignment in the middle
Using the CSS class vclGridSpan-3 we define that the element will take 3/15 of the page width. This kind of classes is typical for fluid-grid CSS frameworks. The total width of the page is 15 as defined by VCL.
We define a horizontal menu on the top of the page using the vclHorizontalNav class:
We define a tree (sidebar) navigation using the vclTreeNav class:
To define search box we use the vclInputGroup component:
1 2 3 4 5
Now we’ve learned how to get started with VCL. Read more about properties and configuration options of each one of the VCL modules on GitHub.
Android Development Studio: Create String Resource Automatically
May 31st, 2014 7:05 pm | Comments
I’ve just learned a new trick: selecting a hard-coded string in an Android xml file and pressing Ctrl+1 brings a context menu where one can select to Extract Android String. This would automatically append a string resource definition to values/strings.xml and replace a hard-coded string with an auto-generated name.
Mar 23rd, 2014 8:50 pm | Comments
a JS tool to be embedded into websites which can monitor users’ actions (scroll, select, copy, paste etc.) and store them in a warehouse for further analysis
a tool that can read (text to speech) websites and additionaly finds videos, images, music in the Internet and makes a movie clip on-fly to support the text being read
a service which can detect polytical views of a website’s visitors
How to Find Text Strings in PDF Files
Feb 21st, 2014 8:00 pm | Comments
I write my master thesis and I have a lot of literature sources which I store in a directory as PDF files. Today I needed to refer to one of the sources but I could not remember which one of them was actually supporting mine argument. I only remembered a couple of keywords from that source. So I was wondering if it’s possible to search for a string in a bunch of PDF files. And after spending some time googling, I found a neat command that does the work:
cd folder-where-you-have-pdfs find . -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "keyword"' \;
← Older Blog Archives
My New Blogging Project
Setting Up SMTP Relay Using Postfix on Ubuntu 14.04
Non-interactive SSH Login Using Password
Learning VCL: How to Build a VCL Component Demo
Converting FLV to MP4 With Ubuntu Linux and Avconv
Copyright © 2015 - Alex Rudenko - Powered by Octopress