Category: Learning today

Script to import HTML files into Zendesk Forums

Weeks ago, I was given with a task to import bunch of HTML files into Zendesk Forum as articles. As there were thousands of files and it’s tough to copy paste them manually. I got to know that Zendesk offers a rich set of API’s to manage Forum and it’s contents. I have created a Python script to import bunch of offline HTML files into Zendesk Forum creating Topics/articles in a Forum under Categories

We can perform either of the following features in Forum section.

  • List Forums
  • Show Forum
  • Create Forum
  • Update Forum
  • Delete Forum

Example request available in the Zendesk developers page is using curl.

curl https://yoursubdomain.zendesk.com/api/v2/topics.json -H "Content-Type: application/json" -v -u email:password -X POST -d '{"topic": {"forum_id": 79161, "title": "My Topic", "body":"This is some code", "topic_type": "articles", "access": "logged in users" }'

The above example had a limitation of adding HTML code into<code>, which is impossible when we had thousands of files to be uploaded. Thus I wrote a Python script tweaking the above example, so that I can refer an external file to fetch HTML contents and import it as an individual Topic.

Source can be found here..

https://github.com/ijeyanthan/zendesk-import-into-forum

To know more, visit http://developer.zendesk.com/documentation/rest_api/forums.html for the list of possible JSON requests available in Zendesk.

Install offline GIT Web help !

Today, I realised there is a HTML version of offline help manual available for GIT while running the following command.

$ git help –web grep

But then I realised the local HTML docs were not installed, when I tried to run. Thus running the following command gets it working.

$ sudo git clone git://git.kernel.org/pub/scm/git/git-htmldocs.git /usr/share/doc/git-doc

Updating the docs is just a command away.

$ cd /usr/share/doc/git-doc
$ sudo git pull

The following are few of the important links that comes handy (as mentioned in man git).

NOTES

1. Everyday Git

file:///usr/share/doc/git-doc/everyday.html

2. Git User’s Manual

file:///usr/share/doc/git-doc/user-manual.html

3. git concepts chapter of the user-manual

file:///usr/share/doc/git-doc/user-manual.html#git-concepts

4. howto

file:///usr/share/doc/git-doc/howto-index.html

5. GIT API documentation

file:///usr/share/doc/git-doc/technical/api-index.html

Mystery resolved – The case of missing balance in my mobile

Heya folks, after a long pause, am back with just another post to keep my blog live.

I still remember those days back at 2006 when I literally begged my parents to get me a sim card with Life time validity in it. Getting a life time card those days were so expensive (it comes around Rs.999/-). At that time, Aircel was the only network to offer Unlimited SMS for lifetime, that too for just Rs.888/-. Since then I am an ardent fan of Aircel network.

Lately, I experienced a strange issue with my network. My balance kept getting lower day by day without making any calls or sending SMS or activating any service. There is definitely something notorious happening with my network, but I had no clue about what was going on and thus I had to reach out to customer care’s assistance.

Reaching out to customer care and explaining the issue is the most painful thing to experience. I had to approach them this time and as expected, they weren’t of much assistance. Confirmed that no special service has been activated and they suspected some of my friends would have made calls without my knowledge. I so wanted to check with them the calls I made the recent calls I made. They refused to share those details with me. Despite many tries, I made him to disclose the time of the last call I made. He said it was just a few minutes ago and that was a surprise to me. I never made any calls that day and I had to continue begging him to know the number I made a call to. After a long debate, he agreed to disclose just the first five numbers to me. As I got the number, I just ended the conversation abruptly out of frustration.

For a moment, I didn’t realise the number he was referring to, was none other than my another number. But hold on, why would I ever call my another number myself when I have both the numbers in hand and that too throughout the month. If at all I have called, it must have logged in my mobile under Recent Calls history; it didn’t happen though.

 

Here comes the climax 😉 After a deep thinking and bit of a research on my mobile settings, I realised I have activated “Call Forward” feature a month ago and made it to route to another number, when this number is not answered or when not reachable. I had to do that because I had a poor network coverage inside my home. Now I called up again and confirmed the number and the charges they debited for that. Thus the case of missing balance has been solved.

Till this incident, I never knew I’d be charged for the call that gets forwarded as per the plan (Have to assume a call is made to the forwarded number and thus will be the charge as per the plan). For those ignorant, beware of this fact!. Arghhh, why on earth it didn’t strike my mind before?. Anyway, now I live in peace 😉

 

