Archie Makuwa

Page 3 of 15

How do I determine if I’m on the very first page of pagination in WordPress?

Well… this is how:


Php: If url is homepage the do this…

Heita hola!

This is just a simple Php (or Laravel) snippet that allows you to sniff if you are on the homepage:


How to remove a div containing a button using jQuery




How to compare the result of success function of ajax with a string

So I got this script from the internet that was supposed to make my life easy… but a one day job ended up becoming a 3 day job and this was why:

But… (wait for it)

So in a nutshell: 
Don’t forget to sanitise your results before comparisons…

Can women ever be equal to men?

Original question:

Can women ever be equal to men?


Why I brought this up:

I tweeted:

Clearly my tweet was met with a lot of criticism, especially on Facebook and my close circle of friends. However, the reason why I initially tweeted was based on reading that ISIS was now targeting and recruiting women and also on another reading that more and more women in South Africa were now getting involved in illegal mining.
I meant everything from a good standing ground; that women are mothers of the nation and that as powerful as they are, the need to understand that if they break apart, the who nation will break apart.
However, to a lot of women the whole “men vs women” topic is war. I should have known better.


Favourite answer:

NO, Women can never be equal to men and Men can never be equal to Women. It doesn’t  mean that women is less then men or Vice- versa

Naturally women and men is born with different biology and responsibilities towards the Nature and that is to balance the universe.

Women is born with great mental strength and sustainability which is needed when she delivers a baby, otherwise she will not survive that unbearable pain and delivering a baby is a responsibility that nature has given to her. Same way men are born with higher physical strength which makes them survive in adverse natural conditions and take care of others less powerful. (that is my biological definition for men and women I am not including intelligence or other factors here)

Now,  I see problem where men and women with same intelligence clash with each other, Yes, That’s the area when both can compete with each other with equal force and  intelligence has nothing to do with the gender its only genetics  and that’s how problem has started. There are area’s when men and women try to overpower each other and I think its good for both as far as its a healthy competition.

But as per me , Men and Women are not born to be equal to each other they are born to complement and complete each other

I am simply against any violence or inhumane act against any human. I am against any discrimination based on gender, there should be equal opportunity of good life for both, But competition as in race to prove yourself superior is strict no no.. If one is superior they will get noticed any way.. Men Women both :))

The Myth Called Gender Equality

To say that women are equal to men, is like saying a doctor is equal to an engineer. Yes, both are graduates and professionals, but their functions in the society are different. They should just be proud of what they can and should do, and appreciative of what the other is doing. There is no point in a doctor claiming that he is equal to an engineer and so should be allowed to build a skyscraper, nor in an engineer seeking the privilege to perform a surgery. There were some interesting articles that complained that there aren’t as many takers for women’s cricket as there are for men’s. Of course, if the best of these women’s teams play against the worst of men’s team (at any given level – national or international), it’s not even going to be much of a contest. So the simple fact is that women are not up to men’s level in playing cricket, and so there are few who are interested in watching them play. It has nothing to do with a perceptional bias. If this difference is evident in even something as simple to analyze as a game, then how can we assume equality on a larger scale? I am sure there are other fields in which men are no match for women. This does not make men and women more equal, but adds to the inequality.
I have been reading many articles that ascribed crime against women to a perception of this inequality in the society. In my opinion, this is fallacious reasoning. Hurting or abusing another is always a wrong thing to do – whether or not they are equal. For example, whether or not you consider a manager and a worker who reports to him to be equal or not, it is not acceptable for the manager to abuse the worker, or the other way. I don’t think it’s because they are equal or they’re doing the same job in their organization, but just that it is not okay for anybody to hurt anybody else – be it man or animal or plant – physically or emotionally (or in any other way). Why don’t we stop at that, rather than bring in unsustainable and arbitrary points such as equality? Of course, we can discuss and debate on those lines as much as we want, but let’s not allow our opinion on these abstract concepts (such as equality) to cloud our view on something as down-to-earth as crime and punishment.I don’t think anybody is equal to anybody else. What I believe is that we are all in different stages of evolution (of the soul), and at our current level we have certain responsibilities that help us get to the next level if we gladly play our part, and to our best ability. We are all essentially manifestations of the same spirit, equally loved by God, and deserve to be equally treated by the Law. We’re like gold or diamond in different levels of refinement or polishing. But the equality stops there. Yes, men and women are different, and the society needs them in different roles. To understand and accept our weakness is the key to developing our strengths. That is the way we grow. If anybody cannot see this obvious truth, they’re either closing their eyes to it, or actually blind. To accept this difference and celebrate this diversity is vital to solving the gender issues that the world is facing today.



30 Regex Code Snippets All Web Developers Should Know

Regular expressions are a powerful tool that should be in every developer’s tool belt. They can match against a string of characters based on very complex parameters, which can save you a lot of time when building dynamic websites.

