CSS Responsive media queries

Below provided CSS responsive media queries for mobile, tabs, desktops

/*Mobile view*/

@media (min-width : 320px) and (max-width : 480px) {

// related CSS

}

/*Tab view*/

@media (min-width : 480px) and (max-width : 760px) {

// related CSS

}

/*Tab view*/

@media (min-width : 760px) and (max-width : 980px) {

// related CSS

}

/*Desktop view*/

@media (min-width : 980px) and (max-width : 1024px) {

// related CSS

}

Advertisement

Why ‘sudo’ command use in linux ?

In Ubuntu Linux there is not root account configured by default. If users want root account password then they can manually set it up can use ‘sudo’.

‘su’ Vs ‘sudo’

‘su‘ forces you to share your root password to other users whereas ‘sudo‘ makes it possible to execute system commands without root password. ‘sudo‘ lets you use your own password to execute system commands i.e., delegates system responsibility without root password.

Ubuntu basic commands

Below specified basic Ubuntu commands

Change owner

sudo chown user_name modules/ 
Using this command change owner for a particular folder.

sudo chown -R user_name modules/ 
Using this command change owner for a folder along with inner files recursively.

Change permissions 

sudo chmod 777 default/ 
Using this command change permissions for a particular folder or file.

sudo chmod -R 777 default/ 
Using this command change permissions for a folder along with inner files recursively.

Change directory

$ cd default

Goto previous directory

$ cd ..

Get current cirectory

$ pwd

“LESS could not create a directory in public” issue in Drupal

LESS could not create a directory in public://less/51761ea74e5068.61766466/sites/all/themes/theme_name/css

Warning: Invalid argument supplied for foreach() in drupal_pre_render_styles() (line 3311 of /home/seat3/public_html/site_folder/drupal/includes/common.inc).
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 of /home/seat3/public_html/site_folder/drupal/includes/common.inc).

To solve this issue need to give 777 permissions "/var/www/site_folder/htdocs/sites/default" at least need to gave 775.

Your drupal site files directory has to be writable by your webserver.

Below specified "Ubuntu command" for change permissions. 
/var/www/site_folder/htdocs/sites$ sudo chmod -R 777 default/

The main 10 topics in PHP that you can expect questions from are

The main 10 topics in PHP that you can expect questions from are

  1. Loops ( For, Do, While )
  2. Arrays ( Creation, Searching , Different types , sorting )
  3. String functions ( Explode, search etc )
  4. Date & time
  5. Session & Cookies
  6. Mail function
  7. Ajax & Curl
  8. File handling ( Create, delete, write )
  9. Image & File upload
  10. Loop Termination Keywords ( Break, Continue, exit etc

Get user roles in drupal

<?php
global $user;
$role = db_result(db_query(‘SELECT r.name FROM {users_roles} ur LEFT JOIN {role} r ON r.rid=ur.rid WHERE ur.uid=%d LIMIT 1’, $user->uid));
print $role;
?>

<?php
global $user;
print ‘roles: ‘.implode(‘, ‘, $user->roles);
?>

Successful Upload to S3 but error on /system/ajax

I’m trying to use S3 CORS for my project and I’m encountering the error below:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Pagh: /system/ajax
StatusTest: n/a
ResponseText:
Error
Error message
Warning: filesize(): stat failed for s3://file-name.txt in file_save() (line 605 of /srv/bindings/ 8583c5f5083a475a9d644d64d843b077/code/includes/file.inc).
PDOException: SQLSTATE[2300]: Integrity constraint violation: 1062 Duplicate entry ‘s3://file-name.txt’ for key ‘uri’: INSERT INTO {file_managed} (uid, filename, uri, filemie, filesize, status, timestamp, type) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array(
[:db_insert_placeholder_0] = > 1
[:db_insert_placeholder_1] = > file-name.txt
[:db_insert_placeholder_2] = > s3://file-name.txt
[:db_insert_placeholder_3] = > text/plain
[:db_insert_placeholder_4] = > 0
[:db_insert_placeholder_5] = > 0
[:db_insert_placeholder_6] = > 1398930781
[:db_insert_placeholder_7] = > default
)
in drupal_write_record() (line 7211 of /srv/bindings/8583c5f5083a475a9d644d64d843b077/code/includes/common.inc).

The website encountered an unexpected error. Please try again later.
–>

Close
Close
Close

Ready State: undefined

 

Below provided some of alternatives to check this error.

1. Insert the same filename into multiple times.
2. Cause of this issue can be having multiple CORS3 Upload fields on a single form.

 

Getting AWS Access Key ID and Secret Access Key

AWS(Amazon Web Services)

  1. Open the IAM console.
  2. From the navigation menu, click Users.
  3. Select your IAM user name.
  4. Click User Actions, and then click Manage Access Keys.
  5. Click Create Access Key.Your keys will look something like this:
    • Access key ID example: AKIAIOSFODNN7EXAMPLE

    • Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

  6. Click Download Credentials, and store the keys in a secure location.Your secret key will no longer be available through the AWS Management Console; you will have the only copy. Keep it confidential in order to protect your account, and never email it. Do not share it outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your secret key.

Use PHPMailer with gmail authentication

Download PHP Mailer from Here

<?php
require(“includes/class.phpmailer.php”);
$mailer = new PHPMailer();
$mailer->IsSMTP();

$mailer->Host = “smtp.gmail.com:587”;

$mailer->SMTPAuth = TRUE;
$mailer->Username = “{somename}@gmail.com”;  // Change this to your gmail adress
$mailer->Password = “{password}”;  // Change this to your gmail password
$mailer->From = “{someid}@gmail.com”;  // This HAVE TO be your gmail adress
$mailer->FromName = “Avinash”; // This is the from name in the email, you can put anything you like here
$mailer->Body = “This is the main body”;
$mailer->Subject = “This is mail from Avinash”;
$mailer->AddAddress(“{toaddress email id}”);  // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
echo “Message was not sent<br/ >”;
echo “Mailer Error: “ . $mailer->ErrorInfo;
}
else
{
echo “Message has been sent”;
}
?>