Skip to content

Instantly share code, notes, and snippets.

@jthoenes
jthoenes / upgrade_dokuwiki.rb
Created January 24, 2010 14:14
Update multiple dokuwiki installations via a ruby script
#! /usr/bin/env ruby
=begin
This script backups and updates all dokuwiki installations on this server
Copyright (c) 2010 by Johannes Thönes <johannes.thoenes@googlemail.com>
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
=end
# Library Requirements
require 'net/http' # for download of the files
require 'open-uri' # for download of the files
// everyone's new favorite closure pattern:
(function(window,document,undefined){ ... })(this,this.document);
// when minified:
(function(w,d,u){ ... })(this,this.document);
// which means all uses of window/document/undefined inside the closure
// will be single-lettered, so big gains in minification.
// it also will speed up scope chain traversal a tiny tiny little bit.
@defunkt
defunkt / installing-mustache.vim.md
Created March 6, 2010 10:21
Installing mustache.vim

mustache.vim

In your shell:

cd ~/.vim
git clone git://github.com/juvenn/mustache.vim.git
mv mustache.vim/syntax/* syntax/
mv mustache.vim/indent/* indent/
mv mustache.vim/ftdetect/* ftdetect/

rm -rf mustache.vim

require File.expand_path(File.join(File.dirname(__FILE__), '../test_helper'))
class MyProjectSpecifcUnitTest < MiniTest::Unit::TestCase
def setup
repository(:default) do |repository|
transaction = DataMapper::Transaction.new(repository)
transaction.begin
repository.adapter.push_transaction(transaction)
end
require 'sinatra'
get '/' do
haml :upload
end
post '/show' do
@sinatra_params = params
@rack_request = request
haml :results
# workaround from
# http://stackoverflow.com/questions/1987386/foreign-key-name-in-datamapper-associations
field_naming_convention = lambda do |v|
if v.name.to_s[0..0] == v.name.to_s[0..0].upcase
v.name.to_s
else
DataMapper::NamingConventions::Field::Underscored.call(v)
end
end
#!/bin/bash
CURRENT_DIR=`pwd`
for dir in $(find $1 -type d -depth 1 -not -name "\.*");
do
cd $dir
if [ -f *.gem ]; then
rm -rv *.gem
fi
#!/usr/bin/env bash
# where do you want couchdb and its deps to be installed
COUCHDB_PREFIX="/opt/couchdb-1.0.1"
# Let's determine the correct arcitecture and choose the installer
if [ "`uname -m`" = "x86_64" ]; then
echo "Using 64-bit installer"
COUCHDB_INSTALLER_DOC_ID="26f246a0fe23d6a53d5326713308f43c"
COUCHDB_INSTALLER_BIN="install-couchdb-1.0.1_rel1-linux-x64.bin"
@henrik
henrik / gist_search.rb
Created January 10, 2011 20:54
Search your own public Gists from the command line. Because the site only provides global search. There's not yet an API for private Gists.
require "open-uri"
require "rubygems"
require "json"
USERNAME = "henrik"
query = ARGV.first.downcase
gists = JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{USERNAME}").read)['gists']
@jiren
jiren / sprite_datauri_writer.rb
Created January 20, 2011 14:57
This generates 2 css files - sprite image and a css along with a datauri css.
#! /usr/local/bin/ruby -w
# This simple program takes a bunch of images and creates a sprite image along with the corrosponding
# css. It also generates the datauri css. So, we can serve performance optimized CSS depending on the
# Browsers.
#
# Browsers which do not support datauri, like IE7 and below get the sprite image and the sprite css.
# Browsers which support datauri, get the datauri.css
#
# Usage: