Skip to content

Instantly share code, notes, and snippets.

@ktheory
ktheory / simple-note-backup.rb
Created December 2, 2010 23:11
Script to automatically export simplenote data from http://simplenote-backup.appspot.com/
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'yaml'
config = YAML.load_file(File.expand_path("~/.simple-note-backup.yml"))
email = config['email']
password = config['password']
# In attribute file:
my_gem_packages = [
"nokigiri", # Only a gem name, without a version requirement or other options"
["bundler", "=1.0.0"], # A gem with a version requirement
["rails", "~>2.3.9", "--no-ri --no-rdoc --source http://rubygems.org"], # A gem with a version requirement and options"
["json", nil, "--source http://rubygems.org"] # Gem with options but no version requirement
]
# In recipe:
# I want to turn this:
array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# into this:
=> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
def to_grid(ary)
array = ary.dup
row_length = Math.sqrt(array.size).to_i
result = []