Adding Twitter Cards To Jekyll

In the past, I’ve discussed about the Open Graph and its integration with Jekyll, where Open Graph tags are used in the HTML to control the content display while sharing on social media networks, particularly Facebook. The tags work pretty well on those sites which natively support Open Graph, such as, Facebook, Google+, etc., however, Twitter doesn’t support Open Graph tags to control the content’s display.

Worry not, as Twitter provide Twitter Cards with its own tags to support the content display control of your blog posts which you share on Twitter. What it actually does, is that it can provide a title, thumbnail and description of your blog post just below your tweet which you shared on your Twitter profile. This results in a higher probability of Click-through rate, as such links look cool and encourages your audience to click on your links. By simply adding a few lines of HTML to your webpage, the users who Tweet links to your content will have a “Card” added to the Tweet that’s visible to all of their followers.

Jekyll, as we have seen before, supports pretty much anything one can do with HTML/CSS/Javascript. With the inclusion of a short code snippet in your Jekyll repository, you can easily integrate Twitter Cards to your Jekyll site. Although, Twitter Cards come in 4 flavours (Summary Card, Summary Card With Large Image, App Card, Player Card), I chose the Summary Card because of its simplicity. Following is the process of adding the Summary Card to your Jekyll site:

1) Understand the structure of your site

Summary Card allows the users to preview the site content within a tweet. In order for Twitter Cards to support your site, you must have three parameters in your site: title, description and image. Twitter Cards will use that information to create a unique card for your links. title, description and url can be either added in _config.yml or in the YAML Front Matter block of your blog posts. The relevant parts in my _config.yml looks like following:


title:               Danyal Zia
description:         "Danyal Zia's thoughts on software development, personal development and writing."
url:                 http://danyalzia.com
avatar:                 media/images/danyal-zia-avatar.png

Relevant parts in the YAML Front Matter block of my blog posts:


title: 5 ways to motivate yourself
description: The guide to develop your self-motivation
thumbnail: /media/images/motivation.jpg

2) Add the Twitter Cards snippet

As you are using Jekyll like me for your blogging/website needs, the simplest way to add Twitter Cards to your site is to find head.hml in your _includes folder and add the code snippets of Twitter Summary Cards under . The basic HTML meta tags that Twitter provides looks like the following:

You can manually add your title, description and image, but we can use liquid syntax to automatically scrap the objects from our Jekyll blog. My complete code looks like the following:

Here, I chose Twitter handle for both site and creator. If it’s a blog post, then the title would be the name of the blog post, otherwise it will be the name of the blog (i.e., Danyal Zia). Similar logic has been applied for url, description and image.

Instead of adding the code in head.html, I created a new file twittercards.html, copied the code in it, and included in my head.html.

3) Validate your links for Twitter Cards

Now, once you have added the code in your head.html, you need to update the source trunk of your Jekyll blog and validate your links from here. This will also add your site in the white-list for the future validation.

twitter-summary-card-preview

Conclusion

In this blog post, I have provided the information on Adding the Twitter Cards to Jekyll and how it can be used to optimize the sharing of your blog posts. If you have any questions, then ask in the comments section below.

0

5 ways to motivate yourself

motivate

Many of us lacks the determination to achieve our goals or finish our plans with single-mindedness due to the lack of motivation or drive, while some of us are scatterbrained with a bunch of ideas, but are unable to set the goals. Chances are you’re one of those people, or perhaps you want to further increase your fluctuated motivation level.

Understanding yourself is the first step towards the self-improvement. The knowledge you gain from the others can help you understand about yourself and your weakness, and how to use your strength to overcome your weakness. For whatever reasons you are suffering from low motivation, following the 5 ways presented below might help you in boosting your motivation level:

1) Create a list of reasons for your goals

