Skip to content

Instantly share code, notes, and snippets.

View hn-support's full-sized avatar

Hypernode Support hn-support

View GitHub Profile
@hn-support
hn-support / use-geoip-data-in.php
Last active January 14, 2019 08:38
How to use geoip data in php on hypernodes
<?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 12:47 — forked from gwillem/check-enough-space.sh
Create Hypernode copy of live site
#!/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 April 12, 2017 16:08
Robots.txt for multisite magento 1 installations
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 December 26, 2020 18:19
Debug script to log all cron output to a logfile
#!/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 January 13, 2018 03:04
block version control directory on apache2
<Directorymatch "^/(.*/)*\.(git|svn)/">
  Order deny,allow
  Deny from all 
</Directorymatch>
@hn-support
hn-support / block-version-control-on-nginx.md
Last active January 13, 2018 03:05
block version control directory on nginx
# Skip .git, .htpasswd etc
location ~ /\.(git|svn|ht) {
    return 404;
}
@hn-support
hn-support / redis-sessions-magento.xml
Last active December 9, 2016 14:44
Setup redis sessions for Magento 1
<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 13:05
Verify curl ssl connections with 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 January 11, 2017 12:47
A cache warmer in bash using curl
#!/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 May 6, 2024 10:20
A threaded cache warmer in python
#!/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