Using powerline-shell with csh and older terminal emulators

Its no secret I spend a lot of time customizing my work environment (and more recently my workflow). Apart from the fact that I enjoy it, the other reason is that I suspect my eyes are not going to last forever and I should do whatever I can to make it easier on them. This involves a balance of contrast and brightness. So when I found powerline and then later powerline-shell I could immediately see the advantage it would give me. Instant information about what I need, in sectioned and clearly separated regions.

My previous shell was already colored and segmented, and displayed my username, hostname and full path. It gave me a separation when scrolling up the terminal to see where the command I last entered was, and where stdout started spewing its stuff. However, I decided to up the ante and tried to install powerline on a combo of csh and konsole from Centos5. Pretty darn old version of konsole dating back to 2006, there were a few hiccups but got it to work using the following steps.

  1. Get the powerline fonts from here: Powerline Fonts . You can clone to repo or wget the zip file. Either copy the required fonts into your ~/.fonts directory or use the install script. Make sure you flush the font cache and see if konsole can find your fonts. Now in your konsole settings change the font to a powerlne one, currently I am on Meslo.
  2. Get the powerline shell python scripts from: Powerline Shell . Try to follow the instructions to do the install, but we will need some tweaks for csh.
  3. Make sure your character encoding in konsole is set to utf8. You can do this by going to settings and encoding. Then set these settings as default so that any new konsole window or tab will wake up with these settings (i.e. font and encoding).
  4. We need to slightly tweak the cshell environment. Set the environment variable LC_ALL to the correct locale, for e.g.
     setenv LC_ALL en_US.UTF-8 

    . Make sure this line is in your .cshrc file, otherwise it wont work by setting it once the shell has spawned.

  5. We need to tweak the powerline-shell-base.py to add support for csh style color formatting, this is fairly easy.
    1. Under color_templates list add another entry for csh:
       'csh': '%%{\\e%s%%}' 
    2. Under the arg_parser shell section, in the choices, add an entry for ‘csh’
    3. Under root_indicators add only if you want to:  
       'csh': ' > ' 
  6. Set the prompt in your .cshrc to run this script:
    1.  set prompt = "`~/powerline-shell.py --shell csh`" 
    2.  alias cd 'cd \!*; set prompt = "`~/powerline-shell.py --shell csh`"' 
  7. Profit!!!

powerline

Samsung Smart TV – Day 1

So I finally unboxed and installed my Samsung Smart TV (UEH6240). Just been a day and im not quite used to it, but I feel from a UX point-of-view the first impressions of the device are more important.
The TV itself is quite nice, I havent tried true 1080p to see how detailed it is, but I’ll get to that later.
It comes with one remote which has reasonably large rubber buttons and clearly labelled. Will take a while to get used to it, but its not bad. There are no buttons on the TV itself so make sure you always have batteries in the remote (or hook up a BT KB or Mourse to it).
Remote-to-TV is teeny bit laggy IMHO, cant go too fast, but its not really slow.
When the TV boots up, you get a bit of a demo video. Here is where I have the most problems though. There is a setup wizard that lets you setup network etc quite quickly but there is no onboarding. There definitely needed to be an onboarding tutorial for the remote, tv settings and especially the TV UX.
The main reason I emphasise on the TV UX onboarding is that its really crap. There is no labeling/text at most places, its hard to see where you need to go and what can be done.
So lets go to the Samsung TV Interface, (I probably should post up images here).
It seems you end up with 4 screens. The home screen is very SPARSE! There is a strip at the bottom with links to your recently used apps. On top of that is a small button tab thing (3 icons in it in my case). This takes you to the remaining 3 screens which seem to be the Samsung SmartHub app.
There is no labelling on any of the screens so you really dont know where you are and what the screen is called.
So the first of these screens is the Games screen where you can install games. So far none of them worked for me and they all asked me for a Samsung SmartHub account (more problems on that front later!). There is no way to search for the games, you have 8 or 10 games showcased on the main screen, and you can go to categories/whats new.
The second screen is the Samsung Apps screen which is similar. It does display all your installed apps but you cannot search for new apps. There are sections for popular, whats new, and categories. Its a bit of a pain to scroll these at times as scrolling to the right or left will change your screen.
The third screen is about media. It seems to display online radio stations or other video sources. I still have not figured out what is supposed to happen on this screen.

