Skip to content

Instantly share code, notes, and snippets.

@namelessjon
namelessjon / planter.rb
Created October 19, 2012 09:27 — forked from ttscoff/planter.rb
Create directory trees from indented text input
#!/usr/bin/ruby
# ruby script to create a directory structure from indented data.
# Three ways to use it:
# - Pipe indented (tabs or 2 spaces) text to the script
# - e.g. `cat "mytemplate" | planter.rb
# - Create template.tpl files in ~/.planter and call them by their base name
# - e.g. Create a text file in ~/.planter/site.tpl
# - `planter.rb site`
# - Call planter.rb without input and it will open your $EDITOR to create the tree on the fly
# You can put %%X%% variables into templates, where X is a number that corresponds to the index
@namelessjon
namelessjon / folder.rb
Created February 19, 2012 11:02
Gist showing nested/self-referential model
class Folder
include DataMapper::Resource
has n, :subfolders, 'Folder'
has n, :messages
belongs_to :parent, :model => 'Folder', :required => false
belongs_to :owner, :model => 'User', :key => true
property :id, String, :key => true
property :name, String
@namelessjon
namelessjon / split_repo.bash
Created March 24, 2010 02:44 — forked from pk/split_repo.bash
Script to split out the subdirectory from a repository to it's own repo
#!/bin/bash
FROM=$1
TO=$2
echo "Spliting '$TO' from '$FROM'"
git clone --no-hardlinks $FROM $TO
cd $TO
git filter-branch --prune-empty --subdirectory-filter $TO HEAD -- --all
git reset --hard
git gc --aggressive
git prune