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
server {
listen 80 default_server;
listen [::]:80 default_server;
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
@ansulev
ansulev / install-lemp-arch-linux.txt
Created April 30, 2017 14:09
How to Install (LEMP) NginX, MySQL, PHP stack on Arch Linux
# How to Install (LEMP) NginX, MySQL, PHP stack on Arch Linux
@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 / nginx-force-non-www-ssl-pwsite.conf
Last active August 27, 2017 12:42
Nginx site configuration for ProcessWire with forced SSL and www to non-www redirect
# nginx site config for processwire with forced SSL and www to non-redirect
# redirect from www to non-www forced SSL
# uncomment, save file and restart Nginx to enable
# if unsure use return 302 before using return 301
server {
server_name domain.com www.domain.com;
return 301 https://$server_name$request_uri;
}
@ansulev
ansulev / getBlockLists.sh
Last active December 10, 2017 09:03
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# inspired by https://gist.github.com/johntyree/3331662#gistcomment-1968023
# created by https://gist.github.com/glaszig/bf96beccf4694ae25d4f1f7cc6224985
# usage:
# getBlockLists.sh > /tmp/blockp2p.list
# or
# getBlockLists.sh | gzip -9 > /tmp/blockp2p.list.gz
# daily updated: https://silo.glasz.org/antip2p.list.gz
#
@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 / pdostatement.php
Last active July 7, 2018 07:20
PDOStatement:execute - simplified $placeholder form
<?php
/*
*from
* http://php.net/manual/en/pdostatement.execute.php#111823
* simplified $placeholder form
*/
$data = ['a'=>'foo','b'=>'bar'];
$keys = array_keys($data);
@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 / wordpress-pinglist.txt
Last active July 10, 2018 08:15
WordPress ping list update - June 2017
http://bing.com/webmaster/ping.aspx
http://ping.blo.gs/
http://blog.goo.ne.jp/XMLRPC
http://blog.with2.net/ping.php
http://blogping.unidatum.com/RPC2
http://blogpingr.de/ping/rpc2
https://ping.blogs.yandex.ru/RPC2
http://blogsearch.google.co.cr/ping/RPC2
http://blogsearch.google.co.hu/ping/RPC2
http://api.moreover.com/ping