Skip to content

Instantly share code, notes, and snippets.

Avatar

Hypernode Support hn-support

View GitHub Profile
@hn-support
hn-support / use-geoip-data-in.php
Last active Jan 14, 2019
How to use geoip data in php on hypernodes
View use-geoip-data-in.php
<?php
/*
This script is a basic example of how to use GeoIP data in PHP.
It returns an overview of all available constants retrieved from the Maxmind GeoIP databases.
*/
$elements = array(
"country_code" => getenv('GEOIP_COUNTRY_CODE'),
"country_code3" => getenv('GEOIP_COUNTRY_CODE3'),
"country_name" => getenv('GEOIP_COUNTRY_NAME'),
@hn-support
hn-support / check-enough-space.sh
Last active May 3, 2017 — forked from gwillem/check-enough-space.sh
Create Hypernode copy of live site
View check-enough-space.sh
#!/bin/bash
# This script checks if there is enough diskspace available on your hypernode
# to create a basic staging environment as explained in
# - https://support.hypernode.com/knowledgebase/using-a-basic-staging-environment-magento1/
# and
# - https://support.hypernode.com/knowledgebase/using-a-basic-staging-environment-magento2/
# To use it, download or copy the script and make it executable.
# is there enough space?
DBNAME=$(magerun --root-dir=~/public db:info dbname)
@hn-support
hn-support / server.robots.md
Last active Apr 12, 2017
Robots.txt for multisite magento 1 installations
View server.robots.md
location /robots.txt { return 200 "### Autogenerated robots.txt\n

# Sitemap
Sitemap: https://$http_host/sitemap.xml

# Crawlers Setup
User-agent: *
Crawl-delay: 20
@hn-support
hn-support / cron-debugger.sh
Last active Dec 26, 2020
Debug script to log all cron output to a logfile
View cron-debugger.sh
#!/bin/bash
# This script is a debug utility for cronjobs as explained in:
# - https://support.hypernode.com/knowledgebase/configure-cronjobs-on-hypernode/
# It logs all output and timing to a log file
#
# To use it, download the script, add the executable bit and put it in your cronjob:
# */5 * * * * /data/web/bin/debug-cron php -f /data/web/public/cron.php
LOGDIR="/data/web/public/var/log/crons"
TIMESTAMP="$( date '+%Y%m%d%H%M' )"
@hn-support
hn-support / block-version-control-on-apache2.md
Last active Jan 13, 2018
block version control directory on apache2
View block-version-control-on-apache2.md
<Directorymatch "^/(.*/)*\.(git|svn)/">
  Order deny,allow
  Deny from all 
</Directorymatch>
@hn-support
hn-support / block-version-control-on-nginx.md
Last active Jan 13, 2018
block version control directory on nginx
View block-version-control-on-nginx.md
# Skip .git, .htpasswd etc
location ~ /\.(git|svn|ht) {
    return 404;
}
@hn-support
hn-support / redis-sessions-magento.xml
Last active Dec 9, 2016
Setup redis sessions for Magento 1
View redis-sessions-magento.xml
<session_save>db</session_save>
<redis_session>
<host>redismaster</host>
<port>6379</port>
<password></password>
<timeout>2.5</timeout>
<persistent></persistent>
<db>2</db>
<compression_threshold>2048</compression_threshold>
<compression_lib>gzip</compression_lib>
@hn-support
hn-support / testtls.php
Last active May 3, 2017
Verify curl ssl connections with php
View testtls.php
<?php
/*
This script tests whether your php installation is able to create TLS connections.
*/
foreach ([6, 7, 8] as $version) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://tlstest.paypal.com/");
curl_setopt($ch, CURLOPT_SSLVERSION, $version);
var_dump(curl_exec($ch));
var_dump(curl_error($ch));
@hn-support
hn-support / cache-warmer.sh
Created Jan 11, 2017
A cache warmer in bash using curl
View cache-warmer.sh
#!/bin/bash
if [ "$#" -ne 1 ] || [ "x$1" == "x" ] ; then
echo "Usage: $0 <sitemap.xml>"
exit 0;
fi
if [ ! -f "$1" ]; then
echo "Sitemap file $1 not found! Exit!"
exit 1
@hn-support
hn-support / cache-warmer.py
Last active Sep 23, 2020
A threaded cache warmer in python
View cache-warmer.py
#!/usr/bin/env python
"""
Warm the caches of your website by crawling each page defined in sitemap.xml.
To use, download this file and make it executable. Then run:
./cache-warmer.py --threads 4 --file /data/web/public/sitemap.xml -v
"""
import argparse
import multiprocessing.pool as mpool
import os.path
import re