When you have a goal, then there is a high probably that you have reasons behind it. Write the every reason you know that you need to achieve your goals, i.e., what will you achieve with your goals, what motivated you to achieve your goals in the first place, etc. When you feel less motivation or get the negative thoughts, read the list again and again. You must convert your negative thoughts, and replace them with positive ones in order to have a clear picture of what the future will look like once you accomplish your goals. Research shows that positive reaffirmation helps programming your mind for the better outcome. You can even create notes about yourself to understand when your motivation sucks to see the pattern.

2) Break your goal into baby steps

You get a burst of ideas to achieve your goal, but you are not confident about it, because there are so many steps that come to your mind, then the old ideas get vanished and you get new ideas, this endless loop continues and you lose motivation. In order to efficiently achieve your goal, you must break it into baby steps and follow them thoroughly. Keep tracking the progress of your projects. If you keep a journal, then write the steps down and stick with them. Doing this way, you can even ask the help from other people to complete some of your steps, so that you can achieve your goals earlier than the predicted time.

3) Prepare ahead for the bad feelings

You must make the realistic expectations and set the logical steps for your goals. You must see the possibilities from every perspective before setting your goals. If you don’t prepare for the odds or the bad feelings, then you will become self-absorbed, self-hating, and thus lose the motivation to achieve your goals. You must understand that the lack of motivation you feel now won’t last long unless you make yourself immersed in the feelings. You must learn to replace procrastination with the willpower in order to complete the project with determination.

4) Listen to the motivational music

Listening to up-beat and loud music can really boost your motivational level. In particular, people with high musical intelligence tends to be inspired and motivated after they listen to their favorite music. Music can also help you in stabilizing your mood. Always listen to the music with optimistic lyrics if you want to reduce the pessimism and cynicism in your life.

5) Do the things your own way

If the traditional approach towards improving your motivation doesn’t work, then you shouldn’t worry about it, as not every person is the same. The best you can do is to study yourself, and try to analyze the situation when you get the motivation. Try to recreate that feeling to get motivation when needed. Perhaps, you might have an ADD? In that case, the psychiatrist can help you overcome your lack of focus.

Final Thoughts

Whatever road you take towards increasing your motivation, remember the life is too short for the procrastination. If you can overcome your procrastination when you must focus on your goal, then you’ve won the great war of the human misery. Procrastination has the capability to kill your dreams; do not let it control you!

0

5 great quotations which make you reconsider your existence

quotations

Often we found ourselves in the grip of existential depression, where the life stops making sense. At such moments, spending time with like-minded people improves the emotional health and may help you in finding the good in life. However, at times, you don’t find anyone around you. I found the following quotes incredibly fascinating which can get you out of the existential crisis:

1) “Death is not an event in life: we do not live to experience death. If we take eternity to mean not infinite temporal duration but timelessness, then eternal life belongs to those who live in the present. Our life has no end in the way in which our visual field has no limits.” – Ludwig Wittgenstein

Reading this poetic utter of Ludwig, you might not be able to grasp the meaning at first, as he didn’t mention the perspective through which he sees the life. In this quote, he meant that we can’t experience “death” because our consciousness stops when are dead. We can only experience “dying”. If you are living to experience a death, then you are not living at all. There is no death for us. We all are eternal.

2) “And those who were seen dancing were thought to be insane by those who could not hear the music.” – Friedrich Nietzsche

This is a remarkable quotation of Friedrich. He argued that people only see things from their perspectives, which is shaped by their experiences, genetics and environmental factors. When the same people find someone “out of the box”, they laugh at him, bully him, or even hurt him verbally and physically in order to “fix” him, because they think they care for him, believing the person does things because of his insanity, without realizing the inherent meaning or motivation or possibilities.

3) “A perfection of means and a confusion of aims, seems to be our main problem.” – Albert Einstein

Many problems in the world can be solved in the correct way. We have the potential to fix our problems right away; we human beings are good at getting things done, especially when we are passionate about it because the values matches ours, but we are extremely bad at deciding what should be done.

4) “All truth passes through three stages. First, it is ridiculed. Second, it is violently opposed. Third, it is accepted as being self-evident.” – Arthur Schopenhauer