Web developers face different tasks than software developers but many of the same code fundamentals remain. Regular expressions (or regex) do have a steep initial learning curve, but they can be tremendously powerful when used correctly.

The trickiest part is learning the syntax and learning how to write your own regex code from scratch. To save time I’ve organized 30 different regex code snippets that you can incorporate into development projects. And since regex isn’t limited to a single language, you can apply these snippets to anything fromJavaScript to PHP or Python.

1. Password Strength


Checking a password’s strength is often subjective so there is no absolute correct answer. But I feel this regex snippet is a great starting point if you don’t want to write your own password strength checker from scratch.

2. Hexadecimal Color

\#([a-fA-F]|[0-9]){3, 6}

The field of web development is ubiquitous with hex color codes. This regex snippet can be used to pull hex code matches from any string for any purpose.

3. Validate E-mail Address


One of the most common tasks for a developer is to check if a string is formatted in the style of an e-mail address. There are many different variants to accomplish this task, so this SitePoint link offers two distinct code snippets for checking e-mail syntax against a string.

4. IPv4 Address


Similar to an e-mail address is the typical IP address used to identify a specific computer accessing the Internet. This regular expression will check a string to see if it follows the IPv4 address syntax.

5. IPv6 Address


Alternatively you might want to check an address for the newer IPv6 syntax with this more advanced regex snippet. The difference is minor albeit vital during development.

6. Thousands Separator


Traditional numbering systems require a comma, period, or some other mark every third digit in a larger number. This regex code operates on any number and will apply any mark you choose to every third digit separating into thousands, millions, etc.

7. Prepend HTTP to Hyperlink

