Skip to content

Instantly share code, notes, and snippets.

@laucb
laucb / spideroak_backup
Created December 6, 2012 13:45
SpiderOak backup
#!/bin/bash
# Automated Cloud Backups to SpiderOak
# -----
# Feel free to use this in any environment and
# modify it to your heart's content.
# -----
package chestnut
import java.io.{File, IOException}
import java.util.{ArrayList, List}
import javax.servlet.{ServletConfig, ServletException}
import javax.servlet.annotation.WebServlet
import javax.servlet.http.{HttpServlet, HttpServletRequest => HSReq, HttpServletResponse => HSResp}
import org.jruby.embed.{LocalContextScope, ScriptingContainer => Container}
require 'RMagick'
module Dragonfly
module Processing
class AspectRatioProcessor
include Dragonfly::RMagickUtils
include Dragonfly::Configurable
configurable_attr :use_filesystem, true
@laucb
laucb / application.rb
Created September 10, 2011 18:16 — forked from parndt/application.rb
config/application.rb hooks for Dragonfly in Refinery CMS
# Place this in the config block on config/application.rb of your Rails application.
# Override where dragonfly keeps your images and its url format
config.to_prepare do
::Dragonfly[:images].configure do |c|
c.datastore.root_path = Rails.root.join('public', 'assets', 'images').to_s
c.url_format = '/assets/images/:job/:basename.:format'
end
end
@laucb
laucb / github_repos.rb
Created August 1, 2011 20:42 — forked from akitaonrails/github_repos.rb
manage all github repositories (yours and watched) with a single command.
#!/usr/bin/env ruby
#
# Brute-force way to retrieve all Github's repositories at once
# Usage:
# github_repos.rb clone # will clone all the user's repositories
# github_repos.rb clone test # will just clone 6 repositories for testing purposes
# github_repos.rb pull # will update all of the user's local repositories
#
# If you have forked repositories, the original sources will be added
# as remotes with the default 'forked_from' name, and a new 'forked_from'
@laucb
laucb / sync.py
Created July 24, 2011 23:07 — forked from kennethreitz/sync.py
GitHub Syncer. Clones or Pulls all GitHub repos (including watched list).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Kenneth Reitz's GitHub Syncer
This script uses the GitHub API to get a list of all forked, mirrored, public, and
private repos in your GitHub account. If the repo already exists locally, it will
update it via git-pull. Otherwise, it will properly clone the repo.
It will organize your repos into the following directory structure:
alias :pputs :puts
def puts(str = "")
pputs(str)
$out << "#{str}"
end
STDOUT.instance_eval do
alias :pputs :puts
def puts(str = "")
pputs(str)
These instructions have two purposes: 1) my own notes so I can more easily set up a new machine next time; 2) help for a Rails n00b to get a machine and a project set up without having to make all the same mistakes I did.
This walks you through setting up a remote Linux server and creating a Rails 3 project locally, using Github and Capistrano to collaborate and deploy.
Local -> means on your machine which should be a Unix variant (some OS X specifics may have snuck in)
Server -> means the server
Local ->
setup a /etc/hosts entry to map the IP to a simple name, hereafter 'server'
@laucb
laucb / webapp.rb
Created November 18, 2010 18:36 — forked from igrigorik/webapp.rb
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
#Original code from ActiveMerchant::PayPalNotification
#Modified by me to account for multiple items and custom flag
#Also bypassed the acknowledge if environment is "test"
require 'net/http'
class PayPalNotification
def initialize(params)
@ipn=params
end