Shaumik is an optimist, but one who carries an umbrella. An undergrad at Indian Institute of Technology Roorkee and the co-founder of The Blog Bowl, he loves writing, when he's not busy keeping the blue flag flying high.
Every developer needs to gain a certain mastery over the terminal. It’s not always possible to be physically present near the computer you are going to work on, in which case, you would need to remotely log into the machine. And while it’s true that GUI applications are available to accomplish this, they are often not as fast as getting terminal access (after all, it’s just the exchange of some text!).
Regardless of whether you are a beginner or an experienced user of the terminal, I’m sure you like to pick up new tips and tricks. In this post, I’ll introduce 15 Unix commands you might not have heard of before.
Note: For this post, I will use square brackets to denote any variables. When you actually run the command, you should substitute it with the actual value, with the square brackets removed. For instance, our first example,
man [command]can be used as
Let’s start with a simple one. The[code language="python"]
mancommand stands for “manual”, as in documentation. If you want to know about any Unix command, you can run the following:
The simplest use case for[code language="python"]
manis to view the manual of the
manis not necessarily itself a little-known command, and you would probably find it in any Unix tutorial. However, there are certain special uses which I would like to highlight that likely wouldn’t be in a common tutorial.
If you need to know more about your ASCII characters, try this.[code language="python"]
There are many more such manual pages, and some of them are really funny too! (Tip: Try
man xkill.) I will leave you to fiddle with that. Meanwhile, let’s move on to some more commands.
If you are working in a directory and accidentally changed to another one, there is an easy way to get back to the old one. Just run the following to get back to the last working directory:
Web scraping, known as content scraping, data scraping, web harvesting, or web data extraction, is a way of extracting data from websites, preferably using a program that sends a number of HTTP requests, emulating human behaviour, getting the responses and extracting the required data out of them. Modern GUI-based web scrapers like Kimono enable you […]
Big brands have always started new trends and fads. A hundred years ago Kelloggs hit on the idea of marketing their cereals to children — a previously ignored sector in cereal marketing — by including a ‘prize’ with the box. Almost overnight the new ‘kids cereals’ category was created. Recently, Apple came up with the […]
Recently we published a couple of tutorials to get you familiar with Git basics and using Git in a team environment. The commands that we discussed were about enough to help a developer survive in the Git world. In this post, we will try to explore how to manage your time effectively and make full use of the features that Git provides.
1. Git Auto Completion
If you run Git commands through the command line, it’s a tiresome task to type in the commands manually every single time. To help with this, you can enable auto completion of Git commands within a few minutes.
To get the script, run the following in a Unix system:[code language="python"]
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
Next, add the following lines to your[code language="python"]
if [ -f ~/.git-completion.bash ]; then
Although I have mentioned this earlier, I can not stress it enough: If you want to use the features of Git fully, you should definitely shift to the command line interface!
2. Ignoring Files in Git
Are you tired of compiled files (like
.pyc) appearing in your Git repository? Or are you so fed up that you have added them to Git? Look no further, there is a way through which you can tell Git to ignore certain files and directories altogether. Simply create a file with the name
.gitignoreand list the files and directories that you don’t want Git to track. You can make exceptions using the exclamation mark(!).
At the end of May, Git’s primary developer, Junio C Hamano, announced on their mailing list the much awaited release of Git 2.0. If you go through the release notes, you will find that there are quite a few changes that have been welcomed by the community.
In this article, I’ll provide an overview of these changes. We will see two big changes that are creating waves, followed by a few miscellaneous ones.
git pushDefault Behaviour
If you use Git for your projects, you should know that the general format for pushing code looks like the following:[code language="python"]
git push [remote_name] [local_branch]:[remote_branch]
If you are a disciplinarian and use this syntax, you would not even notice this change in Git. However, if you were lazy and just executed[code language="python"]
git push, you would have probably received the following message:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
In Git 1.x, the default behaviour is set to
matching. This means that all your local branches that have matching branches on the remote are pushed. However, in Git 2.0, the default is changed to
simple, which would push only your current branch to the remote branch with the same name. If you want to continue with
matching, as in 1.x, you can always change the default.
SitePoint(Shaumik): How did you enter the world of web development?
Mark: I got my first taste of web development when I bought a book called “Creative Web Design” in 1999, using it to teach myself HTML on a computer without an internet connection. I was then lucky enough to land a job doing in-house web design work while still in high school, which allowed me to work as a front-end developer before the job title even existed.
SitePoint: Although node.js is gaining popularity, it still hasn’t released its first stable version yet. Do you think it can take over PHP, Python or Ruby in backend development in the near future?
Mark: Probably not, but I think we’re seeing a move away from monolithic backends towards more specialised services. With this kind of architecture, we’re likely to see much more diversity in technology choices, opening the door to a greater percentage of projects using Node somewhere in their stack.
Mark: Between global objects, AMD, CommonJS and now ES6 modules, our front-end ecosystem is so fragmented when it comes to creating modular code. I wish there could have been a module system and official package manager from day one, like we have with Node. I think we would all be be much further ahead if this had been the case.
When you start out as a freelancer — designer or developer — often it’s a part-time thing. Maybe you’re studying. Perhaps, you’re ‘moonlighting’ outside your normal gig.
Your focus is going to be to present great work in the most professional manner possible.
Ideally, once your business grows big enough, you’ll hire a finance professional to do your invoicing. Till then, you need to depend on tools that help you present the appearance of your longer-established and perhaps bigger competitors.
Happily, we live at a time where we have lots of high quality, cost-effective options to help you.
In this article, we just want to focus one critical part of that process — the piece of paper that gets you paid. The following are all tools that can help you generate simple but attractive invoices.
Let’s get started.
Nutcache is a free online tool for invoicing and time management. It has the tools that are needed by freelancers or other small businesses to manage their finances.
Happily, Nutcache is a free tool and promises to always remain free. It’s used and recommended by SitePoint’s Design and UX editor Alex Walker.
On registering and logging you, the dashboard looks intuitive with useful links on the top. You are provided with quick links to get started in case you are overwhelmed with the options.
Let’s go straight to the invoicing tool by opting to create our first invoice.
Nutcache maintains clients, services and products- all of which are linked back to your invoice. You can add a client while creating your invoice.
In a previous article, I discussed getting started with Git, mainly focusing on using Git when working alone. The core philosophy of Git, however, revolves around the concept of a distributed version control system.
The concept of “distributed” means there exist many independent versions of a single project, each with their own history. Thus, Git is a tool that helps you work with a team that may be geographically distributed.
We discussed how you could manage your files with Git in the previous tutorial, but the aim was to get familiarized with the concepts of git (add, commit, push). Now that you know how Git works locally, you are in a good position to start using the more advanced features.
The first step in the process is to get the code (assuming Git is installed) from a remote resource.[code language="python"]
remoterefers to a remote version of a repository or project. We begin by cloning the resource, using the command
git clone https://github.com/sdaityari/my_git_project.git
A close URL can be obtained from a GitHub repository’s main page, in the sidebar. On successfully cloning the repository, a directory is created (by default, it’s the same name as the project). Another interesting fact is that the
originremote now points to the resource where I cloned the repository.
Even though Git follows the distributed model, a central repository is usually maintained that contains stable, updated code.
Which protocol Should You Use When Cloning?
Notice that the repository is cloned over the
httpsprotocol in this example. The other popular choices that you have are
Cloning over the
gitprotocol requires you to use the origin that looks something like
git://github.com/[username]/[repository]. This does not provide any security except those of Git itself. It’s usually fast, but the big disadvantage is the inability to
pushchanges as it gives only read-only access.
If you use the
httpsprotocol, your connection is encrypted. GitHub allows anonymous pulls over
httpsfor public repositories, but for pushing any code, your username and password would be verified. GitHub recommends using https over ssh.
It is a general tendency of human beings to resist change. Unless Git was around when you started with version control systems, chances are that you are comfortable with Subversion. Often, people say that Git is too complex for beginners. Yet, I beg to differ!
In this tutorial, I will explain how to use Git for your personal projects. We will assume you are creating a project from scratch and want to manage it with Git. After going through the basic commands, we will have a look at how you could put your code in the cloud using GitHub.
We will talk about the basics of Git here — how to initialize your projects, how to manage new and existing files, and how to store your code in the cloud. We will avoid relatively complex parts of Git like branching, as this tutorial is intended for beginners.
The official website of Git has detailed information about installing on Linux, Mac, or Windows. In this case, we would be using Ubuntu 13.04 for demonstration purposes, where you install Git using[code language="python"]
sudo apt-get install git
Let’s create a directory inside which we will be working. Alternately, you could use Git to manage one of your existing projects, in which case you would not create the demo directory as below.[code language="python"]
The first step is to initialize Git in a directory. This is done using the command
init, which creates a
.gitdirectory that contains all the Git-related information for your project.
Next, we need to configure our name and email. You can do it as follows, replacing the values with your own name and email.[code language="python"]
git config --global user.name 'Shaumik'
git config --global user.email 'email@example.com'
git config --global color.ui 'auto'
It is important to note that if you do not set your name and email, certain default values will be used. In our case, the username ‘donny’ and email ‘donny@ubuntu’ would be the default values.
In December 2011, Facebook officially deprecated its REST API and launched the Graph API for public use. Since then, all new features have been added to the Graph API and Facebook has enabled users to perform loads of new things, some of which we will discuss today. In this post, we will be making a lot of requests to the Graph API, receiving JSON responses, and thereby manipulating them to get our desired results.
The Access Token
Most requests to the Graph API need an access token as a parameter. An access token is unique to the combination of a logged in user or page and the Facebook App that makes the request.
A token is associated with a Facebook app to handle the permissions that the user has granted to the app. This defines the resources that are accessible through the access token. Thus, a token provides temporary and secure access to Facebook. You can get an access token from the Graph Explorer. A token may or may not have an exipry time depending on whether they are short-term or long-term tokens. After the expiry of a short-term token, you need to re-authenticate the user and get a new token.
Contests Through Facebook Pages
In recent times, small and up-and-coming organizations have used Facebook pages effectively to promote their content. Yet, getting ‘likes’ and thus, increasing your reach, is a slow and steady process. Many turn to Facebook ads for this purpose. Many others, though, take a cheaper alternative — by organizing contests through their page.
The usual contest involves posting a photo or a paragraph on the page about an experience. The contest is judged on the basis of the number of ‘likes’ on the post or the photo. There’s also an extra condition for participating in the contest. For a ‘like’ to be valid, the user needs to like the page too. Facebook doesn’t have any built-in feature that tells you how many likes are common to your post and page. That makes judging the contests difficult.
Non-programmers would feel that the only way to judge the contest is by cross checking the number of likes manually. Fortunately, the Graph API helps us perform this action without much hassle.
Although I am going to perform the action through Python, the process remains the same for other languages. The important part is the target URLs that we send the requests to and the data we get from the received JSON.