Skip to content

Instantly share code, notes, and snippets.

@shapeshed
shapeshed / .bashrc
Created February 3, 2009 08:09
.bashrc file
########################################
# Show current Git branch in prompt
########################################
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\h:\W\$(parse_git_branch)$ "
@shapeshed
shapeshed / clean_filenames.sh
Created February 3, 2009 13:49
Bash script to convert all filename in a folder to lowercase and replace spaces with underscores
#!/bin/bash
# Replaces spaces in filenames with underscores and converts filenames to lowercase
# Run within a directory to convert all files
ls | while read -r FILE
do
mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'`
done
@shapeshed
shapeshed / exp_permissions.sh
Created August 26, 2009 10:28
Correctly sets permissions for a new ExpressionEngine site
#!/bin/bash
# File: exp_permissions.sh
# Description: Sets permssions on a ExpressionEngine install
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@shapeshed
shapeshed / ee_disqus_exporter.rb
Created October 6, 2009 06:22
Import ExpressionEngine comments into Disqus
# Copyright 2009 Michael Ivey, released to public domain
# Disqus guts lifted from http://github.com/squeejee/disqus-sinatra-importer/tree/master
# I wanted it to run from MySQL and command line, instead of a Sinatra app
require 'rubygems'
require 'rest_client'
require 'json'
require 'sequel'
disqus_url = 'http://disqus.com/api'
@shapeshed
shapeshed / flv_convert.sh
Created November 1, 2009 10:21
Batch convert flv files to ogv and mp4 formats
#!/bin/bash
# File: flv_convert.sh
# Description: Converts flv files to ogv and mp4
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@shapeshed
shapeshed / publish_jekyll.sh
Created November 18, 2009 13:02
Compiles Jekyll Website and publishes via rsync
#!/bin/bash
# File: publish_jekyll.sh
# Description: Compiles Jekyll Website and publishes via rsync
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@shapeshed
shapeshed / generate_redirects.sh
Created November 30, 2009 10:48
Generates redirect rules from a folder structure
#!/bin/bash
# File: generate_redirects.sh
# Description: Generates redirect rules based on a folder structure
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@shapeshed
shapeshed / monitor_df.sh
Created November 30, 2009 14:14
Monitors disk usage and sends an email when nearing limit
#!/bin/bash
# File: monitor_df.sh
# Description: Monitors disk usage and sends an email if limit reached
#
# Adapted from http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@shapeshed
shapeshed / ee2_permissions.sh
Created December 5, 2009 15:27
Sets permssions on a ExpressionEngine Version 2 install
#!/bin/bash
# File: ee2_permissions.sh
# Description: Sets permssions on a ExpressionEngine Version 2 install
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#!/bin/bash
#
# File: iptables_firewall.sh
# Description: Sets iptables firewall rules (run as root)
#
# Copyright 2010 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at