Ok, a very confusing UX, but what about the platform and connectivity?

Samsung SmartHub account

I fell at the first hurdle. Reluctantly I went to the Samsung website to create an account, but it told me my email address was already in use. Great, lets use the old account then. While I could sign into that account from my PC, it failed to login to SmartHub with some obscure error. I will try again with my TV but i doubt it will work. And this is the bane of most of my problems and the whole platform is tied into this account so I wont be able to do anything

Connecting to your phone

I have a Samsung Galaxy S3 (running 4.1) and a Moto G (running 5.0) so I thought I would be covered, Samsung loves Android, right? Cant be more wrong, complete fragmentation. It told me to install AllShare or SmartView2 on my phones. I tried various samsung apps on both phones. The S3 wasnt accepted since it wasnt running KitKat, and the Moto G wasnt accepted since it wasnt a Samsung phone. Out of the box it seems I wont be able to use any of my phones with the TV which is quite frankly incredibly disappointing as there is definitely not a technological limitation, just a fragmentation on Samsungs own focus.
I need to check how it plays out with iPhones but im not too hopeful on that.

Connecting to your PC

So TVs have supported protocols like DLNA and Miracast for a long time, so this should be easy, right?
Well out of the box, again I’m told to install various things on my PC that I cannot find or download or sign in to. Again very disappointing.
I’m going to give Plex a go on this as this is pretty much my ONLY option short of needed an HTPC.

Platform

AllShare SmartView2 all that crap and confusion. I feel this platform lacks focus, and updates break things.

What I expect from a Smart TV

Connectivity. I just expect the TV can connect to my phone, my PC, my cable provider all via network so I dont have to install useless apps or sign in to services i dont want to use. In the future I hope Virgin and Sky will stream everything (the Netflix way), so set top boxes will be made redundant. There is a sad issue of standardization on smart tv apps and technologies which suggests app development will be only manufacturer specific. Possibly AndroidTV will change this, but that still has a while to do. Personally I would prefer an HTPC setup for the flexibility, but SmartTVs are cheap and widely available so you might end up with one even if you dont care about them.

Setting up Qt4 for PySide

I thought I should write down some notes on my travels across Python GUI dev, as it took me a while to set this up. The main reason was too many things to download, the Qt SDK is pretty massive.

Rather than listing all the wrong turns I took, I’ll just tell you what you need for getting up and running with PySide.

PySide requires Qt4 SDK, currently only Qt5 is available on the Qt website (by Digia). You have to traverse a bit far in, to reach the archives section, then go into the Qt directory, and download the last Qt4 version available. You do not need to install Qt Creator or anything else, just the Qt4 SDK. It is almost 1.2 GB, which really gave me second and third thoughts about installing it, but i had no choice (well…)

Once you install it somewhere safe, to start the designer go to C:\DEV\QtSDK\4.8.6\bin or wherever you installed it, and launch designer.exe.

This will give you the Qt4 designer.

Untitled

Create a new form and go for “Main Windows”. You can drag and drop stuff around, and it will generate a ui file for you. Thats all you need to from the designer.

Now the python side, yup, pySide. I did this in Windows, but most of the procedure should be similar in *nix.

First installed pySide via pip.

pip install pyside

It will also install another script/executable, pyside-uic.exe.

This is the file that converts the .ui file you generated in the designer into a .py python script that you can simply include into your project.

To generate the python code, just run:

pyside-uic.exe test.ui -o test.py

Now go back to your favourite IDE (pyCharm, right?) and include these files into your project.

 

Battle of the IDEs and Editors

For some reason recently I’ve been playing around with too many IDEs and Code Editors. A lot of them are new for me and I havent delved into them too much or used them extensively. But just played enough with them, looked at the plugins/themes and the extensibility framework.

