Skip to content

Instantly share code, notes, and snippets.

View 1stevengrant's full-sized avatar
🏠
Working from home

Steven Grant 1stevengrant

🏠
Working from home
View GitHub Profile
#!/bin/bash
#
# Backup Script
#
#=====================================================================
#=====================================================================
# Set the following variables to your system needs
#=====================================================================
# Directory to save daily tar.gz backup files to e.g /backups
@1stevengrant
1stevengrant / .htaccess
Created May 24, 2014 14:18
htaccess that can protect an environment
#
# .htaccess
# Apache Configuration File
#
# This code has been assembed from various places. A LOT of it came from
# the HTML boilerplate. See their awesome stuff here: http://html5boilerplate.com/
#
# Created by Jesse Bunch on 2011-04-15.
# Copyright 2011 Jesse Bunch (www.GetBunch.com). All rights reserved.
#
@1stevengrant
1stevengrant / gist:5ee4913109dd0922ed74
Created May 24, 2014 14:49
add this to your CMS index file to protect a file
if($_SERVER['SERVER_ADDR'] == '127.0.0.1') {
$username = 'username';
$password = 'password';
if (!(isset($_SERVER['PHP_AUTH_USER']) && ($_SERVER['PHP_AUTH_USER']==$username && $_SERVER['PHP_AUTH_PW']==$password))) {
header('WWW-Authenticate: Basic realm="This site is protected"');
header('HTTP/1.0 401 Unauthorized');
// Fallback message when the user presses cancel / escape
echo 'Access denied';
#!/bin/sh
# Import a remote database into a local database
# ----------------------------------------------
#
# Based on http://danherd.net/quick-script-synchronise-from-a-remote-expressionengine-database/
#
# Don’t forget chmod +x to make the script executable.
#
# Change the extension to .command to run the script directly from OS X Finder.
CREATE TABLE `exp_security_hashes` (
`hash_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date` int(10) unsigned NOT NULL,
`session_id` varchar(40) NOT NULL DEFAULT '0',
`hash` varchar(40) NOT NULL,
`used` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`hash_id`),
KEY `hash` (`hash`)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
if($_SERVER['SERVER_ADDR'] == '127.0.0.1') {
$username = 'username';
$password = 'password';
if (!(isset($_SERVER['PHP_AUTH_USER']) && ($_SERVER['PHP_AUTH_USER']==$username && $_SERVER['PHP_AUTH_PW']==$password))) {
header('WWW-Authenticate: Basic realm="This site is protected"');
header('HTTP/1.0 401 Unauthorized');
// Fallback message when the user presses cancel / escape
echo 'Access denied';
{% for session in craft.entries.section('session').sessionType('Plenary') %}
{% if loop.first %}
<ul>
{% endif %}
<li>
<a href="#">
<h4 class="session-title">{{ session.title }}</h4>
{% for speaker in entry.sessionSpeaker %}
@1stevengrant
1stevengrant / talks.html
Last active August 29, 2015 14:05
This code loops through sessions that are set as a workshop, groups them by workshop round, orders them by title and lists the related speaker for a session
{% set allWorkshops = craft.entries.section('session').sessionType('Workshop').order('sessionRound','title') %}
{% set allWorkshopsByRound = allWorkshops|group('sessionRound') %}
{% for round, workshopsInRound in allWorkshopsByRound %}
<h3 class="round">Round {{ round }}</h3>
{% for entry in workshopsInRound %}
{% set speaker = entry.sessionSpeaker.first() %}
{% extends "_layout" %}
{% set title = "Talks" %}
{% block content %}
<div class="body-content">
<div class="body-inner">
{% for session in craft.entries.section('session').sessionType('Plenary').order('sessionDateTime','title') %}
{% set speaker = session.sessionSpeaker.first() %}
<div class="talk">
<h4>
{% for speaker in session.sessionSpeaker %}
{% if speaker.speakerSalutation %}
{{ speaker.speakerSalutation }}
{% endif %}
{{ speaker.speakerFirstName }} {{ speaker.title }}{% if not loop.last %}, {% endif %}