Skip to content

Instantly share code, notes, and snippets.

View serhiijko's full-sized avatar

Serhii serhiijko

  • Kyiv, Ukraine
View GitHub Profile
@serhiijko
serhiijko / scaling_php_application.conf
Created November 3, 2018 20:21 — forked from khoatran/scaling_php_application.conf
Configuring Nginx to be a Cache for PHP-FPM
# This is the sample from Scaling PHP applications book
#Set the path where the cache is stored; Set the zone name(my_app), totalsize (100m),and max life time(60m)
fastcgi_cache_path /tmp/cachelevels=1:2keys_zone=my_app:100minactive=60m;
#Set the cache key used,in this case: httpsGETtest.com/somepage.html
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server{
listen 80;
@serhiijko
serhiijko / remember-passphrase.sh
Created November 3, 2018 20:21 — forked from khoatran/remember-passphrase.sh
Remember passphrase of your ssh key
ssh-add ~/.ssh/id_rsa &>/dev/null
function qtrans_disable(){
global $typenow, $pagenow;
if (in_array($typenow, array('teacher'))) {
remove_action('add_meta_boxes', 'qtranxf_add_meta_box_LSB');
remove_action('admin_head-nav-menus.php', 'qtranxf_add_nav_menu_metabox');
remove_action('admin_head', 'qtranxf_admin_head');
remove_filter('admin_footer', 'qtranxf_admin_footer', 999);
remove_filter('the_editor', 'qtranxf_the_editor');
}
$main_args = [
'post_type' => 'lectures',
'posts_per_page' => -1,
'orderby' => 'bydate',
'order' => 'ASC',
'meta_query' => [
'bydate' => [
'key' => 'date',
'value' => date("Y/m/d"),
'compare' => '>=',
<?php
add_action( 'pre_get_posts', function( $q )
{
if( $title = $q->get( '_meta_or_title' ) )
{
add_filter( 'get_meta_sql', function( $sql ) use ( $title )
{
global $wpdb;
// Only run once:
@serhiijko
serhiijko / wget-snapshotpage.md
Created December 28, 2018 15:38 — forked from dannguyen/wget-snapshotpage.md
Use wget to snapshot a page and its necessary visual dependencies

Use wget to mirror a single page and its visible dependencies (images, styles)

Money graphic via State of Florida CFO Vendor Payment Search

Graphic via State of Florida CFO Vendor Payment Search (flair.myfloridacfo.com)

This is a quick command I use to snapshot webpages that have a fun image I want to keep for my own collection of WTFViz. Why not just right-click and save the image? Oftentimes, the webpage in which the image is embedded contains necessary context, such as captions and links to important documentation just incase you forget what exactly that fun graphic was trying to explain.

@serhiijko
serhiijko / .htaccess
Created January 5, 2019 11:26 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
@serhiijko
serhiijko / functions.php
Created May 16, 2019 23:07 — forked from jaredatch/functions.php
WordPress Search Autocomplete using admin-ajax.php
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@serhiijko
serhiijko / letsencrypt_2019.md
Created May 17, 2019 21:12 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files: