All in vain

Some rants about technology, PHP, people, tools, web etc from a developers perspective. Feel free to copy ideas, code or anything from here.

Tuesday, November 24, 2015

see the output from unit files created using template

if you are wondering how to see the output of multiple systemd unit files launched via template units then you have come to the right place. On CoreOS i created multiple instances of a service file using template files. Systemd Unit files are of this format:

foo@.service

[Unit]
Description=Preview Application service

After=etcd.service
After=docker.service
After=docker-connect.service

Requires=docker.service

[Service]
TimeoutStartSec=0
EnvironmentFile=/etc/environment
User=core
ExecStartPre=-/usr/bin/docker kill hg-doc-preview-%i
ExecStartPre=-/usr/bin/docker rm hg-doc-preview-%i
ExecStartPre=/usr/bin/docker pull localhost:5000/hg-doc-preview
Restart=always
ExecStart=/usr/bin/docker run --name hg-doc-preview-%i -m 500m \
    -e COREOS_PRIVATE_IPV4=${COREOS_PRIVATE_IPV4} \
    -e "HG_CACHE_BACKEND=MultilevelCache" \
    -e "SERVICE_%i_NAME=hg-doc-preview" \
    -e 'SERVICE_%i_ROUTE=Host("mock-server.test-easywebats.com")' \
    -p ${COREOS_PRIVATE_IPV4}:%i:7090  \
    --add-host backends:${COREOS_PRIVATE_IPV4} \
    localhost:5000/hg-doc-preview
ExecStop=/usr/bin/docker stop hg-doc-preview-%i

[X-Fleet]
Conflicts=hg-doc-preview@%i.service


You can then start instances of this service like so:
fleetctl start foo\@1234.service to launch on external port 1234. Now if you follow this there would be many unit files and you would like to watch the output of all these units.

Just run this command to see the logs for all such units:
fleetctl list-units | grep foo | awk '{ printf " -u %s ", $1 }' | xargs journalctl -f

Thursday, October 09, 2014

running grunt cli shows nothing on ubuntu 14

If you are running ubuntu and you followed some tutorial which lists first step in the installation of nodeJS you might have run

sudo apt-get install node

and when you tried to do your basic hello world this would have failed with the console reporting missing NodejS binary. The reason being on ubuntu NodeJS is called nodejs and there is another legacy program called node. You must run the following commands to ensure GruntJS works fine:

sudo apt-get --purge remove node

ln -s /usr/bin/nodejs /usr/bin/node

grunt -v

Now you should be able to run Grunt without any issue!

Saturday, September 13, 2014

docker fails to run on Ubuntu LTS 14?

If you try to follow the documentation on docker.com and install the latest version you might encounter this error:

Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

to solve this run:

sudo apt-get install apparmor;sudo docker -d &

Friday, April 13, 2012

IE z-index bug for absolutely positioned elements

I hate IE. Its because of the way it interprets css standards it makes it painful for web developers. If you are facing similar issue that your absolutely positioned elements are hiding behind content below it do not despair, there is help at hand. Head to this blog.


In brief, giving the parent element a higher z-index actual fixes the bug.



Sunday, February 26, 2012

DIY make your normal TV smart



Question: What to do if you want a "Smart" TV and you don't have the money it requires?
Answer: You take any "Dumb" TV that is good enough and make it smart. Continue reading below to know how.








Sunday, December 11, 2011

A new JAVA framework with PHP leanings

Just came across a different kind of framework in JAVA. Usually when we talk about frameworks in JAVA they are always "full stack" with the kitchen sink thrown in for good measures. I am used to developing with PHP frameworks as they are not too complex and also i like the fact that there is no compilation involved. You just refresh the page and you can see the results. This is where PHP excels.

 But what if you want the robustness of JAVA and instant results of PHP? May i suggest Play Framework to you? Not only is it a breeze to get it up and running but also it follows the "shared nothing" approach of PHP which i have always liked for quick web development.

From the Play Framework site:
Play is a real "Share nothing" system. Ready for REST, it is easily scaled by running multiple instances of the same application on several servers.
Also, the fact that it uses "Groovy" as the template language it makes it more appealing for me, cause XSLT is a big PITA and i never "got" JSP. I have to say the designers of this framework got it right. They took the Best of breed programming language(JAVA) and married it to the shared nothing model of the Most popular scripting language(PHP). I will take this framework for a spin soon. Only question running through my mind is, will it scale?

Tuesday, August 30, 2011

HybridAuth PHP authentication library

Came across this new Social sign-in library which goes by the name of HybridAuth. Seems like it is a good tool when you want to let your users sign-in to your website without registering to your site.

Will give a try sometime later. Check it out here!

New CSS framework from Twitter

Recently one of my friends shared this new CSS framework with me. Named Bootstrap, this is a good attempt at creating a CSS framework and also helps accelerate web development.

Will certainly love to include in my next project. So check it out here!

Monday, June 22, 2009

Idea for an android application

Recently i had this brilliant thought, here it goes. We normally receive so many calls from unknown numbers, it could be great if we know where this call is actually from. I am wondering this can be easily done in a mobile OS like Android. Here is how i think this can be achieved.

1. Create a DB of name-value pairs for all the operators in India (Some guy here has already done it).
2. When a call is received intercept it and look up the first four digits. If a match is made then display the Provider name and State.
3. Optionally, Map of India with a dot for location :)

So if somebody does it before me then its good, otherwise i think i will take it up later when i get some free time.

Monday, June 15, 2009

Authenticating users Against Active Directory with PHP

This summary is not available. Please click here to view the post.

Friday, May 29, 2009

creating png images from latex

Recently at work i had to generate images from latex equations. I used Miktex latex suite to generate the images. Here is the template i used for generating the images.

