Skip to content

Instantly share code, notes, and snippets.

@karlgray
karlgray / wp-xml-to-html
Last active March 31, 2016 03:00
Quick hack to extract wordpress posts from xml to separate html files.
#!/usr/bin/php -q
<?php
/* Really nasty, really fast hack to extract all wordpress articles to .html files.
* Please test before using. It worked for a particular site to save time copy and pasting.
* There is no garantee it will work for you.
*
* Note this a php CLI script don't run from browser.
*
* I then used this to convert them to markdown files.
* find ./ -iname "*.html" -type f -exec sh -c 'pandoc "${0}" -o "./markdown/$(basename ${0%.html}.md)"' {} \;
@karlgray
karlgray / prepare-server.sh
Last active April 29, 2016 17:14
Prepare a Centos 6.7 Server
#!/bin/bash
yum -y update
yum -y install vim wget curl
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum -y install Percona-Server-server-56
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum -y install https://mirror.webtatic.com/yum/el6/latest.rpm
yum -y install php56w php56w-opcache php56w-fpm php56w-mysql mlocate vim redis php56w-pecl-redis memcached
yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum -y install monit
@karlgray
karlgray / gray.repo
Last active April 27, 2016 14:26
Repo for custom rpms for clients.
[yum.gray.me.uk]
name=Gray Repos
baseurl=http://yum.gray.me.uk/
gpgcheck=1
#repo_gpgcheck=1
gpgkey=http://yum.gray.me.uk/RPM-GPG-KEY-karl-rpm.txt
enabled=1
@karlgray
karlgray / letsencrypt.sh
Created April 27, 2016 15:06
Install letsencrypt on Centos 6.7
#!/bin/bash
yum -y install https://rhel6.iuscommunity.org/ius-release.rpm
yum --enablerepo=ius install git python27 python27-devel python27-pip python27-setuptools python27-virtualenv -y
yum install git
cd /root/
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt/
./letsencrypt-auto certonly -d secure.domain.co.uk
@karlgray
karlgray / MY_Model.php
Created October 27, 2018 17:10 — forked from codersatx/MY_Model.php
My base model class for my CodeIgniter-based cms.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* My Model
*
* Used as a base class for all admin or app related model functions.
*
* @author Alex Garcia
* @since 0.1
* @version 1
*/
@karlgray
karlgray / gist:d0388051d3f21dd6871344b3c10d7ff9
Created July 2, 2021 20:18 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...