Skip to content

Instantly share code, notes, and snippets.

@sr
sr / gist:25914
Created November 17, 2008 21:31
#!/usr/bin/env ruby
def truncate(text, length = 30, truncate_string = "...")
if text.nil? then return end
l = length - truncate_string.length
(text.length > length ? text[0..l] + truncate_string : text).to_s
end
def date
Time.now.strftime('%Y/%m/%d %H:%M')
end
#!/usr/bin/env ruby
base = File.dirname(__FILE__) + "/../code/git-wiki"
require base + '/git-wiki'
set :public, base + '/public'
set :port, 4567
set :env, :production
disable :run, :reload
@sr
sr / from.rb
Created December 14, 2008 01:06 — forked from bmizerany/from.rb
get '/:id' do
@vent = Vent.get(params[:id])
erb :show
end
# show post
get '/:id.xml' do
@vent = Vent.get(params[:id])
builder :show
end
#!/bin/bash
cat <<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Notes en Vrac</title>
<link rel="alternate" type="application/atom+xml"
title="Notes en Vrac (Atom)" href="/notes/feed" />
<style type="text/css">
@import "/2008/10-crumb.css";
@sr
sr / serve.rb
Created December 28, 2008 02:09
# WTFPL
# Requires http://github.com/rtomayko/sinatra/tree/hoboken
require "rubygems"
require "rack"
require "thin"
require "pathname"
require "addressable/uri"
require "sinatra/base"
@sr
sr / app.rb
Created December 29, 2008 13:45
require "rubygems"
require "rack"
$:.unshift File.dirname(__FILE__) + "/lib"
require "sinatra/base"
class Sinatra::Application
get "/" do
"Hello World"
end
end
Sinatra Pimping
===============
Ideas/Brain dump
----------------
* Do not show the README on the front page. But:
* Elevator pitch
* Code
* Mailing-List, #sinatra, Bug tracker
@sr
sr / init.rb
Created January 22, 2009 18:22 — forked from jnewland/init.rb
# A Sinatra App as a Rails Plugin
#
# In your Edge Rails app:
#
# ruby script/plugin install git://gist.github.com/50625.git
require 'sinatra/base'
class SinatraRailsPlugin < Sinatra::Base
commit 7f15f6447d38cab55b46ae3210db773e1f61af4a
Author: Simon Rozet <simon@rozet.name>
Date: Wed Jan 28 17:31:07 2009 +0100
last one
diff --git a/index.html b/index.html
index 4b10db2..0b09989 100644
--- a/index.html
+++ b/index.html