Categories
Twitter Pulse

Twitter Pulse Week 2

Welcome to a new week. The above graph shows the interest in the Canadian Permanent Residence among Nigerians. Take note of the regions where there are spikes in the graph.

The Goodbye Nigeria post led to Nigerians doing the #snowpose on Twitter. Nigerians from countries with winter took pictures of themselves in the snow.

Elegushi Beach

COVID-19 is in Lagos. Disregarding all warnings by the government, Lagosians stormed the beach on the first Sunday of the year. You can view the picture below:

Elegushi Beach

Such as situation is the ideal environment for the Coronavirus to be spread and some of the beach goers have now tested positive.

Elegushi Beach Aftermath

Panti After Party

The government with view to curbing the spread of the dreaded Coronavirus has placed an embargo on clubs, bars and restaurants.

Sadly, Lagosians didn’t heed the warnings and some of them were caught by the Lagos State Taskforce.

Party Goers
Panti After Party

FG to Borrow Dormant Account Balance

Dormant Accounts

As part of measures to shore up the national purse, the Federal Government has started borrowing from dormant accounts.

DNA Testing

After the FCMB Scandal, Twitter NG was buzzing with reasons why men should do DNA Testing.

Most heart-wrenching is the story below:

Family Feud I
Family Feud II
Family Feud III

Code of Conduct

How bad the level of poverty in Nigeria is can be felt by the code of conduct of a supermarket in Port-harcourt.

You can read this below:

Code of Conduct 1
Code of Conduct 2
Code of Conduct 3

As you can see for yourself, this isn’t a code of conduct, it is the terms of slavery.

Categories
Twitter Pulse

Twitter Pulse Week 1

Welcome to the new year. Since Twitter is where the pulse of the nation can be felt, I realise that it would be nice to curate tweets the resonate with me.

The above image is the story of the GDP of Nigeria from 2000 to 2019. You can tell for yourself how well the current administration has performed.

Goodbye Nigeria

Goodbye Nigeria

A Twitter user finally achieved his goal of leaving Nigeria. He came on Twitter to celebrate and met with serious backlash.

Backlash
Backlash Continues

If that was all, I would not feel bad. Sadly, more was to come:

Bad Belle

Sadly, one of the commentators lives in Canada.

Wizard

Clout Chasing

How far people will go for clout can be seen in the actions of a Twitter user called Didi of Malaysia. When called out, she had no reply.

Clout Chasing

Rape Attitude

False Rape Allegation

Today rape has become trivialised. The prevailing attitude about rape is simply scary.

Rape Mindset
Rape Setup

Feast Afrique

Feast Afrique has released a digital library of culinary text. One of the reminders that Twitter like real life comes with its own ray of hope.

Categories
Uncategorized

Welcome to a New Year

In the last weeks of 2020, the NIN issue which hounded JAMB registration in the early part of 2020 reared its ugly head.

Amidst the panic caused by the sudden announcement that everyone must link their SIM cards to their NIN, we have made it into a new year.

I once wrote the article My Top 10 Predictions for 2020 for the year 2020. Considering the fact that I missed the most important event of the year 2020, I won’t be making any prediction for the New Year.

However, I wish everyone reading this a prosperous 2021.

Categories
Python Programming

Euclid’s Algorithm I

Euclid’s Algorithm allows you to find the HCF of two numbers. The steps of the algorithm are given below:

  1. Ask the user for 2 numbers
  2. Test which one is bigger
  3. Make the bigger number m and the smaller number n
  4. Set r to be the remainder when m is divided by n
  5. Set n to m
  6. Set r to n
  7. If r is 0, the HCF is n. Stop
  8. Else go back to step 5

This article will cover steps 1 to 3. The first step is to create a script and name it euclid.py.

To write the code for step 1, enter the code shown below into the script:

# Ask the user for the first number
first_number = int(input("Please enter the first number: "))

# Ask the user for the second number
second_number = int(input("Please enter the second number: "))

To test which of the input numbers is bigger, we will use the greater than symbol. We will ignore other cases. The code to do this is shown below:

# Test if the second number is bigger than the first number
if (second_number > first_number):
    # Swap if the first number is greater than the second number
    temp = second_number
    second_number = first_number
    first_number = temp

# Print out to check the swap
print(first_number, second_number)

Now the program can receive input and swap them correctly. Below is an image of a running program.

Sample Program Run

Categories
Vector Graphics for the Web

Drawing Complex Shapes in RaphaelJS

