Skip to content

Instantly share code, notes, and snippets.

<?php
$serverName = "MOHANA-LAPTOP\SQLEXPRESS";
$connectionInfo = array("Database" => "test", "UID" => "sa", "PWD"=>"123456");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn) {
echo "Connection established .. :)";
} else {
echo "Connection could not be established :(";
dir(print_r(sqlsrv_errors(), true));

Swappiness

# The default swappiness in Ubuntu 60. Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended, but feel free to experiment.
# Checkout swappiness value
cat /proc/sys/vm/swappiness

# Switch swap off
sudo swapoff -a
@mcjwsk
mcjwsk / clearlogs.sql
Last active April 22, 2021 20:57
magento
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
@dleone81
dleone81 / reindexall.sh
Created March 11, 2016 08:48
Avoid Magento
#!/bin/bash
# This file reindex all Magento indexes without any lock table
# This is the right order to reindexall via script
# I update every 3 sec any Magento product via API.
# Before this script I noticed this error
# SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
echo "Reindexall via script"
php /mage/magento/shell/indexer.php --reindex cataloginventory_stock
php /mage/magento/shell/indexer.php --reindex catalog_product_attribute
@LauLaman
LauLaman / gpg.md
Last active March 7, 2023 14:42
Use GPG to sign commits using git & PHPStorm

1 - install GPG tools : https://gpgtools.org/

2 - Create new key for your github email

3 - Add key to git on your local machine: git config --global user.signingkey YOURKEY

4 - configure git to sign all commits: git config --global commit.gpgsign true

5 - add to the bottom of ~/.gnupg/gpg.conf: (create the file if it not exists)

@sergiojovanig
sergiojovanig / magento2-deploy.sh
Last active March 18, 2021 12:36
Deploy Magento 2 steps
php bin/magento setup:backup --db
gzip var/backups/*.sql
git pull
php bin/magento maintenance:enable
php bin/magento cache:enable
rm -fr var/di var/generation var/cache
php bin/magento setup:di:compile
php bin/magento deploy:mode:set production --skip-compilation
php bin/magento maintenance:enable
php bin/magento setup:upgrade
@jcberthon
jcberthon / networkmanager-wifi-powersave.md
Last active May 7, 2025 12:45
NetworkManager Wi-Fi powersaving configuration

NetworkManager WiFi Power Saving

NetworkManager supports WiFi powersaving but the function is rather undocumented.

From the source code: wifi.powersave can have the following value:

  • NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
  • NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
  • NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
@rafaelstz
rafaelstz / magento2-truncate.sql
Created August 29, 2017 14:40
Magento 2 truncate customers, products, reviews and orders table
SET FOREIGN_KEY_CHECKS = 0;
-- Truncate order tables
TRUNCATE TABLE `gift_message`;
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
@holmberd
holmberd / php-pools.md
Last active April 29, 2025 08:29
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log