For a while I’ve been using the following

emacs (everything on linux)

i used emacs for everything on linux, its such a pleasure to work with. the theme support is great (currently im on solarized), its extensible, its customisable. its just amazing how much depth there is to this simple editor, that i feel i have a lot more to explore. its a real editor that makes the workflow so much smoother.

eclipse (java, perl, python, tcl)

i didnt like eclipse early since i was using it on a slow computer its eclipse is a serious resource hog. i also didnt like it since it felt too overwhelming, but along with time as i got used to it (and i got an ssd) its not too bad. its a real IDE that can support a large number of languages, and plugins. the autocomplete and quickfix are amazing. its really fast to write code in eclipse although it does feel its doing most of the boiler plate stuff for you. the code organisation, the build tools,, its a really powerful IDE, i havent seen anything missing from it.

visual studio express 2013 (c, vb.net)

microsoft made this free, so i thought i’d give it re-spin. my previous experience with vb.net and an older version werent so great so made me leave it. to be honest i havent played with vs2013 alot to say anything except it feels lighter than before, and yeah i managed to add the solarize them to it!

b4x (basic)

the b4x tools used to build for android or desktop had been updated so i thought i’d give them a go. havent managed to add my favourite theme to it yet. its light and fast, much better than the previous versions. still not at all extensible or customisable. its great to write fast basic code, the language itself is a joy to work with. the ide code completion etc is pretty good, but i really miss customisable shortcuts and better project view.

pycharm (python)

so ive only just started using pycharm and i havent even managed to write a single proper script in it so cant say a lot. it feels heavier than it should for a python ide, and i didnt see any exceptional python features so far. however its very themable once again, but i really have to use it properly to get a better feel.

idle (python)

so i used idle to write some basic scripts..umm…i didnt really like it. it did the job but was too clunky.

atom (not sure)

atom just came out from github so i thought lets give it a go. im quite impressed. some good themes (yes i solarized it), and extensible. from the looks of it i might replace notepad++ for some tasks. it feels very nice, an insane amount of keybindings, im really looking forward to see what i can use it for.

notepad++ (anything)

this is my go-to editor to open pretty much any file whether its code or not. its clean, its got some insane features, but most of all its FAST. im not a fan of the interface, but its still quite extendible. guess what, i even got a solarized theme for it, but its been trouble some, i think the theme and syntax highlighting are conflicting a bit.

brackets.io (html/css)

i gave brackets a shot for a short while since it looked great, and im hoping sublime comes to windows one day. to be honest i couldnt really work with it as they way to do some things wasnt what i expected them to be. also i dont have a lot of html/css to do so maybe one day i will go back.

Installing Ubuntu in VirtualBox

So I had some issues with the graphics drivers when installing Ubuntu 14.04 in virtualbox. The installation itself is straightforward, just mount the ISO and it installs within minutes. I following quite a lot of steps to get the graphics resolution to ramp up from 640×480.

I installed VirtualBox guest extension pack (by mounting the VirtualBox CD in the VB menu). However it seemed to complain about headers not matching even though it completed successfully. I tried installing various x-org packages and dkms but nothing would work. I kept getting this error:

The headers for the current running kernel were not found…

Until I saw this ticket: https://www.virtualbox.org/ticket/12623

Anyway, before I tried this (and I still think I dont have the correct video drivers) I also tried another method described here: http://www.linuxbsdos.com/2014/10/31/solutions-for-low-screen-resolution-in-ubuntu-14-0414-10-and-virtualbox/

I used Xdiagnose to turn on debug and boot messages and somehow now I can get up 1024×768!

Furthermore, I installed VirtualBox 4.3.22 and tried with the new extensions but they were failing. I had to manually remove the symlinks that the install was complaining that already exists. Then it finally installed. Now the resolution goes upto 1600×1200 and is a bit more smoother.

Next step is to probably see how I can further improve performance by setting up more cores/memory or transfering it to an SSD.

New Google Play Store Policies