The SVG path element is used for drawing complex shapes in the SVG path specification. It is the most complex element for drawing built-in shapes.

Paths represent the geometry of the outline of an object using commands. They take a single attribute to describe what to draw. In SVG the path element is represented by d will take the path string. In RaphaelJS, the path string is given to the library to handle drawing.

Setup

We will use a grid of 500 by 500 pixels to cover the topic of paths. The code to create the grid is given below:

<html>
	<head>
		<title>Paths Arrow Absolute</title>
		<style>
			#container {
				clear:both;
				width:500px;
				height:500px;
				background:url(grid.jpg) repeat;
				display: block;
				margin: 0 auto;
			}
		</style>
	</head>
	<body>
		<div id="container"></div>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
		<script>
			paper = Raphael('container', 500, 500);
			// Write Code Here
		</script>
	</body>
</html>

The grid image is shown below:

Grid Image

General Commands

All path commands are used in capital letters when used in absolute coordinates and lower case when used in relative coordinates.

M or m

This is the move command. It moves the drawing of the path to a point specified by the user.

Z or z

This closes the path of a path string returning it to the point where the path started from. It ends a point by connecting it back to its initial point.

Line Commands

L or l

This draws a line from the current point to a specified end point.

H or h

This draws a horizontal line from the current point to a specified end point.

V or v

This draws a vertical line from the current point to a specified end point.

Bring it all Together

In this section, we shall draw a simple arrow. The code to do this is shown below:

paper.path("M100 200 H300 V150 L450 250 L300 350 V300 H100 Z");

Generating the arrow shown in the diagram below:

Arrow Generated with Absolute Paths

Now let us examine the commands that create the arrow.

M100 200 makes the starting point of the drawing at 100, 200 of the grid. Note that the origin of the drawing is in the top left corner of the grid.

H300 V150 draws a horizontal line to the point that is 300 from the origin and then a vertical line to 150 on the grid is drawn.

L450 250 L300 350 draws a line to point 450, 250 and then 300, 350 on the grid.

V300 H100 draws a line vertically to the point 300 on the y axis of the grid and a horizontal line of back to point 100 on the x axis.

Z completes the shape by drawing a line back to the initial point M.

To use relative paths, we would do this differently as we would have to take the relative position of each point. The advantage of using relative paths is that we can move the shape just by moving one point.

The code to draw the arrow using relative paths is shown below:

paper.path("M100 200 h200 v-50 l150 100 l-150 100 v-50 h-200 z");

M100 200 like the command for absolute paths will start the drawing at the point 100,200 of the grid.

h200 will draw a horizontal line of length 200 from the starting point. v-50 will draw a line 50 in the negative direction.

l150 100 draws a line from the current point to the tip of the arrow. l-150 100 draws a line from the tip of the arrow to the lower left section.

v-50 h-200 draws the remaining parts of the arrow. z completes the arrow.

Curve Commands

They are used for drawing curves. There are 3 types of curves in SVG, they are:

  1. Quadratic Curve
  2. Cubic Curve
  3. Arc Curve

Quadratic Curve

The quadratic curve takes in two coordinates. The first one is the location of the control point for drawing the curve and the second one is the end point for the curve.

The code:

paper.path("M100 200 Q150 100 200 200");

Will create the arc shown below:

Quadratic Curve

Suppose we move the control point to 200, 200 with the code shown below:

paper.path("M100 200 Q200 200 200 200");

We will get a quadratic curve that looks like this:

Quadratic Curve with Control Point on a Line

Note that the curve now is a straight line. This is because the control point is in the middle and on the same line with the start and end point of the curve.

The code:

paper.path("M100 200 Q150 100 200 200 T 300 200");

Will create a inverse of the curve and drag it to an end point giving the quadratic curve shown below:

Sine Wave

Cubic Curve

The cubic curve has 2 control points unlike the quadratic curve.

The code consist of a control points at 120, 160 and 180, 240 with the new position of the curve at 200, 200 is written as:

paper.path("M100 200 C120 160, 180 240, 200 200");

This creates the path:

Cubic Curve

Arc Curve

The arc curve takes the following parameters:

rx ry x-axis rotation y-axis rotation large arc flag sweep flag x y

The code:

paper.path("M100 200 A100 100, 0, 0 1, 200 200");

Will draw the curve shown below:

Drawing an Arc

Conclusion

Paths become too complex to create manually and you should use a vector graphics editor like Inkscape. However, understanding the above commands will help you understand what the program is doing under the hood.