Linux – chown directory for multiple users
Create a new group for users (run commands with root rights): groupadd testgroup gpasswd -a user1 testgroup gpasswd -a user2 testgroup gpasswd -a user3 testgroup…
Create a new group for users (run commands with root rights): groupadd testgroup gpasswd -a user1 testgroup gpasswd -a user2 testgroup gpasswd -a user3 testgroup…
Regular expression for IP address: Regex for IPv4 /^((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?1)){3}\z/ Regex for IPv6 /^(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})\z/i
The “official” fool-proof regex to match email addresses known as RFC 5322: (?:[a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)* | “(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f] | \\[\x01-\x09\x0b\x0c\x0e-\x7f])*”) @ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])? | \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3} (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]: (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f] | \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)…
Create a simple function that get the client time (hours:minutes:seconds) and prints it in the div: <script type=”text/javascript”> function getTime() { var currentDate = new…
Add a custom right-click function to a web application. Also can be used to implemen a custom menu opened on right-click: <script language=”javascript” type=”text/javascript”> document.oncontextmenu…
The expression bellow can be used to extract paragraphs information from a html document. This expression can be changed to be applied to other HTML…
Get duplicate id’s in DOM using jQuery // Warning Duplicate IDs $(‘[id]’).each(function(){ var ids = $(‘[id=”‘+this.id+'”]’); if(ids.length > 1 && ids[0] == this) console.warn(‘Multiple IDs…
Zend Framework 1 – trace sql errors and exceptions and put them in a log file. Add the next code in the ErrorController.php: <?php class…
Create a new simple rule for jquery.validator plugin by doing something like this: jQuery.validator.addMethod(“greaterThanZero”, function(value, element) { return this.optional(element) || (parseFloat(value) > 0); }, “*…
A very useful snippet code to strip html tags using Javascript: var strippedString = string.replace(/(]+)>)/ig,””); Read entire article and commentshere