Skip to content

Instantly share code, notes, and snippets.

@codezixo
codezixo / .htaccess
Last active Mar 27, 2016 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
View .htaccess
#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/
@codezixo
codezixo / howto.sh
Created Mar 28, 2016
Percona innobackupex Xtrabackup
View howto.sh
# backup
innobackupex --stream=xbstream --parallel=4 --compress --compress-threads=2 /var/lib/mysql > /root/backup/backup.xbstream
# restore
xbstream -x < /root/backup/backup.xbstream
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum install qpress
for i in $(find -name "*.qp"); do qpress -vd $i $(dirname ${i}) && rm -f $i; done
innobackupex --apply-log ./
service mysql stop
View setup.sh
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
View dns-ms-check.sh
#!/usr/bin/bash
dns_server="@IP DNS SERVER 1@"
while [ -n "$dns_server" ]; do
ping -q -c 1 $dns_server | while read pong; do echo "$(TZ='Europe/Moscow' date): $pong" » ./ck_dns_test.out; done
host -t A @DNS MANE OF YOUR HOST@ $dns_server | while read myhost; do echo "$(TZ='Europe/Moscow' date): $myhost" » ./ck_dns_test.out; echo $myhost; done
echo '' » ./ck_dns_test.out
case "$dns_server" in
@IP DNS SERVER 1@)
dns_server="@IP DNS SERVER 2@"
View master-slave-sync.sh
# @ master
DB=dbname
SLAVE=root@slave
TMPFILE=/tmp/dbdump.sql.gz
mysql -u root -p -e "RESET MASTER; FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS;" $DB
mysqldump -u root -p --lock-all-tables $DB | gzip > $TMPFILE
mysql -u root -p -e "UNLOCK TABLES;" $DB
scp $TMPFILE $SLAVE:/tmp/
rm $TMPFILE
@codezixo
codezixo / Breadcrumbs.php
Created Nov 8, 2017 — forked from jonpugh/Breadcrumbs.php
Add Taxonomy Term to a Node's Breadcrumb in Drupal 8
View Breadcrumbs.php
<?php
// src/Breadcrumbs.php
namespace Drupal\modulename;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;
@codezixo
codezixo / imagemagick.bash
Created May 4, 2018 — forked from bensie/imagemagick.bash
ImageMagick Static Binaries for AWS Lambda
View imagemagick.bash
#!/usr/bin/env bash
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime
# As of Nov 23, 2015, this is Amazon Linux AMI 2014.09.2 x86_64 (ami-0c682c64)
#
# Lambda includes ImageMagick 6.7.8-9 preinstalled, so you need to prepend PATH
# with the folder containing these binaries in your Lambda function to ensure
# these newer binaries are used.
sudo yum -y install libpng-devel libjpeg-devel libtiff-devel gcc
@codezixo
codezixo / gist:bc9d63aff010dce21051487def836e29
Created Aug 9, 2018 — forked from phayes/gist:2770495
Manually rendering ctools-content-type
View gist:bc9d63aff010dce21051487def836e29
<?
ctools_include('plugins');
ctools_include('context');
ctools_include('content');
$plugin_id = 'super_pane';
$plugin = ctools_get_plugins('ctools','content_types', $this->options['field'], $plugin_id);
$conf = array() // array of configuration to pass to the content-type
View My Exiftool Cheatsheet.md

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@codezixo
codezixo / netspeed.sh
Created Oct 6, 2018 — forked from tazhate/netspeed.sh
netspeed.sh : check download speed rate via command line | Linux bash script
View netspeed.sh
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-09
#
# _______________| netspeed : check download speed via command line.
#
# Usage: netspeed [tokyo, london, usw, use, east, west, URL]
# ^default U.S. west coast.
# [ -speed_KB/sec ]
# ^negation activates the Mbps converter.
#