I have been reading around various websites after some of google’s recent announcements on the play developer console. A lot of devs are feeling betrayed and hurt, and many of them are foreseeing problems which is justified.

Android has long been a hobbyist OS due to the hackable nature of the Nexus One and the open-source OS. It has a huge developer following but most of them are part-time or hobbyist rather than professional developers. Ok, it is hard to tell that, but from looking at the quality of many apps on the store, talking to a large number of devs and following indie websites, a lot of them start off as hobbyist and take the plunge, some of them never do. The big software houses are always there on every platform, and we are not really concerned about them as they know how to take care of themselves with their fancy accountants and lawyers.

The Google developer console is not bad. Overall they did a good job when they ported over to the new system. There are a couple of missing features here and there. There are also sometimes feature graphics etc that are needed but occassionally the requirements change as the play store layout changes.

App Pricing and Developer Revenue

I want to start with some comments on pricing applications.

Each developer pays Google a one time fee of $25, which is not a lot. In return google is hosting our apps, providing a front-end distribution mechanism to the users. There are no adverts on the play store. Google makes nothing on free apps (except if they use adverts but that is an unlinked stream).

On paid apps, Google takes 30%. So every £1, Google will take 30p. Factor in UK VAT at 20%, I am not sure whether it is 20% of £1 or 20% of 70p, either way a developer will be making around 50p – 60p for every £1 that a customer pays.

Assuming a developer works at £20/hour (which is fairly low), he would need 40 customers to buy the app to pay for 1 hour of his work. If you are thinking of an ongoing stream where a developer is producing apps and getting paid consistently at this rate you are looking for 300 new customers a day. Everyone knows this is an extreme rarity on the play store.

New Support Policy

So Google is now asking developers to respond to users within 3 days. There are several points to make here:

  • Does Google itself follow this rule and responds to developers within 3 days? Nope. In fact your chances of getting a reply from Google support (even in the case of a MAJOR issue like app bans etc) is same as winning the lottery.
  • Developers with a huge user base will struggle with this. Receiving lets say 40 emails a day, even spending 5 minutes reading each email means they will spend 3 hours a day just doing customer support!!! No development, no coding, no income!
  • Developers with a small user base will also struggle. After all they dont get an email everyday and often check maybe once every few days, they may even miss the 3 day deadline.
  • Is it worth the developers time? For earning an income of 50p, how much time spend on customer support is justified? Maybe initially it makes sense, but over time, it is less productive work. Per customer, the developer is not being paid enough to perform proactive customer support.

While these issues may seem to pertain only to indie devs and one-man-bands this is not true. Software houses will also have to dedicate more time and resources to customer support if they previously didnt.

New Address Policy

Google now requires all apps that are paid or offer In App purchases to have a physical address listed. From the developer console:

If you have paid apps or apps with in-app purchases, it’s mandatory to provide a physical address where you can be contacted, as you are the seller of that content, to comply with consumer protection laws. If you don’t provide a physical address on your account, it may result in your apps being removed from the Play Store.

The problems I see with this are:

  • No way to verify the physical address
  • Invasion of privacy for indie developers who do not own a business address.
  • Security risk for indie developers (who do not own a business address) as address verification is used by banks, utility companies, web hosts providers etc. There are many recent examples of social engineering attacks using this kind of information.
  • For developers who do not see this as a source of business income but just enough to feed their hobby (these are the explorer developers who have done some great work) from donations and so on, this is very discouraging
  • The address is displayed on paid apps, even to people who have NOT purchased the app
  • How will it help the customer to have a physical address?

I dont see any advantage to this except for the following of the law. That said, ofcourse Google reserve the right to do how they want in the Play store.

If this is to block malicious apps, this is easily workaroundable by providing a fake address, but it will affect the honest developers more. (If you read some reviews on the Play store you would realize how passionate and crazy some users can get!)

As a side note, it seems that that this can affect the xda devs like kernel, root and rom developers where local guys are going to hang out at the devs home, asking them to fix their bricked devices! Hope they bring pizza 😉