People don’t actually accept the truth. They end up calling it “self-evident” when they can’t go anywhere in their intellectual pursuits to defend themselves. This is, of course, said with a perspective which conflates opinion with truth.

5) “Hope in reality is the worst of all evils because it prolongs the torments of man.” – Friedrich Nietzsche

Friedrich beautifully translated “Ignorance is a bliss” into the human language. The desire for truth, the curiosity of things leads to the destruction of one’s health. It’s terrible to find the truth: the collective beliefs of people turn out to be delusional, language and culture which make people less isolated use lying and fakery to get the aims, forcing people to get into escapism.

0

Why I love deadlines

deadlines

Highlighting the reasons on why I love deadlines.

In my freelance writing career, I find it hard to finish the work if I don’t have enough stress of deadlines. This stress is actually an eustress for me, because it motivates me enough to complete the unfinished projects. I do many projects at once, and sometimes it’s hard for me to keep focused on a single project regardless of my decisive personality. I need to have the ability to effectively meet deadlines.

Although, I wouldn’t say that others should love deadlines too, and that they should only work effectively under deadlines, because I prefer diversity, but I do think that deadlines are very important in a successful project management.

Many people would argue that giving hard deadlines kill the creativity in highly potential people who, despite working under deadlines, would prefer to work when there is no external pressure of time. I would argue that it is certainly true, but deadlines should nevertheless be the part of a long-term successful project, as without it, many people may find difficulty in finishing the project.

In this blog post, I will highlight the points in favor of deadlines and why it should be part of contracts of employers when hiring employees.

Why I love deadlines

1) It gives motivation

As mentioned earlier, deadlines provide motivation to achieve something, which is finishing the project in case of work. I only work efficiently if I have some motivation. If there is no motivation, then I can greatly lack desire. If I do this project at the right time, then I would have more time for other projects.

2) Recipe to kill Procrastination

Many people have a tendency to procrastinate while working on a project. This is cumbersome for them, as they find themselves in failure when they can’t do work as others expected of them. This leads to self-abandonment and the sense of guilt.

Many people do procrastination not because they are not dedicated to complete a job within a deadline, but because they are perfectionists and only work when they feel they understand everything and that the current moment is the right time to act.

3) Sense of responsibility

Deadlines make you responsible that others are relying on your work. Getting your work done on time affects other people.  If you are late for your deadline, it could have a domino effect and make everyone else late as well.  In the end everyone ends up looking unprofessional and disorganized.

Conclusion

Deadlines are arguably the catalyst in making your project successful, as many are stimulated by deadlines, as long as it doesn’t end up killing the creativity in people.

0

My experience with learning SQL

learning sql

Sharing my experiences and initial impression on learning SQL.

Today, I finished the third class of SQL (about its syntax and Microsoft SQL Server) in my university, where we have been taught about SQL Joins (Inner Joins, Outer Joines, etc.) and Subqueries.

Even though, it was my first time learning SQL and its actual Queries (the first two classes were introductory classes and thus were boring for me), it convinced me enough that learning SQL isn’t too hard for newbies compared to general purpose programming languages like C/C++, Java, etc.

My conviction was further increased when I read about it on the internet. So, I am going to highlight the reasons on why learning SQL seem easy to me.

My experience with learning SQL

I came to this conclusion for the following reasons:

1) Separation of church and state

RDBMS is separated from SQL; you do not need to learn about the inner details of RDBMS in order to learn SQL. Most SQL code is portable across different RDBMS.

2) Writing SQL queries is similar to writing pseudo-code

SQL is very declarative unlike most procedural programming languages (C/C++, Java, etc.). You can just throw a bunch of keywords and expect good things to happen! Consider the following SQL query:

It’s pretty obvious from the code that we are asking for a table with name of Customers who lives in America.

3) Tables are ubiquitous

You can play with predefined tables; you do not need to learn about tables / schemas and their different formats. Most RDBMS also supports reading / writing Microsoft Excel files.

