Jekyll for Android v1.0

After a couple of months around this project it reached

a stage where maybe it is not super stable but it is usable and pretty ok for my needs.

It provides:

  • UI that is simple and I like.
  • Ability to commit a new post through Github API.
  • Keeps a draft.
  • A list of the user’s posts.
  • Ability to edit previous posts.

Here are some screenshots:

The source code is available and always will be on Github.
I think about publishing the app on Google Play Store for a small
price (let’s a dollar or two) mainly to get back the money from that Developer account.

What you will get is easy updates through the Play Store and the happiness of buying me a beer.

You can download the latest binary here.

What do you think about it?
Let me know! :)

Mr. Freeman

From Wikipedia:

Mr. Freeman is a Russian animated web series named after its main character. The series appeared on YouTube on September 21, 2009 and got considerable popularity in Runet. The main content of the series is monologues which in a harsh manner criticize the lifestyle of modern everyman. As of August 16, 2012 there are 19 episodes published. The total number of views is more than 35 million.

I discovered Mr. Freeman by this video last year which I saved on my Favourites list on Youtube.
Today as I was cleaning up this list, I rediscovered it and felt like sharing.

You may say you are not that guy for whom he is talking about but chances are you have a lot in common. Agreeing or not with him and his opinion of you there is sure some food for thought in his words.

Jekyll for Android

Some months ago I ditched my WordPress blog and fall for a platform calledJekyll (I wrote about it here).

Being hosted on Github was a great advantage but what happens when I want to post from my smartphone or tablet?

Cloning the whole project with some client and pushing it up again seemed stupid for just one file, the setup of which was pleasant because the filename should be something in the form of:

YYYY-MM-DD-title.md

and the beginning of the file:

---
layout: post
title: "The Title"
summary: ""
category:
tags:
---

So these days I started a little project called Jekyll for Android.

It is a little simple client for android that allows you to publish a post on your Jekyll blog if it is hosted on Github!

It it uses Github’s API and offers a Markdown Preview to check if your post looks ok (very Alpha feature) .

If you find it useful fork it, make it better or just use it!

You can find the project here!

P.S.: I wrote this post with it so it looks like it works! :p

Open Source is cool but don’t be an asshole

OMGUbuntu! had an article recently about the well known text editor Sublime Text 2.

This editor is fantastic! It can be customised in any way you imagine to fit your needs and taste. There is also a great community that builds plugins and you can build your own pretty easily. It also support some great features and you can see a demonstration at their homepage. Please go! I can wait!

You saw it? Good!

You wanna know how much it costs? 70 bucks (almost 10% of an average notebook) and its not open source.

There is though an unlimited evaluation period with a notification window punching you every n-time you save something.

I don’t care for the price. It’s a high quality tool and the licence part is very straight forward. How much they charge is their choice and if you buy it it’s yours. You evaluate it, you buy it or you leave it if you don’t like the price or the product. It’s about what works for you. You can just continue using what you used before.

The not open source stuff makes things difficult for some as you see. The same guy continued with some crap that he does not infest his computer with proprietary software and that proprietary software is somehow “fishy”. He got almost equal Upvotes & Downvotes in this comment so you see the opinion of the community on the subject. If you follow up with him on other comments in the same article he becomes pricky and eventually thrown out of the conversation.

The truth is that he is using closed source software on his computer if he ever views a YouTube video (Adobe Flash), listens to mp3 audio or even searches the web with any search engine (Google, DuckDuckGo).

Open Source is cool and I love it, but not everything is open source and if someone wants to make a living from his product he maybe can’t give it to you for free every time or give you the source. Why? Because he doesn’t want to! So simple!

It’s the same like saying I give you a screwdriver for 10 bucks with complete instructions how to replicate it and another one for 11 bucks that is more comfortable for you because of some features it carries and will help you to do your job better but it does not provide the replicating instructions. This is your choice to make.

Don’t be an asshole

Make your choices and don’t get angry with the guy that made the tool for his choices.

Universal Raspberry Pi Remote