Depreciate or deprecate ?

I have often been confused with these two words and their usage as these are very similar in spelling and meanings. Today, after a bit of googling, I found the real context of them.

Here is a quick rundown of their definitions:

Depreciate is used to denote objects whose values have dropped in price over a period of time after you have bought them. This is often applied to houses, cars, computers, etc.

Eg : The pound is expected to depreciate against the dollar

Deprecate is a term for items that should no longer be in use. Common uses are in computer software versions, in which an older version is said to be no longer supported. A related term is self-deprecating humor, which is the term for comedians who make jokes about themselves.

Eg : This feature of Subversion is deprecated.

What is the difference between >> and 2> – Standard Input and Output Redirection explained

Off late I happen to get used to a lot of I/O redirection involved in coding and executing commands. Thus I thought summarizing them as a blog for my own reference.

The shell and many UNIX commands take their input from standard input (stdin), write output to standard output (stdout), and write error output to standard error (stderr). By default, standard input is connected to the terminal keyboard and standard output and error to the terminal screen.

The way of indicating an end-of-file on the default standard input, a terminal, is usually <Ctrl-d>.

Redirection of I/O, for example to a file, is accomplished by specifying the destination on the command line using a redirection metacharacter followed by the desired destination.

C Shell Family

Some of the forms of redirection for the C shell family are:

Character Action
> Redirect standard output
>& Redirect standard output and standard error
< Redirect standard input
>! Redirect standard output; overwrite file if it exists
>&! Redirect standard output and standard error; overwrite file if it exists
| Redirect standard output to another command (pipe)
>> Append standard output
>>& Append standard output and standard error

The form of a command with standard input and output redirection is:

% command -[options] [arguments] < input file > output file 

If you are using csh and do not have the noclobber variable set, using > and >& to redirect output will overwrite any existing file of that name. Setting noclobber prevents this. Using >! and >&!always forces the file to be overwritten. Use >> and >>& to append output to existing files.

Redirection may fail under some circumstances: 1) if you have the variable noclobber set and you attempt to redirect output to an existing file without forcing an overwrite, 2) if you redirect output to a file you don’t have write access to, and 3) if you redirect output to a directory.

Examples:

% who > names
Redirect standard output to a file named names
% (pwd; ls -l) > out
Redirect output of both commands to a file named out
% pwd; ls -l > out
Redirect output of ls command only to a file named out

Input redirection can be useful, for example, if you have written a FORTRAN program which expects input from the terminal but you want it to read from a file. In the following example, myprog, which was written to read standard input and write standard output, is redirected to read myin and write myout:

% myprog < myin > myout

You can suppress redirected output and/or errors by sending it to the null device/dev/null. The example shows redirection of both output and errors:

% who >& /dev/null

To redirect standard error and output to different files, you can use grouping:

% (cat myfile > myout) >& myerror

Bourne Shell Family

The Bourne shell uses a different format for redirection which includes numbers. The numbers refer to the file descriptor numbers (0 standard input, 1 standard output, 2 standard error). For example, 2> redirects file descriptor 2, or standard error. &n is the syntax for redirecting to a specific open file. For example 2>&1 redirects 2 (standard error) to 1 (standard output); if 1 has been redirected to a file, 2 goes there too. Other file descriptor numbers are assigned sequentially to other open files, or can be explicitly referenced in the shell scripts. Some of the forms of redirection for the Bourne shell family are:

Character Action
> Redirect standard output
2> Redirect standard error
2>&1 Redirect standard error to standard output
< Redirect standard input
| Pipe standard output to another command
>> Append to standard output
2>&1| Pipe standard output and standard error to another command

Note that < and > assume standard input and output, respectively, as the default, so the numbers 0 and 1 can be left off. The form of a command with standard input and output redirection is:

$ command -[options] [arguments] < input file > output file 

Redirection may fail under some circumstances: 1) if you have the variable noclobber set and you attempt to redirect output to an existing file without forcing an overwrite, 2) if you redirect output to a file you don’t have write access to, and 3) if you redirect output to a directory.

Examples:

$ who > names
Direct standard output to a file named names
$ (pwd; ls -l) > out
Direct output of both commands to a file named out
$ pwd; ls -l > out
Direct output of ls command only to a file named out

Input redirection can be useful if you have written a program which expects input from the terminal and you want to provide it from a file. In the following example, myprog, which was written to read standard input and write standard output, is redirected to read myin and write myout.

$ myprog < myin > myout