Conclusion

Overall, I find SQL very easy to learn because of its eloquent syntax, although I felt a bit lack of intuition in its syntax considering it was initially developed in the 70s. I will be updating on my journey to learn SQL, so stay tuned!

0

Usefulness of constexpr in C++14

constexpr

The new standard of C++, that was formally called C++1y has been released for preview in the mid-August of 2014. It took some time for the standardization. Clang and g++ already implemented most of its features at the time with Clang claiming to be 100% feature-complete. For the new users of C++11, it merely enhances some aspects that were either oversight or voluntary left out for the future revisions.

One of many things that C++11 introduced is the inclusion of [compile-time function evaluation CTFE in the core language through the use of constexpr keyword. It is noted that we have already seen CTFE in D programming language — a language that is highly influenced by C++, through which with small intuition, we can evaluate lots of things at compile-time. While constexpr in C++ is arguably far less powerful than CTFE features found in D, it still provides some ways to evaluate various things at compile-time.

In C++11, not more than simple arithmetic with numbers or finding min/max values of int could be done with constexpr. C++14 improves upon it; it relaxes a lot of its restrictions, namely some iterations can now be done within a function without resorting to doing recursion for looping. We will see what can be done easily with C++14 that were previously cumbersome to be done with C++03/C++11. Although, I have mentioned about CTFE of Dlang, I won’t write about it in this post.

Variable initialization

In C++11, we couldn’t initialize variables in a constexpr function, which greatly limited its usefulness. With C++14, we can simply initialize how many variables we need, though we can’t use **static**, **thread_local** and **global** variables.

Conditional branch

We can now use If and else in constexpr functions, if they don’t have any extra return statement. Previously we had to use the short form of if/else to achieve the same effect.

Loops / Iterations

With C++14, we can write loop statements for iterations. This also includes range-based for loops. Previously, we had to use recursion to achieve the same effect.

Conclusion

C++’s compile-time evaluation features have a long way to come near Dlang’s CTFE, but they are arguably in the right direction. I have already seen its uses in new libraries. If you are using new constexpr features in your C++ library, then please tell me in the comments section!

0

Namecheap vs GoDaddy – Why I chose Namecheap over GoDaddy for domain registration

This is my honest piece of review on the services of Namecheap and GoDaddy. I only recommend product I personally use.

When I created my personal homepage / blog on Tumblr (it was before I moved it to Jekyll and then finally WordPress), I badly wanted to buy the custom domain for it. I didn’t want to buy the hosting, as Tumblr already provided the platform for me to blog regularly and create pages for my services and contact information. Also, Tumblr provided almost complete control / customization (custom HTML/CSS, etc.), so there was no reason for me to buy the hosting for other blogging platforms (self-hosted WordPress, etc.) because I didn’t want that extra functionality of those, such as, plugins (i.e., PHP support), themes, etc.

Anyway, I did google “Cheap domains” and found GoDaddy on top of the search page, so I thought that they were the most popular domain registrar in the world. I went through the site and completed the signup there, hoping to buy the domain. They register country specific TLD (Top-Level Domain) as well (.pk in my case), and they were showing the prices in PKR… which seemed good to me, because that had given me the impression that Pakistani entrepreneurs / freelancers prefer to buy domain from them. They were charging around $14.99 / year for .com domain, however, they were forcing me to buy the hosting from them as well, so for me their ordering process wasn’t very user-friendly at all.

I then found another domain registrar, namely, Namecheap from the Wikipedia page of GoDaddy while reading the internet freedom controversy. I visited the page and fell in love with its simplicity. They were giving .com domain for $10.69 / year with a free WHOIS guard for the first year, so they were indeed cheaper than GoDaddy.

I don’t have any experience in buying the hosting from either of them, but for getting a custom domain for your blog, I would highly recommend Namcheap because of their user-friendly website and (a bit) cheaper domain registration.

(Some of the links above are affiliate links)

0

6 Tips For Writing A Killer Cover Letter

Tired of getting declination of jobs because of poorly written cover letters?

Most of us who are looking for potential jobs in a marketplace need to regularly write cover letters to sell ourselves in such a way that make us stand out among the rest, especially for online work platforms or freelance marketplace. Badly or poorly written cover letters give impression to the client that the candidate is a cut / copy paste person, and so that way a client can lose a potential candidate!

The tradition of writing cover letters for making contracts date back to the days when people started using the medium of written communication to express the formal message, meaning the cover letters need to be considered as a medium of communication, not something that could be automated!

After having some experience in writing cover letters while working as a freelance software developer, and getting hired and rejected, I have noticed 6 crucial things that need to be kept in mind when writing a cover letter. Even though I can’t guarantee that the following tips will land you a job, I can say for sure that if you precisely follow these tips, then there is a good chance that the client would enjoy reading your cover letter.

6 Tips For Writing A Killer Cover Letter

1) Be specific