I am getting mad of the remote controller in the house.

Actually I use three:

  • The TV remote
  • The Radio/iPod/CD Player remote
  • The Air Condition remote

Some time ago I fell on this post. It is an IR receiver & emitter circuit attached to a Raspberry Pi. I had some spare time so I decided to build it!

Circuitry was fairly easy.

Parts I used:

Infrared LED : Had a spare one but you can use any from an old remote
IR Receiver : I used a TSOP382. You can use any BUT check the datasheet!
NPN Transistor : I don’t know the part code
1.5Ω Resistor : It just has to be really low
220Ω Resistor : Nothing to say here

You can see the connections clearly here:

After the first assembly and testing I made it smaller using a strip board:

And this is what we end up with:

LIRC

LIRC stands for Linux Infrared Remote Control. And does exactly what it says.

LIRC is now included in Raspbian’s official repositories for Raspberry Pi and you can install it with:

sudo apt-get install lirc

Append this on your /etc/modules:

{% highlight bash %}
lirc_dev
lirc_rpi gpio_in_pin=23 gpio_out_pin=22

Change your /etc/lirc/hardware.conf to:

########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"

# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false

# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false

# Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################

And now restart your LIRC daemon:

sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

Transceiver

Now that we are all set up lets check if our IR transceiver works

# Stop the lircd so /dev/lirc0 is not in use
sudo /etc/init.d/lirc stop
# Get RAW data from the transceiver
mode2 -d /dev/lirc0

When you press some buttons on a remote control you should get something like:

space 12300
pulse 590
space 19395
pulse 540
space 7024
pulse 495
space 402351
pulse 560
space 7085
pulse 480
space 29043

If not then check your wiring. It is possible that you crossed the wires on the Pi.

IR LED

It’s really easy to create add a new remote on LIRC.

# Stop lircd so /dev/lirc0 is not in use
sudo /etc/init.d/lirc stop

# Create a new remote control configuration file (using /dev/lirc0) and save the output to ~/lircd.conf
irrecord -d /dev/lirc0 ~/lircd.conf

# Edit ~/lircd.conf and add edit the name of the controlled device
nano ~/lircd.conf

# Make a backup of the original lircd.conf file
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf

# Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf

# Start up lirc again
sudo /etc/init.d/lirc start

Do not forget to check irrecord --list-namespace for the valid key names. If something doesn’t meet your needs just put it on a KEY_ value that you will not use for this remote.

Now let’s test the remote:

# List all of the commands that LIRC knows for 'samsung_tv'
irsend LIST samsung_tv ""

# Send the KEY_POWER command once
irsend SEND_ONCE samsung_tv KEY_POWER

# Send the KEY_VOLUMEDOWN command once
irsend SEND_ONCE samsung_tv KEY_VOLUMEDOWN

# Send the KEY_VOLUMEDOWN command 10 times lowering the volume for 10 units at once
irsend --count=10 samsung_tv KEY_VOLUMEDOWN

Here is a video where I change channels from command line:

You can add more remotes just by appending a new lircd.conf at the previous one.

For the LIRC configuration I followed this guide.

I also made an Android application using the web interface provided here but the code needs a lot of polishing so I can’t share it yet.

It was cool for an evening project:)

ELOT-743 translator

I had a task to translate a big Greek address book in English.

Due to the fact that Greek Language is full of special characters, a problem occurred when passports where to be created. There should be a fixed way to translate names from Greek to English.
So the ELOT-743 standard was created to solve the confusion

Here you see most of it:

Greek English Greek English Greek English Greek English
α a Ή I Ξ X Ύ Y
ά a θ th ο o Ϋ Y
Α A Θ TH ό o φ f
Ά A ι i Ο O Φ F
β v ί i Ό O χ ch
Β V ϊ i π p Χ CH
γ γ ΐ i Π P ψ ps
Γ G Ι I ρ r Ψ PS
δ d Ί I Ρ R ω o
Δ D Ϊ I σ s ώ o
ε e κ k ς s Ω O
έ e Κ K Σ S Ώ O
Ε E λ l τ t ΟΥ OU
Έ E Λ L Τ T ου ou
ζ z μ m υ y ού ou
Ζ Z Μ M ύ y Ού Ou
η i ν n ϋ y γγ ng
ή i Ν N ΰ y ΓΓ NG
Η I ξ x Υ Y Γγ Ng

