Tuesday, September 22, 2015

Understanding Websites

Understanding Websites

This article makes some gross assumptions about the Internet simply in order to
allow a reader completely unversed in the technical literature to understand
what the Internet is. That is because we can only define what we do not know
with what we know

The Internet is a phenomenon. It is the single largest network of information
in the history of the world. Now, it is highly misunderstood as the World Wide
Web. You see the WWW is simply a part of the Internet. Let us get started then.

Our topic of discussion revolves around websites.

website
ˈwɛbsʌɪt/
noun
noun: website; plural noun: websites; noun: web-site; plural noun: web-sites

    A location connected to the Internet that maintains one or more web pages.


If computers are talking what language are they talking in? Binary is the base
language for all computer communication. Think of binary as alphabets. Grossly,
if you are speaking in English, Spanish, French etc. you are using the same
alphabet. That is what computers are doing. They exchange information in
binary.

If we think of binary as alphabets, it comes to mind that how is the language
structure defined? One can associate protocols as language structure.
Iklsdfnnf lsliisejf ljdsknnbb  sldf sjdiielfm sd f jsdfieflsfjd ssaopqrjefsdfn.
Lost me for a bit there? Exactly. If computers did not know what the other
computer was saying this network would be useless. Protocols tell us that
soheimtng is not a correct word and something is. They are convention to allow
computers to convey information to each other. There are lots of protocols
which function over the Internet. Protocols like IMAP and SMTP deal with email
while those like HTTP and HTTPS deal with websites. There are others like FTP
which deal with File transfers.

Websites are information exchanges happening over HTTP or HTTPS. That said,
whenever an exchange happens there are two computers involved. A sender and a
receiver. The method of finding one computer amongst the millions connected to
the Internet is defined in the Internet Protocol(IP). The version 4 of this
protocol (IPv4) tells us that each computer has an address of the form
`xxx.xxx.xxx.xxx` where xxx is a number from 0 to 255.

However when we visit a website we never type in this number which is crucial
to finding the right computer in this haystack. We type in a readable name. The
protocol which allows you to do this is called DNS. When you type in
`google.com` you computer asks it's local DNS server to translate `google.com`
into an IP address.

When setting up a website, this DNS service is crucial otherwise your users
will be stuck typing the IP address into the address bar. This part of the
website building process is buying the domain name. This does not set up the
website for you. All it does is gives you the ability to tell everyone in the
world that `google.com` is actually 173.194.117.64 (go ahead, type that into
your address bar in the browser and you will end up on google)

Buying a domain name gives you the ability to say that `desilingo.com` is
actually machine `xxx.xxx.xxx.xxx`. With that ability you can now take up the role of a server of a website. The server and client of a website are actually machines. There is not special hardware requirement. You could run a server off your laptop for all sane reasons. It is however not advised. Servers are machines which have to run nonstop for months on end(forever theoretically). They tend to be powerful machines requiring special care which the average Joe is not able to offer. Hence we go to a space hosting service.