Always highlight your strong points and be specific as to why the client should choose you instead of others of the same set of skills as yours applying for the same job. Do not use general sentences, such as, “I’m excellent in HTML/CSS“, etc., but rather use specific sentences, such as, “I feel like I’m very good in HTML/CSS because I have designed ___ site from scratch“, etc.

2) Do not copy from previous cover letters

You can use the previous letter as the basis for your new cover letter, but never copy / paste the exact words from them! The clients would clearly find out that you have simply copy-pasted the cover letter and won’t take your application seriously as it gives the impression that you didn’t pay enough attention to the job requirements, thus making you look unprofessional.

3) Never beg for the job

Never ever beg for the job; when you are begging for a job, then it sends a negative impression of yours to the client that you don’t have enough skills to do the job and rather you are trying so hard to land the job.

Usage of the word “please“, particularly in the sentences like “Please hire me“, “Please do me a favor“, etc. are highly discouraged! You need to understand that everyone who is applying for a job gets a strong case, so you aren’t the exception! Use sentences like, “You may need to try me before rejecting my application” or “You can test my skills before rejecting me for mere lack of experience“, etc.

4) Be personal

You can be personal without begging for the job; that is, you can make a case that you are the only person who is perfect for the job. For instance, suppose a client has posted a job wanting a writer with software development knowledge, then you can tell why you are the only person who is perfect for the job, because you have both writing and software development skills at the same time. You can also mention your personal qualities, like how you are known for working under deadlines, etc.

5) Use proper English

Always use proper English with correct structure, and without any grammatical mistakes, especially for the jobs on content / blog writing. For the non-native writers, I would highly recommend Michael Swan’s Practical English Usage. Any grammatical error in a cover letter can be a break dealer, so it can be a worth investment!

6) Do not oversell yourself

Avoid the use of words like “expert“, “perfect“, etc. when describing your skills to the clients. Most clients prefer honest individuals who self-assess themselves honestly. Prefer the use of “very good” or “quite experienced” instead.

Know any other tips for writing a killer cover letter that has helped you in landing a job? Tell me in the comments section below!

0

Hi, there!

My name is Danyal Zia, I live in Karachi, Pakistan — a fast developing city. I’m graduating at University of Karachi, where I’m studying software engineering. I like to program applications, my main interest is in native compiled programming languages, although in recent months, I have made the transition to web development. I prefer static/strongly typed languages such as C, C++ and D, basically the ones that provide the maximum performance and/or use the hardware specific features.

I started my programming journey by contributing to some open-source software that are hosted on Github. I pursue to host my projects and code snippets there as much as I can. I currently do freelancing in software development and content writing.

When I began working as a freelancer, I had an ambition to make my personal site — a site which can be one-stop shop on my contact information. So, I decided to try Tumblr for both the CMS and site hosting, but I later realized that I needed to upgrade, so I made the transition to WordPress.

PS: Feel free to poke around the site and contact me if needed!

0