Skip to content

Instantly share code, notes, and snippets.

View gnanet's full-sized avatar

Gergely Nagy gnanet

  • Self-Employed Freelancer
  • Hungary
  • X @gnanet
View GitHub Profile
@gnanet
gnanet / dns_dotroll.sh
Last active June 9, 2023 05:09 — forked from scr34m/dns_dotroll.sh
Acme.sh DNS API interface for Dotroll
#!/usr/bin/bash
# Dotroll domain api
# - api access values stored per domain, including migration from account stored values
# - zone data is POST-ed to avoid "414 Request-URI Too Large" errors
#
# Initially export values Dotroll_User and Dotroll_Password
# export Dotroll_User='<your.dotroll@user>'; export Dotroll_Password='<dotroll_api_password>'; acme.sh --issue --dns dns_dotroll -d <domain.tld> -d '*.<domain.tld>'
# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
@gnanet
gnanet / pleskCommands.sh
Created October 22, 2019 23:43 — forked from AlexPashley/pleskCommands.sh
PLESK: Useful PLESK common commands
# USEFUL PLESK COMMANDS
# restart plesk
/etc/init.d/psa restart
# reload plesk configs (useful for vhost.conf)
/usr/local/psa/admin/sbin/websrvmng -a -v
# restart qmail
service qmail restart
@gnanet
gnanet / download.php
Created September 1, 2018 19:48 — forked from tosinafolabi/download.php
Force File Download with PHP
<?php
/*
* Force File Download
* Usage: http://example.com/download.php?file=./uploads/image.jpg
*
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary
*
*/
// grab the requested file's name
log_format postdata '$time_local $request $request_body';
location = /path {
access_log /var/log/nginx/postdata.log postdata;
proxy_pass http://localhost:8080; # <= set your port
}
@gnanet
gnanet / wpai-run-imports.sh
Created January 29, 2018 01:17 — forked from onnimonni/wpai-run-imports.sh
Helper bash script which you can use to run wp all import synchronously. This also outputs problems which you may have with wpai.
#!/bin/bash
##
# Script to run WP All Import scripts sychronously with cron
##
# This is default wp core directory for us
ABSPATH="/var/www/project/wp"
function usage()
{
@gnanet
gnanet / gist:8c0781418fce05ba4632255e9d8c3b98
Created September 25, 2017 21:20 — forked from jchristopher/gist:676652d094264a3e8853
find out if there was an exact match of a SearchWP term
<?php
// find out if there was an exact match
global $wpdb;
if ( defined( 'SEARCHWP_DBPREFIX' ) && SEARCHWP_DBPREFIX ) {
$searchwp_terms_table = $wpdb->prefix . SEARCHWP_DBPREFIX . 'terms';
$search_query = sanitize_text_field( get_search_query() );
$search_sql = "SELECT id FROM {$searchwp_terms_table} WHERE term = %s";
$term_found = $wpdb->get_var( $wpdb->prepare( $search_sql, $search_query ) );
$exact_match = is_null( $term_found ) ? false : true;
@gnanet
gnanet / .htaccess
Created September 24, 2017 22:25 — forked from adamzr/.htaccess
Add Link headers to preload content
<IfModule mod_headers.c>
Header add Link "</service-worker.js>; rel=preload;"
Header add Link "</favicon-16x16.png>; rel=preload;"
Header add Link "</favicon-96x96.png>; rel=preload;"
Header add Link "</android-chrome-192x192.png>; rel=preload;"
Header add Link "<https://cdn.ampproject.org/v0.js>; rel=preload; crossorigin"
Header add Link "<https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface>; rel=preload; crossorigin"
Header add Link "<https://cdn.ampproject.org/v0/amp-analytics-0.1.js>; rel=preload; crossorigin"
Header add Link "<https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js>; rel=preload; crossorigin"
Header add Link "<https://fonts.gstatic.com/s/abrilfatface/v8/X1g_KwGeBV3ajZIXQ9VnDgYWpCd0FFfjqwFBDnEN0bM.woff2>; rel=preload; crossorigin"
@gnanet
gnanet / critical-css.js
Created September 1, 2017 05:56 — forked from kostasxyz/critical-css.js
Select all elements above the fold and append matched css rules in header
(function () {
document.addEventListener('DOMContentLoaded', function(){
var stylesheets = document.styleSheets;
var wHeight = window.innerHeight;
var criticalCSS = '';
var uniqueRules = [];
var criticalRules = [];
console.log(stylesheets);
@gnanet
gnanet / critical.js
Created September 1, 2017 05:52 — forked from zanonnicola/critical.js
Detecting Critical CSS For Above-the-Fold Content.
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@gnanet
gnanet / compare_file_age.sh
Created July 19, 2017 18:08 — forked from ashrithr/compare_file_age.sh
bash function to compare if a file is older than 28 hours or not
#######BEGIN SCRIPT############
#!/bin/bash
# This checks that the specified file is less than 28 hours old.
# returns 0 if younger than 28 hours.
# returns 1 if older than 28 hours.
#funtion arguments -> filename to comapre against curr time
function comparedate() {
if [ ! -f $1 ]; then
echo "file $1 does not exist"