You can suppress redirected output and/or error by sending it to the null device/dev/null. The example shows redirection of standard error only:

$ who 2> /dev/null

To redirect standard error and output to different files (note that grouping is not necessary in Bourne shell):

$ cat myfile > myout 2> myerror

 

P.S. This works the same way in all operating system and is universal.

Courtesy : http://www.mathinfo.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html

History and Significance of Laughing Buddha explained..

Over the years, I have been seeing laughing Buddha in many places and I never cared of knowing it’s history. As I had a chance to know the history and significance behind it, I thought I would share with you what they mean as they all have different meanings.

Background information on the laughing Buddha

When westerners think of “Buddha,” usually they don’t visualize the Buddha of history, meditating or teaching. Instead, they visualize a fat, bald, jolly character called “The Laughing Buddha.” Where did he come from?

The celestial Buddha named Hotei or Pu-Tai is best known as the jolly Laughing Buddha. In China, he is known as the Loving or Friendly One. He is based on an eccentric Chinese Ch’an (Zen) monk who lived over 1,000 years ago and has become a significant part of Buddhist and Shinto culture. Because of this monk’s benevolent nature, he came to be regarded as an incarnation of the bodhisattva who will be Maitreya (the Future Buddha). His large protruding stomach and jolly smile have given him the common designation “Laughing Buddha.”

The Laughing Buddha’s image graces many temples, restaurants, and amulets, as he has become a deity of contentment and abundance. The image of Hotei is almost always seen carrying a cloth or linen sack (that which never empties) which is filled with many precious items, including rice plants (indicating wealth), candy for children, food, or the woes of the world. He is patron of the weak, poor and children.
Laughing Buddha statues depict a stout, smiling or laughing bald man in robes with a largely exposed pot belly stomach, which symbolizes happiness, good luck, and plenitude. Some sculpture has small children at his feet. Another item that is usually seen with the Laughing Buddha figure is a begging bowl to represent his Buddhist nature.

In some scenes the Laughing Buddha may be found sitting on a cart drawn by boys, or wielding a fan called an oogi (said to be a “wish giving” fan — in the distant past, this type of fan was used by the aristocracy to indicate to vassals that their requests would be granted). All of these images display Hotei as a wandering monk who goes around and takes the

sadness from people of this world.

According to legend, if you rub the Laughing Buddha’s great belly, it brings forth wealth, good luck, and prosperity. Hotei is also referred to as the patron saint of restaurateurs, fortune tellers and bartenders. When one overeats or over drinks, friends jokingly attribute it to the Laughing Buddha’s influence.

Laughing Buddha is a symbol of joy and wealth. Nowadays everyone, even who are not following the Buddhism and Taoism those are also started to feature the Happy Buddha in their homes and offices. This practice is even grown up in the western countries too. This article is a small try to know about the laughing buddha.
Over the years, the Smiling / Laughing / Fat Buddha has come to represent several beneficial attributes such as happiness, prosperity,contentment and joy. Consequently, people in East Asia such as China and Japan have placed the Fat Buddha statue in their homes and offices.

Tradition or Feng Shui

While Chinese and Japanese tradition merely associates the placement of the Fat Buddha in the home or office with prayers for prosperity and happiness, there is a school of thought known as Feng Shui that also focuses on the actual position of the placement and direction the Fat Buddha statue is facing.
In Feng Shui, the reason for buying and placing figurines or statues in the home is to correct a certain imbalance in your life. The placement of particular figurines in a certain part or direction of the house is meant to bring harmony and order into your life, letting you experience a more peaceful and prosperous life. The amount of benefit achieved by such placements depends on whether the rules of Feng Shui are being followed correctly.

Fundamentals of Feng Shui

Feng Shui (literally “Wind and Water” in Chinese), is all about balance and harmony between us and our environment. Just like the Yin and Yang energies, Feng Shui is about balance. Where there is light, there will always be darkness; where there is fire, there will always be water; and so forth.

Types of Laughing Buddha Statues

The following is a list of Smiling / Laughing / Happy / Fat Buddha statues. These Laughing Buddha statues have been attributed to provide their owners with beneficial effects such as happiness, prosperity, contentment and wealth. As such, many people have purchased various forms of these buddha statues to place in their homes or at their offices and businesses, hoping that they will receive some of these attributes too. You will find a number of these fat buddha statues being the centrepiece of many home decorations.

Tips
Buddha’s should never be placed on the floor as this is a sign of disrespect. All About Feng Shui recommends that you place your Buddha at least 4′ from the floor in an elevated position. Treat him with respect and he will reward you handsomely.

However, the location of placing the Laughing Buddha is important. It has to be placed at an height of some 30” approximate and should be facing the main door directly. The Laughing Buddha greets the energies that enter from the main gate and activates them manifold, and turns highly prosperous. If this location is not possible, the next best place to keep the Laughing Buddha is on a side table or a corner table, which is diagonally opposite to the main door and facing the door.

It is not advisable to keep the Laughing Buddha in a bedroom or in the dining room. This God of wealth is not worshipped or prayed to, but just displayed and its presences is purely symbolic and auspicious.

Linux File System Hierarchy

Do you need to know the file system hierarchy. You don’t have to search in Google to get familiarized with it. It’s there within your distro. Yes, Just type the following command to list the manual containing a detailed information about the file system hierarchy.

$ man hier

Playing around with fbcmd [HOWTO]

This post has been lying around my Drafts for about a month. While I was looking for ways to find mutual friends between two persons in Facebook, I realized that it is a painful job which involves a lot of playing around with Facebook API’s to get mutual friends listed. Whereas finding Mutual friends in Twitter is quite simple and so does with Identica too. You may find how to find them in this blog.

Let’s see how to achieve this..

1. Install fbcmd as per the blog post

2. Open your terminal and type the following to find mutual friendship between you and your friend

$ fbcmd mutual “<Enter_your_friend’s_full_name_within_quotes>”

For Example :

$ fbcmd mutual “vigneshwaran Raveendran”

NAME                     FRIEND_NAME

Vigneshwaran Raveendran  Kashi Vishwanath Revathy Ganesan

Karthikumar SK

Dhameswaran Natarajan

Mohindar Amarnath

Kamesh Jayachandran

[snip]

Isn’t that awesome. The following are a few commands that I felt it interesting..

How to list [and optionally save] all your friend’s profile photos ?

$ fbcmd ppics =all /tmp/fbcmd/ppics/

How to list [and optionally save] all photos where friend(s) are tagged

$ fbcmd fpics

How to list any friends who are currently online

$ fbcmd fonline

How to export all your friend’s B’day date in csv format ?

$ fbcmd finfo birthday_date -csv

How to know your profile ID ?

$ fbcmd whoami

How to set your status update
$ fbcmd status “is excited to play with fbcmd”
What not? Start playing with this app
$ fbcmd help #is your friend..
With this application, you can even schedule for a list of status updates with the help of a cron job 🙂
for additional help, examples, parameter usage, flists, preference settings,
visit the FBCMD wiki at:

[HOWTO] Access facebook through command line interface (CLI)

A majority of linux users prefer sticking to their terminal rather than accessing through a GUI for most of their daily tasks. Have you ever wondered if there is any way to access facebook from terminal? The answer is Yes… Now, it’s possible to access facebook from terminal. fbcmd application gives you a command line interface for Facebook. It is surprisingly available for Windows OS as well.

Installation of this app in Linux is pretty simple.

Make sure you have php installed in your system. If not, install as follows

$ sudo apt-get install php5 php5-cli

To test your PHP environment, try typing at a command prompt:

php -r “echo phpversion();”

While you’re at it, make sure this outputs “1”.

php -r “echo ini_get(‘allow_url_fopen’);”

Download fbcmd.zip from the this link and Unzip the file

$ unzip fbcmd.zip

$ cd fbcmd

To finish the installation:

$ sudo php fbcmd_update.php sudo

$ php fbcmd_update.php install

type fbcmd to begin

$ fbcmd

Welcome to fbcmd! [version 1.0-beta5-dev1]

This application needs to be authorized to access your facebook account.

You are almost done! This application needs to be authorized to access your facebook account. This is a one time process.

Step 1: Allow basic (initial) access to your acount via this url, execute:

$ fbcmd go access

 

Step 2: Generate an offline authorization code, execute:

$ fbcmd go auth

Step 3: Obtain your authorization code (XXXXXX) and then execute:

$ fbcmd auth XXXXXX

Step 4: Most FBCMD commands require additional permissions. To grant default permissions, execute

$ fbcmd addperm

You are done !

To know the syntax , execute

$ fbcmd help

Start playing around with it and let me know your comments.

Don’t forget to visit the following post to continue reading this..

http://www.ijeyanthan.com/blog/archives/playing-around-with-fbcmd-howto