So to save my self from the abyss and to avoid the government’s site that had the capability to translate only small text, I wrote a python script myself.

Here is the dictionary to translate the strings:

# -*- coding= utf8 -*-
"""Main source http://www.sete.gr/files/Media/Egkyklioi/040707Latin-Greek.pdf
"""
dict={
"α":"a","ά":"a","Α":"A","Ά":"A","β":"v","Β":"V","γ":"γ","Γ":"G","δ":"d","Δ":"D","ε":"e","έ":"e","Ε":"E","Έ":"E","ζ":"z","Ζ":"Z","η":"i","ή":"i","Η":"I","Ή":"I","θ":"th","Θ":"TH","ι":"i","ί":"i","ϊ":"i","ΐ":"i","Ι":"I","Ί":"I","Ϊ":"I","κ":"k","Κ":"K","λ":"l","Λ":"L","μ":"m","Μ":"M","ν":"n","Ν":"N","ξ":"x","Ξ":"X","ο":"o","ό":"o","Ο":"O","Ό":"O","π":"p","Π":"P","ρ":"r","Ρ":"R","σ":"s","ς":"s","Σ":"S","τ":"t","Τ":"T","υ":"y","ύ":"y","ϋ":"y","ΰ":"y","Υ":"Y","Ύ":"Y","Ϋ":"Y","φ":"f","Φ":"F","χ":"ch","Χ":"CH","ψ":"ps","Ψ":"PS","ω":"o","ώ":"o","Ω":"O","Ώ":"O","ΟΥ":"OU","ου":"ou","ού":"ou","Ού":"Ou","γγ":"ng","ΓΓ":"NG","Γγ":"Ng",
}

And here is the actual script:

#!/usr/bin/python

# -*- coding= utf8 -*-
import sys, getopt
from string import maketrans
from elot743 import *

def replace_all(text, dic):
     for i, j in dic.iteritems():
              if i != j:
                  text = text.replace(i, j)
     text.replace(',' , 'n')
     return text

def readFile(infile):
     print "reading file",infile,"...n"
     i = open(infile, 'r')
     array=[]
     for line in i:
          array.append(replace_all(line.rstrip('n'),dict))

     i.close()
     return array
     print "nfinished reading file!n"

def writeFile(outfile, array):
     print "writing to file",outfile,"...n"
     print array
     o = open(outfile, 'w')
     for item in array:
           o.write("%sn" % item)
      o.close()
     print "nfinished writing to file!n"

def main(argv):
   inputfile = ''
   outputfile = ''
   try:
      opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
   except getopt.GetoptError:
      print 'names.py -i  -o '
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print 'names.py -i  -o '
         sys.exit()
      elif opt in ("-i", "--ifile"):
         inputfile = arg
      elif opt in ("-o", "--ofile"):
         outputfile = arg
   if inputfile == '':
      inputfile = raw_input('File where the names to be translated exist (ex. names.txt) : ')
   if outputfile =='':
      outputfile = raw_input('File where the translated names will be written (ex. trnames.txt) : ')
   print 'Input file is "', inputfile
   print 'Output file is "', outputfile

   transArray=[]

   transArray=readFile(inputfile)
   writeFile(outputfile,transArray)
   print 'File is translated!'

if __name__ == "__main__":
   main(sys.argv[1:])

To run the script, you can call it from command line by typing:

python names.py -i  -o 

Where the text file where the names to be translated exist and the text file where the translated names will be written.

-or-

You can run it without the arguments and it will prompt you for the file names.

I believe that it will not be helpful to many but it could be a relatively good example of using dictionaries in Python;)

The project code can be found here on GitHub. Feel free to use it.

Feel free to leave your comment below!