BLOb

What is a BLOb?

BLOb, Binary Large OBject : is a collection of binary data stored as a single entity in a database management system. Blobs are typically images, audio or other multimedia objects. Database support for blobs is not universal. Blobs were originally just big amorphous chunks of data invented by Jim Starkey at DEC(Digital Equipment Corporation)

The four BLOB types are

  • TINYBLOB : A BLOB column with a maximum length of 255 (28 – 1) bytes. Each TINYBLOB value is stored using a one-byte length prefix that indicates the number of bytes in the value
  • BLOB : A BLOB[(M)] column with a maximum length of 65,535 (216 – 1) bytes. Each BLOB value is stored using a two-byte length prefix that indicates the number of bytes in the value.
    An optional length M can be given for this type. I
  • MEDIUMBLOB : A BLOB column with a maximum length of 16,777,215 (224 – 1) bytes. Each MEDIUMBLOB value is stored using a three-byte length prefix that indicates the number of bytes in the value.
  • LONGBLOB : A BLOB column with a maximum length of 4,294,967,295 bytes or 4GB (232 – 1). Each LONGBLOB value is stored using a four-byte length prefix that indicates the number of bytes in the value.
Advertisements

“#!” Shebang (Sha-bang, Hashbang)

I came across this line #!/usr/bin/env and was wondering what is this and for what? I browsed some articles to get some overview about it. Any script beginning with #! is called shebang(other names are hashbang, sha-bang etc). When a script with shebang is run, it passes the file as an argument to the specified program instead of trying to execute it.

The form of a shebang interpreter directive is as follows:

#! interpreter [optional-arg]

The interpreter must be an absolute path to an executable

In order to run the script, we need to tell the shell three things:

  1. That the file is a script –>accomplished using shebang #!

  2. Which interpreter we want to execute the script

  3. The path of said interpreter

2 and 3 is accomplished using env. 

Some typical shebang lines:

  • #!/bin/sh — Execute the file using sh
  • #!/usr/bin/perl — Execute using Perl
  • #!/usr/bin/python — Execute using Python

Shebang lines may include specific options that are passed to the interpreter.

Understanding some techy terms/concepts

  • Memoization – I give you 2 candies for breakfast, you have 2 candies. 3 candies after lunch, now you have (3+2=5) 5 candies. After dinner I give you 1 candy, Ho w many candies do you have at the end of the day?(assuming you haven’t eaten any :-P) You have (5+1=6) 6 candies at the end of the day. In short, what are you doing here? You are using the count of previous candies and adding the current count to it. Rather than, counting all over from the beginning. This concept is used in Dynamic Programming, remember things to save time later.
  • Deadlock – For getting a job I need experience, For becoming experienced I need a job. (especially for freshman)
  • Bootstrapping/Booting – Sequence of operations that starts the operating system, i.e. OS of a computer when it is turned on. Loading of an OS into the memory for running application, one loaded.
  • Protocol – Person A speaks French to Person B. But, Person B can only speak English. So, what they need to do in order to communicate?  Come up with a standard language understood by both of them or get a translator. Same thing happens when two devices are communicating, therefore a protocol i.e. a set of rules or standards is needed to govern the correct interpretation of communication.
  • Mount – This term is used for Unix based operating systems. Mounting means giving a location in a directory tree to a new storage device. Unmount means undoing the mount.

Framework and its potentialities

What is so special about frameworks? We hear about these web frameworks frequently like Django, Cake PHP, Rails etc.  Let’s dive into frameworks.

Framework gives you a ready-made code base which has been tested and designed by many developers and is ready to use solution for common generic problems. That is, it provides with a generic functionality which has flexibility to be changed, which helps you take advantage of this generality. It provides powerful template where the logic can be injected, helps in simplifying complex things.

Pros

  • Saves lot of time, DRY(Don’t Repeat Yourself) means fewer lines of code
  • Provides a standard through which the user can develop the module or a complete application instead of starting from lower level details.
  • More time can be devoted in developing the software and not in preparing the environment and tools of development.
  • Code is extensible for future use with clean code

Heads Up! Framework doesn’t work everywhere, for instance smaller projects which require simple coding seems to work faster than setting up a framework.

Setting environment variable for python in Windows

Tip for those running python script on Notepad++
Press F5 to run current script and to avoid output screen disappear instantaneously type in command: cmd /k python -i “$(FULL_CURRENT_PATH)”.

C Puzzles

int main()
{
int i=567;
printf(“%d\n”,printf(“%d”,printf(“%d”,i)));
return 0;
}
Output: 56731
Reason:( ) have higher precedence, first the innermost printf statement prints the value assigned to i, i.e. 567. The second printf then counts the number of characters previous printf statement; value of i[i.e.3] and the outermost printf statement counts no. of characters of previous printf statement i.e.1


int main()
{
int *i=50;
printf(“%d\n”,i);
return 0;
}
Output: 50
Reason: prints value assigned to i, which is equal to 50.


int main()
{
int *i=50;
i++;
printf(“%d”,i);
getch();
return 0;
}
Output: 54 or 52 depending on size of int used by respective compiler is 4 or 2.
Reason: increment a pointer whose value is 50. It goes to the next address location, which is 50 + sizeof(data pointed) = 50 + sizeof(int).


int main()
{
char i=’ABCZa’;
printf(“%d”,i);
return 0;
}
Output: 97
Reason: prints the ASCII value of ‘a’.


int main()
{
int p;
int *a=&p;
scanf(“%d”,a);
printf(“%d”,p+5);
return 0;
}
Output: prints value of a+5
Reason: value at a has address of p assigned to it. The program first scans value of a and prints value of a(though, it is p+5; value of a holds address of p) by adding constant 5 to it.