A hosting service provides you with a computer with a set IP address. The
maintenance of the actual hardware is done by them. They offer things like ((%
uptime; meaning that out of 100 hours your website's computer will be available
99% of the time to everyone in the world. Do not be lured by someone who offers
100% uptime. They are lying. So if your website's computer is somewhere else in
the world how do you control your website? Other protocols are built for such
things. SSH is the most popular choice but others include good old HTTPS. You
control your website via a web interface. Just like you do with blogger.com or
wordpress.

So a website consists of a domain name and a computer to serve your website.
What you serve in a website is the famous Hyper Text Markup Language(HTML). The
most recent version at the time of writing this is HTML5. Writing an HTML
document is a trivial task once you now how to write one. In fact word
processors like Microsoft Word allow you to save documents as `html`. So how
does the world know which file to look for? If you visit the URL
`http://example.com/2015/5/15/diary_entry.html`. You are being served a file called
`diary_entry.html` in a folder called `15` which is in another folder called
`5` which is in turn within a folder called `2015`. These folders are on a
computer identified by the domain name `example.com`

Now comes the difference in static and dynamic websites. Every time you visit
`https://facebook.com` you do not see the same page. If you are not logged in
you see the registration page. If you are logged in you see the profile page.
If the URL is the same how come you are being served a different file every
time? Websites where the URL corresponds to a single file are called static
websites. Websites like Facebook are dynamic.

So in order to set up a website you need a domain name, a server, content to
serve. Some things one should look into are :




Tuesday, September 1, 2015

Ether and light

Dark ether, spread around
no light, yet dark found

some shy, some bright,
these twinklers put up a fight,
against your rage against light.

Woe on the fate of a star,
Their death not known,
for years after their war.

Along comes a demon so bright,
slaying your minions,
o ether against light.

You battle with all your might,
slowly killing this ogre of light,
fifteen days, ether vs light.

only to arise,
feeding on the pain,
of a multitude of starry demise.

This ogre shall rise,
for dark ether, spread around
there is light and so you're bound.

Sunday, August 30, 2015

PyTongue - OSFY article

PyTongue
========

Teaching programming with non-English languages
-----------------------------------------------

Title                     : Teaching programming with non-English languages
Author                 : Arjoonn Sharma
Target Audience  : People who teach programming at various
                               levels and general programming enthusiasts

Any program which must be run needs to be converted to a string of bits in
order to run. This has been true ever since the inception of programmable
computers. If this is the case, then all we need to do is write the proper
string of bits to make any program. Then what do programming languages do?
After all we are not writing bit-strings but are writing text based programs.
The bit-strings are all that a computer needs to run. The programming languages
exist to help us make sense of what we have written. This means that
programming in a language of our own is very much possible. All that is needed
is a method of translating the language to the appropriate bit-string. This is
where PyTongue comes in handy. It lets you teach people who do not know the
Latin script how to program.

For the purpose of teaching programming to children who do not know English I
developed PyTongue. Thus I can teach them Python without having to teach them
English first. Python3 was the choice of language as it has nice Unicode
support throughout and Python by nature has a small learning curve. After a
while people have to learn English as it is the language of the trade. This way
however I can make sure that a child who has the potential to program does not
miss out simply because of a language barrier.

PyTongue has simple logic powering it. It is a transliteration service to be
precise. It takes a program written in one language and transliterates it to
normal Python code which is in English. The new code is then executed.

To get started with PyTongue we must first install Python3 and then install
PyTongue. For this article Ubuntu 14.04 was used.

First we make sure that Python3 is installed. Next we create a directory
`pytongue_folder` and download PyTongue in it.

--------------------------------CODE-----------------------------
sudo apt-get install python3
cd ~
mkdir pytongue_folder
cd pytongue_folder
git clone https://github.com/theSage21/pytongue
cd pytongue
--------------------------------CODE-----------------------------

In case the `git` command shows an error you can download the `zip` file from
the same link and unzip it. The effect is the same. We need to have a folder
called pytongue. After that we navigate into the folder with


In order to write code in a certain language we need to get the mapping for it.
Some mappings like Hindi, Russian etc are already provided.
Mappings are obtained by running `pytongue-mapgen hi` for Hindi and
so on. The two word short forms are from


A mapping is a word-for-word translation of the basic keywords and builtins
in Python. To create a mapping we need to create a file with the required
language name and write a JSON encoded dictionary having the general structure
of :.

This creates a mapping for the requested language. While it is downloading the
language it prints out the keywords mapped. After this we begin to write a
program. For the purposes of demonstration we will first write a simple 'hello
world' program and then a simple calculator in Hindi.

To write these programs any plaintext editor will do (gedit, vim, notepad etc).
The first line of the program must always be of the format
`# `

Program1: hello.py
--------------------------------CODE-----------------------------
# HI
छाप('हैलो दुनिया')
--------------------------------CODE-----------------------------

This prints out हैलो दुनिया'

Program2: calc.py
--------------------------------CODE-----------------------------
# HI
क = पूर्णांक( इनपुट('एक संख्या दर्ज करें'))
ख = पूर्णांक( इनपुट('एक और संख्या दर्ज करें'))
कार्य = इनपुट('क्या करना है दर्ज करें (+,-,*,/) : ')
अगर कार्य == '+':
    छाप(क + ख)
अगर कार्य == '-':
    छाप(क - ख)
अगर कार्य == '*':
    छाप(क * ख)
अगर कार्य == '/':
    छाप(क / ख)
--------------------------------CODE-----------------------------

This prompts you for two numbers and then an operation to perform on them. It
prints out the result of the operation on the two numbers. The translation
created for this program is:-

--------------------------------CODE-----------------------------
a = int(input('Enter a number'))
b = int(input('Enter another number'))
op = input('Enter the operation:')
if op == '+':
    print(a + b)
if op == '-':
    print(a - b)
if op == '*':
    print(a * b)
if op == '/':
    print(a / b)
--------------------------------CODE-----------------------------


How would someone know what words to use? That is done using the created maps.
The maps are stored as JSON in the languages folder. They are thus editable by
hand. Hence if some translation seems strange to you, you can simply edit by
hand to make it more to your liking. In order to know what a particular
function is called, you simply need to open the particular language file
(`$ gedit ./languages/RU` for russian) and look up the particular
translation pair.

After writing the desired code, we need to run it. Instead of the traditional
`python3 hello.py` command we would have issued, we run the shell script called
`pytongue.sh hello.py`

That is all. We have successfully written python in Hindi. For other languages
similar procedures follow. To sum up, we need

1. Mapping of the required language
2. Source code with first line as `# `
3. Run the program with `pytongue.sh .py`


Have fun with the software and let those who may become great programmers
experience programming even without knowing the Latin script.