Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"<CHANGE-ME>.github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted
GHBU_PRUNE_AFTER_N_DAYS=${GHBU_PRUNE_AFTER_N_DAYS-3} # the min age (in days) of backup files to delete
#!/bin/bash
# Script to backup git repo to S3
# Set bucket, dir, password and account to use for the backup. I keep mine in local env vars
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc
bucket=$GITHUB_BACKUP_BUCKET
dir=$GITHUB_BACKUP_DIR
password=$GITHUB_BACKUP_PASSWORD
account=$GITHUB_ACCOUNT

Templating in EE vs. Craft

Lots of people have asked, so here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft.

Table of Contents

  1. Comments
  2. Conditionals
  3. Loops
@joshellington
joshellington / gist:5dadb27095e940314821
Created May 19, 2014 01:07
Backup your Github organization repos.
require 'github_api'
require 'optparse'
require 'pp'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: github_org_backup.rb [options]"
opts.on("-u", "--user USER", "Your Github username") do |v|
options[:user] = v
window.onclick=function() {
alert('wtf!');
}
@joshellington
joshellington / gist:960071
Created May 7, 2011 00:28
.bash_profile settings for colors and current git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
PS1='\[\e[1;34m\]@\[\e[m\] \[\e[0;32m\]:\W\[\e[m\]\[\e[1;32m\] \[\033[1;31m\]$(parse_git_branch)\[\033[01;34m\] \$\[\e[m\] \[\e[1;37m\]'
PATH="/opt/local/bin:$PATH"
alias ls="ls -G"
@joshellington
joshellington / gist:959933
Created May 6, 2011 22:37
Preload background-images from media query CSS files
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
// Find 4 digit pixel reference in filename
var digits = 4;
var str = this;
var regex = new RegExp("\\d{"+digits+"}", "g");
var match = str.match(regex);
// If bg image is smaller than user's screen width
@joshellington
joshellington / gist:1008237
Created June 4, 2011 19:21
Facebook iframe signed request
require 'json'
require 'base64'
# Decoding functions
def base64_url_decode str
encoded_str = str.gsub('-','+').gsub('_','/')
encoded_str += '=' while !(encoded_str.size % 4).zero?
Base64.decode64(encoded_str)
end
@joshellington
joshellington / gist:1144369
Created August 13, 2011 23:36
MongoMapper counting loop
date_started = Date.parse("2011-08-09")
date_now = Date.today
@by_day = []
@days_passed = date_now.mjd - date_started.mjd
(1..@days_passed).each do |day|
date = Kit.where(:created_at.gte => day.days.ago, :created_at.lte => (day-1).days.ago).fields(:created_at).first
count = Kit.count(:created_at.gte => day.days.ago, :created_at.lte => (day-1).days.ago)
@by_day.push("date" => date.created_at.strftime("%m/%d"), "count" => count)
def self.new_image(images, uid)
final = Magick::Image.new(1000, 600).matte_reset!
last = images.length - 1
images.each_with_index do |image, index|
o = image[1]
n = Magick::Image.read($dir+'/'+o[:src]).first
n.scale!(200, o[:height].to_i)