Skip to content

Instantly share code, notes, and snippets.

@ansulev
ansulev / 0_reuse_code.js
Created June 12, 2016 14:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ansulev
ansulev / gist:ee2b7215a9dc9c526a8bb061d4b9c408
Created May 16, 2017 03:02 — forked from fennb/gist:1283573
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@ansulev
ansulev / wp-maintenance-mode.php
Last active July 7, 2018 07:24 — forked from digitalinkwell/maintenance-mode.php
Easy put WordPress in Maintenance Mode.
/*
* put this on the very bottom of the functions.php file of your theme
* or create manually .maintenance on your web root with desired message
*/
// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:red">Website under Maintenance</h1><br />We are performing scheduled maintenance. We will be back online shortly!');
}
@ansulev
ansulev / sql2csv
Created June 27, 2018 17:16 — forked from mtth/sql2csv
Parse SQL dump into csv.
#!/usr/bin/env bash
# convert sql dumps to csv, tsv, ssv...
# also can filter fields using a sed pattern
# only works on linux
function usage
{
echo "usage: $0 [-sc CORES] [-o OUTFILE] [-p PATTERN] SQLFILE" 2>&1 && exit 1
}
@ansulev
ansulev / nginx-ps-config
Created September 30, 2018 09:01 — forked from ASergey/nginx-ps-config
Example prestashop 1.6 nginx host config
server {
listen 80;
server_name maxmobiles.lo *.maxmobiles.lo;
root /var/www/maxmobiles.lo;
error_log /var/www/maxmobiles.lo/log/error.log warn;
location / {
index index.html index.php; ## Allow a static html file to be shown first
@ansulev
ansulev / prestashop.conf
Created September 30, 2018 17:01 — forked from julienbourdeau/prestashop.conf
PrestaShop Nginx Configuration
server {
listen 80;
listen [::]:80; #Use this to enable IPv6
server_name www.example.com;
root /var/www/prestashop17;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html;
@ansulev
ansulev / nginx.conf
Created February 15, 2019 06:32 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@ansulev
ansulev / install-photoshop-cs6.md
Last active August 10, 2024 18:07 — forked from romuloctba/readme.md
Install Adobe Photoshop CS6 on Wine (Arch Linux)

Step 1. Install the Wine and Winetricks

  sudo pacman -S wine winetricks

Step 2. Using winetricks to get install dependencies for Photoshop CS6

winetricks atmlib gdiplus msxml3 msxml6 vcrun2005 vcrun2005sp1 vcrun2008 ie6 fontsmooth-rgb gecko
@ansulev
ansulev / install-python-2.7.17.sh
Last active July 21, 2024 11:36 — forked from pigeonflight/install-python-2.7.14.sh
Install Python 2.7.17 on Ubuntu 14.04
# usage
# bash install-python-2.7.17.sh
sudo apt-get update
sudo apt-get install build-essential checkinstall -y
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
cd /usr/src
sudo wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tgz
sudo tar xzf Python-2.7.17.tgz
cd Python-2.7.17
sudo ./configure --enable-optimizations
@ansulev
ansulev / mysql.txt
Created October 11, 2021 05:39 — forked from sarvar/mysql.txt
Changing WordPress URLs in MySQL Database
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');
UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');