Skip to content

Instantly share code, notes, and snippets.

View nagiyevelchin's full-sized avatar
🌴
On vacation

Elchin Nagiyev nagiyevelchin

🌴
On vacation
View GitHub Profile
@nagiyevelchin
nagiyevelchin / glog-pod-install-problem.md
Last active November 9, 2023 11:27
Troubleshooting glog Installation Failure in React Native on macOS

When attempting to set up a new React Native project using npx react-native init projectName or executing pod install within the iOS folder, you may encounter a frustrating roadblock during the pod install phase, specifically with glog on macOS. The error typically looks like this:

-> Installing glog (0.3.5)
...
...
patching file config.sub
Hunk #1 FAILED at 1096.
1 out of 1 hunk FAILED -- saving rejects to file config.sub.rej
@nagiyevelchin
nagiyevelchin / Removing LibreOffice and Installing It with a PPA on Ubuntu.sh
Created October 25, 2023 12:22
Learn how to uninstall LibreOffice, remove residual files, add a PPA for LibreOffice, update your package list, and install LibreOffice on your Ubuntu system using these Bash commands.
# Remove LibreOffice and its components
sudo apt remove --purge libreoffice* -y
# Perform an autoremove to clean up unnecessary packages
sudo apt autoremove -y
# Run autoclean to remove old package files
sudo apt autoclean -y
# Add the LibreOffice PPA to get the latest version
@nagiyevelchin
nagiyevelchin / postgresql_backup.sh
Last active October 7, 2023 08:43
This script is a combination of tasks, including cleaning up old log and backup files, performing a PostgreSQL database dump, compressing the dump, and uploading files to an SFTP server. Make sure to replace SFTP_USER=user SFTP_PASSWORD=******** with your actual SFTP user name and password for security.
#!/bin/bash
# ----------------------------------------------------------------------- #
# Automate PostgreSQL Database Backups to Secure SFTP Server. #
# ----------------------------------------------------------------------- #
# This Bash script simplifies the process of backing up #
# your PostgreSQL database by automating the entire workflow. #
# It cleans up old log and backup files, performs a secure database dump, #
# compresses the backup, and uploads it to a remote SFTP server. #
# Ensure data integrity and easy retrieval with this efficient script. #
@nagiyevelchin
nagiyevelchin / mysql_backup.sh
Last active October 7, 2023 11:04
This script is a combination of tasks, including cleaning up old log and backup files, performing a MySQL database dump, compressing the dump, and uploading files to an SFTP server. Make sure to replace MYSQL_USER=mysql MYSQL_PASSWORD=mysql SFTP_USER=user SFTP_PASSWORD=******** with your actual user names and passwords for security.
#!/bin/bash
# ----------------------------------------------------------------------- #
# Automate MySQL Database Backups to Secure SFTP Server. #
# ----------------------------------------------------------------------- #
# This Bash script simplifies the process of backing up #
# your MySQL database by automating the entire workflow. #
# It cleans up old log and backup files, performs a secure database dump, #
# compresses the backup, and uploads it to a remote SFTP server. #
# Ensure data integrity and easy retrieval with this efficient script. #
# Header set X-Robots-Tag "noindex, nofollow"
Header set X-Frame-Options SAMEORIGIN
Header set X-Content-Type-Options nosniff
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Security-Policy "allow 'self';"
Header set X-WebKit-CSP "allow 'self';"
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "GET, POST"
@nagiyevelchin
nagiyevelchin / image-resize.js
Created September 1, 2019 12:52
Resizing image in user side in Vue CLI JavaScript
/**
* Resizing image in user side
* @param {string} filePath - file input value
* @param {number} [max_width=1600] - result image max width
* @param {number} [max_height=900] - result image max height
* @returns {Promise<base64string>}
*/
export default (filePath, max_width, max_height) => {
/**
* Example
@nagiyevelchin
nagiyevelchin / PHPMailYandex.php
Created July 12, 2019 06:53
PHPMail Yandex send through smtp and save sent mail in imap folder
<?php
print "<pre>";
$mbox = imap_open("{imap.yandex.ru}/ONE", "***@yandex.ru", "****", OP_HALFOPEN)
or die("can't connect: " . imap_last_error());
$list = imap_getmailboxes($mbox, "{imap.yandex.ru}", "*");
if (is_array($list)) {
print_r($list);
} else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}
@nagiyevelchin
nagiyevelchin / ready.php
Last active July 11, 2019 10:57
ProcessWire multiple domain multiple language
<?php
//paste it in "site/ready.php" file
$wire->addHookAfter('Page::render', function (\ProcessWire\HookEvent $event) {
if (strpos(wire('config')->urls->httpRoot, '.com') !== false && wire('user')->language->name !== 'default') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".wire('page')->localHttpUrl('default'));
exit();
} elseif (strpos(wire('config')->urls->httpRoot, '.ru') !== false && wire('user')->language->name !== 'ru') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".wire('page')->localHttpUrl('ru'));
@nagiyevelchin
nagiyevelchin / PHPMailGmail.php
Last active February 12, 2022 15:58
PHPMailer Gmail working example PHP
<?php
/**
* PHPMailer Gmail working example
*
* composer require phpmailer/phpmailer
*
*/
require 'autoload.php';
@nagiyevelchin
nagiyevelchin / mkdir.php
Last active February 12, 2022 15:59
Recursively create directory in PHP
<?php
/**
* Makes directory
* @link http://stackoverflow.com/questions/5425891/check-if-directory-exists-php
* @param string $pathname The directory path.
* @param int $mode [optional]<p>
* The mode is 0777 by default, which means the widest possible
* access. For more information on modes, read the details
* on the <b>chmod</b> page.
* </p>