G31 Zone
  • About
  • Contact

Linux – chown directory for multiple users

Posted on: March 6, 2015 /
Categories: Linux

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 … Make that group the group owner of the directory (with root rights): chown -R user1:testgroup /your/directory Make the group writeable (with root rights): chmod -R g+w /your/directory

Regular expression for IP address

Posted on: September 12, 2014 /
Categories: Regular expression (Regex)

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

Regex to match email addresses

Posted on: September 11, 2014 /
Categories: Regular expression (Regex)

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])+) \]) A more practical implementation of RFC 5322 if we omit the syntax using double quotes and square brackets. It will still match 99.99% of all email addresses in actual

Read More →

Javascript simple clock

Posted on: September 10, 2014 /
Categories: JavaScript

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 Date(); var hour = currentDate.getHours(); var min = currentDate.getMinutes(); var sec = currentDate.getSeconds(); var currentTime = hour + “:” + min + “:” + sec; document.getElementById(‘clock’).innerHTML = currentTime; } setInterval(“getTime()”,

Read More →

Add a custom right-click function to a web application

Posted on: September 9, 2014 /
Categories: JavaScript

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 = RightMouseDown; document.onmousedown = mouseDown; function mouseDown(e) { if (e.which == 3) {//righClick console.log(“Right-click goes here”); } } function RightMouseDown() { console.log(“Right-click Context goes here”); return false; } </script>

Regular Expression for html paragraph

Posted on: October 7, 2013 /
Categories: Regular expression (Regex)

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 tags. preg_match(‘/(]*>.*?)/i’, $subject, $matches);

Get duplicate id’s in DOM using jQuery

Posted on: September 16, 2013 /
Categories: JQuery

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 #’+this.id); });

Zend Framework 1 – trace and log sql errors and exceptions

Posted on: August 12, 2013 /
Categories: Zend

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 ErrorController extends Zend_Controller_Action { … public function errorAction() { … if (get_class($errors->exception) == ‘Zend_Db_Statement_Exception’) { $writer = new Zend_Log_Writer_Stream(“ADD HERE YOUR LOG PATH”); $logger = new Zend_Log($writer); $logger->info($errors->exception); } …

Read More →

Create a new rule for jquery.validator plugin

Posted on: July 24, 2013 /
Categories: JQuery

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); }, “* Amount must be greater than zero”); Apply the new rule: $(‘validatorElement’).validate({ rules : { amount : { greaterThanZero : true } } });

Javascript strip tags

Posted on: July 1, 2013 /
Categories: JavaScript

A very useful snippet code to strip html tags using Javascript: var strippedString = string.replace(/(]+)>)/ig,””); Read entire article and commentshere

« 1 2 3 4 … 9 »

Categories

  • Apache
  • CentOS
  • Git
  • HTML
  • HTTP
  • JavaScript
  • JQuery
  • Linux
  • Magento
  • MySQL
  • PHP
  • Regular expression (Regex)
  • Smarty
  • Symfony 2 / Doctrine
  • Twig
  • Ubuntu
  • Uncategorized
  • Zend

Archives

  • June 2015
  • May 2015
  • March 2015
  • September 2014
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • January 2013
  • October 2012
  • August 2012
  • May 2012
  • April 2012
  • January 2012
  • December 2011
  • November 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010

Recent Posts

  • Connect to VPN from Linux
  • Enable slow query log on MySQL server
  • Doctrine Console Commands
  • Symfony2 Doctrine debug query
  • Mysqldump only tables with certain prefix

Tags

404 not found error apache bundled categories category cms tags command line confirm contact form countries create user customer group name customer logged in disable right click export database front controller git image uploader import database incorrect url JavaScript jquery jquery ajax request Magento mysql mysql show user privileges no right click parameters php print array product attribute product images products read files read folders regions script script execution time session smarty smarty print array stores subcategories tinymce url

Copyright G31 Zone 2022 | Theme by Theme in Progress | Proudly powered by WordPress