New VAT Policy

This is a welcome addition as most developers barely had the time to deal with VAT. Normally VAT is deducted at the point of purchase (atleast in the UK) so this makes a lot of sense.

Tooleap and B4A – Part 6 : Other considerations

There are some additional important things to note when using Tooleap.

  • If you are using view positions in %x,%y your view positions can be a bit off. Also affects popup menus. Make sure you adjust your layout for miniApp mode and normal mode if you need to use it in both.
  • Do not use Dialogs. This means MsgBox/InputList/CustomDialogs/BetterDialogs etc.
  • MiniApp icon should be atleast 30dip x 30dip
  • If you call StartActivity from the miniApp it will close the miniApp/sidebar.
  • When the application runs the miniApp, it gets cleared from recent tasks menu.
  • After the HOME button is pressed, it takes longer to load the miniApp (5 seconds). This is Android’s security feature.

 

Multiple instances of same activity

You can use the same activity for multiple purposes (for instance different conversations in a chat app etc). This can be done, as whenever you launch an activity for one type you can use the appID to distinguish between different instances, and load different data accordingly.

Tooleap and B4A Part 5: Launching a MiniApp

You can launch your miniApp from another activity or service. To manage your miniApps you will need to use the MSTooleapManager object. This object allows you to add/remove or find your miniApps.

To create and set up a particular miniApp you will need to use the MSTooleapMiniApp object.

Lets see how to create and start an activity in miniApp mode and also to set up its notification object.

We start off by creating an intent to our activity. This is in the format of “<packagename>/.<activityname>”. (There were probably easier ways to do this but I chose this to remain flexible)

 Dim i1 As Intent
i1.Initialize("","")
i1.SetComponent("com.maximussoft.tooleap/.test")

Then we set up our miniApp object:

TooleapMiniApp1.Initialize(i1,TooleapMiniApp1.TYPE_POPOUT_MINIAPP)
TooleapMiniApp1.ContentTitle = "A sample Title"
TooleapMiniApp1.ContentText = "content TExt"
TooleapMiniApp1.NotificationText = "Notification Text!"
TooleapMiniApp1.NotificationBadgeNumber = 3
TooleapMiniApp1.bubbleBackgroundColor = Colors.Transparent

Simple stuff, just setting up the Header/Titles.

Now to actually start the floating notification we need to add the miniApp using the manager.

appID = TooleapManager1.addMiniApp(TooleapMiniApp1)

That is it! That will start a notification, and when you click on the notification, it will launch your activity in miniApp mode.
You can customise the miniApp more using the object, and can manage them using the manager object. You can remove all miniApps or remove particular ones, and list them all etc.

Tooleap and B4A Part 4: Creating a Tooleap Activity in B4A

Once you create a Tooleap Activity, it can be used in normal mode or in miniApp mode (but only one at a time).

To set up your activity as a Tooleap Activity, you need to follow some steps. Firstly, we will change the activity type by using the following activity attribute (in your activity attributes section).

#extends: com.tooleap.sdk.TooleapActivities.Activity

Then in your manifest, you need to add the following lines (remember to replace with your activity name):

AddActivityText(test,
<intent-filter>
<action android:name="com.tooleap.sdk.TOOLEAP_SHOW"/>
</intent-filter>
)
SetActivityAttribute(test, android:theme, "@android:style/Theme.Translucent")
SetActivityAttribute(test, android:launchMode, "singleInstance")
SetActivityAttribute(test, android:taskAffinity, ".tooleap")

That is all the preparation that is required.

Now remember in miniApp mode the size of the Activity will be different (80%x, 100%y-105dip). In order to find out if the activity is in normal or miniApp mode you can use the MSTooleapActivityHelper object:

Dim TA As MSTooleapActivityHelper

If TA.isStartedByTooleap Then
    lbl.Text = "Started by Tooleap"
Else
    lbl.Text = "Started in normal mode"
End If

To get the current activity’s app id (each miniApp must have its own ID)

Dim appID As Long = TA.getCurrentActivityTooleapAppId