== Preamble ==
\documentclass[11pt]{article}
\newenvironment{custommargins}[2]%
{\addtolength{\leftskip}{#1}\addtolength{\rightskip}{#2}}{\par}
\pagestyle{empty}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{mathptmx} % rm & math
\usepackage[scaled=1.0]{helvet} % ss
\usepackage[papersize={5.75in},top=1pt,bottom=1pt,left=5pt,right=1pt]{geometry}
\begin{document}
\begin{custommargins}{-2cm}{-2cm}
\begin{flushleft}

== Your equation latex snippet ==

== Postable ==

\end{flushleft}
\end{custommargins}
\newpage
\end{document}

Steps to create image
1) Create a tex file using the above template
2) Create a DVI file using - $LATEX_PATH --quiet --interaction=nonstopmode $temp_tex_file_name
3) you may need to run it twice for formulas to render properly
4) Create png image using - $DVIPS_PATH -q $tmp_filename.dvi -o $tmp_filename.png


You are done!!

Dont forget to write to me if you find it useful.

Make your HTML go on a diet!

In one of my previous posts i showed a technique wherein you could reduce the size of your css and javascript files. You run them through a minify engine which strips down all the spaces and comments and possibly zip it as well while serving.

While it is all fine and dandy for a while but after a while you start to think even after the minify-ing process my html page size is still upwards of 300-400K! Then i think you need to do soul searching like i did. Why do we need all those javascript and CSS for anyway? cant we write css which is only 30-40 lines and still keeps my site functional and javascript which "really" helps the vistior.

Post your comments and suggestions :)

Textpattern and the art of CMS design

Phew a new post after such a long time. It has been a long time i have blogged. So here it goes. This post is about TextPattern. A PHP MySQL based CMS.

I was searching for a simple, elegant and unobtrusive CMS for my personal site. I dutifully headed to opensourcecms.com for seeing the latest and greatest PHP powered CMSes but sadly none of them fitted the bill for me. I was amazed by the bloat and stupidity of those CMSes.

Thats when i remembered about textpattern. I had known it existed for quite a while but never had the time to take it for a ride. Now that i have done it i am quite happy with it and it seems natural to me. I have added one WYSIWYG plugin and an admin theme. Now i am good to go. More to come later.

Tuesday, October 07, 2008

Spaces in file path in DOS

At last i am able to make it work. Thanks to this blog post i am able to get some headway in the problem i was facing. Basically i was running a php script as a batch script and i was not able to make some commands work because they contained space(s) in the path. There is a switch to DIR command in DOS "/X" which tells you the short name for any directory or file name.

So instead of "C:\program files\foo\bar.exe" you can use "C:\PROGRA~1\foo\bar.exe". May be it is helpful to someone.

Thursday, August 21, 2008

I want "no training wheels" attached PHP 6

Yeah you read that right. With some time before PHP6 comes into the fore, i want PHP6 to be a real path breaker. That means effectively no backward compatibility. PHP5 was slow in adoption just because of this reason. People knew that their applications would work on PHP5, that is why they were in no real hurry to adopt it.

I want the core developers team of PHP to really do some nice things with PHP. For noobies PHP5 should be kept. But with PHP 6 i want them to break new grounds. Like APC (Alternative PHP Cache) should be part of the standard install. I want them to incorporate consistent naming schema for at least in-built functions. That means str_replace => natsort?? kind of naming schema should be made consistent.

I want PHP6 to be more serious about security. It should have features which would make incidence of user oversight things of past. I want the in-built functions in PHP6 to raise exceptions. I want PHP6 to have variable types. I mean i declare a variable to be of type INT and i want PHP6 to raise an error if it is used in string context.

With these changes i can see PHP6 gaining the respectability it deserves. It can move to the area called enterprise platform.

Jquery('MyLife').turnAround();

This would summarize my development endeavors in JavaScript Land. I have lately come to love Jquery. So much so anything i do with JavaScript i do it with Jquery. I have also started using the latest Jquery UI. The tabs in JUI is truly amazing and easy to setup. Check out this collection of most popular Jquery plugins.

I am hoping one day we would see one widget system similar to ExtJS but using Jquery. Anyways if you are interested in Jquery, visit the site.

Wednesday, February 13, 2008

CSS framework + layout

You have heard about development frameworks in php,python etc. Now take a look at a css framework. YAML is the new kid on the block. It comes with its own slick layout designer so that you can create your own custom layout in a jiffy.

What i like about this css framework is that it gives you a clean slate to work with. You dont have to worry about the layout not behaving in IE etc. Kudos to its developers for creating such a nice css framework.

Friday, February 01, 2008

My own google gadget



Just a basic Finance gadget. Check it out now!!
Add to Google

Monday, January 14, 2008

Minify JS and CSS

So you just finished working on your new shiny web 2.0 application/site. It all looks very good until you open it on your friends computer to show off your baby. Its painfully slow!!. Hmm you must be wondering why its taking so much time to load.

The answer may be revealed to you once you see the source of your page. Its all good and dandy that you are using the "mini" version of Javascript frameworks like prototype, jquery, YUI etc. Whats probably slowing down your page is the sheer number of JS and CSS files you are loading on your page.

To mitigate the impact of so many files being loaded in your page you can use this novel idea. Look at this URL for more info. http://code.google.com/p/minify/ Minify.


What minif does is that it lets you load multiple JS and CSS files with one single call. It even caches the file generated so that subsequent requests don't have the overhead of "php" processing. I had some spectacular results with this approach where the sheer number of requests was taking a toll on the page.

Wednesday, May 23, 2007

New development framework for php

i have hosted my new dev framework for php on google. Here is the link to that site.