if (!s.match(/^[a-zA-Z]+:\/\//))
    s = 'http://' + s;

Whether you’re working in JavaScript, Ruby or PHP, this regular expression can prove very helpful. It will check any URL string to see if it has an HTTP/HTTPS prefix, and if not, prepend it accordingly.

8. Pull Domain from URL


Every website domain contains the initial protocol(HTTP or HTTPS) and oftentimes a subdomain plus the additional page path. You can use this snippet to cut through all of that and return just the domain name without extra frills.

9. Sort Keywords by Word Count

^[^\s]*$        matches exactly 1-word keyword
^[^\s]*\s[^\s]*$    matches exactly 2-word keyword
^[^\s]*\s[^\s]*     matches keywords of at least 2 words (2 and more)
^([^\s]*\s){2}[^\s]*$    matches exactly 3-word keyword
^([^\s]*\s){4}[^\s]*$    matches 5-words-and-more keywords (longtail)

Users of Google Analytics and Webmaster Tools will really enjoy this regular expression. It can sort and organize keywords based on the number of words used in a search.

This can be numerically specific (i.e. only 5 words) or it can match a range of words (i.e. 2 or more words). When used to sort analytics data this is one powerful expression.

10. Find a Valid Base64 String in PHP

\?php[ \t]eval\(base64_decode\(\'(([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?){1}\'\)\)\;

If you’re a PHP dev then at some point you may need to parse through code looking for Base64 encoded binary objects. This snippet can be applied to all PHP code and will check for any existing Base64 strings.

11. Valid Phone Number

^\+?\d{1,3}?[- .]?\(?(?:\d{2,3})\)?[- .]?\d\d\d[- .]?\d\d\d\d$

Short, sweet, and to the point. This regex code will validate any traditional phone number syntax based primarily on the American style of phone numbers.

Since this can turn into a fairly complicated subject I recommend skimming this Stack thread for more detailed answers.

12. Leading & Trailing Whitespace

^[ \s]+|[ \s]+$

Use this code snippet to pull out leading/trailing whitespace from a string. This may not be a big deal but sometimes it can affect output when pulled from a database or applied to another document encoding.

13. Pull Image Source

\< *[img][^\>]*[src] *= *[\"\']{0,1}([^\"\'\ >]*)

If for some reason you need to pull out an image’s source straight from HTML, this code snippet is the perfect solution. Although it can run smoothly on the backend, frontend JS devs should instead rely on jQuery’s .attr() method for the frontend.

14. Validate Date in DD/MM/YYYY Format


Dates are tricky because they can appear as text+numbers, or just as numbers with different formats. PHP has a fantastic date function but this isn’t always the best choice when pulling a raw string. Consider instead using this regular expression made for this specific date syntax.

15. YouTube Video ID Match


YouTube has kept the same URL structure for years because it just works. It’s also the most popular video sharing site on the web, so YouTube videos tend to drive the most traffic.

If you need to pull out a YouTube video ID from a URL this regex code is perfect and should work perfectly for all variants of YouTube URL structures.

16. Valid ISBN

/\b(?:ISBN(?:: ?| ))?((?:97[89])?\d{9}[\dx])\b/i

Printed books follow a system of numbering known as ISBN. This can get rather tricky when you consider differences between ISBN-10 and ISBN-13.

However this incredible snippet allows you to validate an ISBN number and check if it’s ISBN10 or 13. All code is written in PHP so this should prove exceptionally useful to web developers.

17. Check Zip Code


The creator of this snippet not only released his work for free, but he also took the time to explain it. You’ll find this snippet useful whether you’re matching a typical 5-digit zip code or the lengthier 9-digit version.

Keep in mind this is meant primarily for the American system of zip codes so this may require adjustments for other countries.

18. Valid Twitter Username


Here’s a very small code snippet for matching against Twitter usernames found in a string. It checks for @mention syntax which is perfect for automatically scanning the contents of a tweet (or tweets).

19. Credit Card Numbers


Validating a credit card number often requires a secure platform hosted elsewhere online. But regex can be used for the minimal requirements of a typical credit card number.

A more comprehensive list of codes for individual cards can be found here. This includes Visa, MasterCard, Discover, and many others.

20. Find CSS Attributes


It may be rare to run regex over CSS but it’s not an incredibly odd situation either.

This code snippet can be used to pull out every matching CSS property and value from individual selectors. It can be used for any number of reasons, possibly to view chunks of CSS or to remove duplicate properties.

21. Strip HTML Comments


If for whatever reason you need to remove all comments from a block of HTML, this is the regex code to use. Along with the expression you’ll find a PHP example using preg_replace.

22. Facebook Profile URL


Facebook is incredibly popular and has gone through many different URL schemes. In a situation where you’re taking profile URLs from users it might be helpful to parse strings and confirm that they’re structured properly. This snippet can do exactly that and it’s perfect for all FB-style links.

23. Check version of Internet Explorer

^.*MSIE [5-8](?:\.[0-9]+)?(?!.*Trident\/[5-9]\.0).*$

Microsoft’s move over to Edge has not been unanimous and many people still rely on classic Internet Explorer. Developers often need to check for versions of IE to handle inconsistencies with rendering engines.

This snippet can be used in JavaScript to test a browser agent based on which version of Internet Explorer (5-11) is being used.

24. Extract Price


Pricing comes in a variety of formats that contain decimals, commas, and currency symbols. This regular expression can check all these different formats to pull out a price from any string.

25. Parse E-mail Header


With this single line of code you can parse through an email header to pull out “to” information from the header. It can be used in tandem with multiple emails joined together.

If you prefer to avoid regex for this task you might instead rely on a parsing library.

26. Match a Particular Filetype


When you’re dealing with various file formats like .xml, .html, and .js, it can help to check files both locally and uploaded by users. This snippet pulls a file extension to check if it’s valid from a series of valid extensions which can be changed as needed.

27. Match a URL String


This snippet can be used both for HTTPS and HTTP strings to check if the text matches up to the traditional TLD domain syntax. There’s also a simple implementation of this regex using JavaScript’s RegExp.

28. Append rel=”nofollow” to Links

(<a\s*(?!.*\brel=)[^>]*)(href="https?://)((?!(?:(?:www\.)?'.implode('|(?:www\.)?', $follow_list).'))[^"]+)"((?!.*\brel=)[^>]*)(?:[^>]*)>

If you’re working with a batch of HTML code it can be gruesome to apply manual labor into repetitive tasks. Regular expressions are perfect for this occasion and they’ll save a whole lot of time.

This snippet can pull all anchor links from a block of HTML and append therel=”nofollow” attribute to every element. The developer who wrote this code was kind enough to publish the raw expression plus a working example in PHP.

29. Media Query Match


Break apart CSS media queries into their parameters and properties. This can help you analyze external CSS in a cleaner fashion with a more direct focus on how the code operates.

30. Google Search Syntax

/([+-]?(?:'.+?'|".+?"|[^+\- ]{1}[^ ]*))/g

You can build your own regex code for manipulating searchable text using Google’s trademark syntax. The plus sign (+) denotes additional keywords and the minus sign (-) denotes words that should be ignored and removed from results.

It’s a rather complicated snippet but used properly it can provide a base for building your own search algorithm.

How to create a sub-domain on zPanel

This is how:
1.   Login to ZPanel as user
2.   Click “Sub Domains
3.   Enter sub-domain prefix and select the domain
4.   Use create new home directory
5.   Click “Create
6.   Now go home
7.   Then click “DNS manager
8.   Select your domain
9.   Under CNAME – You will need to add new record for the prefix of your sub domain
10. Then click “Save Changes

Adding elements to the home page using JavaScript

This is how you go about doing that:

Another alternative method:


jQuery toggle() and addClass()

jQuery .toggle() + addClass()

  • Long Approach


  • Short Approach


  • CSS


  • HTML


« Older posts Newer posts »

Copyright © 2019 Archie Makuwa

Theme by Anders NorenUp ↑