Skip to content

Instantly share code, notes, and snippets.

@janlelis
janlelis / rdoc2md
Last active August 29, 2015 14:17 — forked from teeparham/rdoc2md.rb
#!/usr/bin/env ruby
require 'rdoc'
puts RDoc::Markup::ToMarkdown.new.convert File.read(ARGV[0] || 'README.rdoc')
# ./rdoc2md > README.md
# ./rdoc2md ABC.rdoc > abc.md
@janlelis
janlelis / palava
Created December 21, 2013 19:57
An example nginx config to setup the palava-portal and a palava-machine.
upstream palava_machine {
server 127.0.0.1:4240;
}
server {
listen 443 ssl;
server_name example.com; # TODO
ssl on;
ssl_certificate /path/to/your/ssl/cert.crt; # TODO
@janlelis
janlelis / palava-machine
Created December 21, 2013 19:35
A simple init script for the palava-machine. Put it in /etc/init.d/ and make it executable.
#!/bin/bash
invoke()
{
echo "[$1]"
su - palava -c "ruby -S palava-machine-daemon $1"
}
start_multiple()
{
@janlelis
janlelis / gemfile
Created August 19, 2012 12:29
Displays gem urls and summaries found in a Gemfile
#!/usr/bin/env ruby
# USAGE
# gemfile [--bundle] [--details] [--fetch] [--sorted] [--commentate]
# DESCRIPTION
# Displays gem urls and summaries found in a Gemfile.
# cd into a directory with a Gemfile and run `gemfile`
# PREREQUISITES
# gem install bundler paint
# FLAGS
@janlelis
janlelis / ruby_indentation.rb
Created January 12, 2012 22:12
gem install ruby_indentation
require 'coderay'
require 'set'
module RubyIndentation
VERSION = '0.2.0'
def self.[](buffer)
opening_and_modifier_tokens = %w[if unless until while].to_set
opening_tokens = %w[begin case class def for module do {].to_set
closing_tokens = %w[end }].to_set
@janlelis
janlelis / permalink.js
Created December 5, 2011 17:05
pagination vs. permalinks
@janlelis
janlelis / hole4.rb
Created November 22, 2011 04:11
ruby source golf 2011-11-21
# hole 3 in 93 bytes (only counting newlines between method body)
# see http://rubysource.com/ruby-golf/
def play(i)
s=%w[Rock Paper Scissors]
p=s.index i
s[c=rand(3)]+",#{p==c ?:Draw: p&&p==-~c%3?:Win: :Lose}"
end
# Colorizes the output of the standard library logger, depending on the logger level:
# To adjust the colors, look at Logger::Colors::SCHEMA and Logger::Colors::constants
require 'logger'
class Logger
module Colors
VERSION = '1.0.0'
NOTHING = '0;0'
@janlelis
janlelis / .railsrc
Created March 31, 2011 16:52
13 Rails-specific hints for your rails 3 console.
# .railsrc for Rails 3, encoding: utf-8
# see http://rbjl.net/49-railsrc-rails-console-snippets
if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else
# # #
def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end
# # #
# loggers
@janlelis
janlelis / blip
Created January 16, 2011 14:38
Easy access to your clipboard
#!/usr/bin/env ruby
require 'rubygems' unless defined? Gem
require 'clipboard'
if $stdin.tty? && $*.empty?
puts Clipboard.paste # the trailing new-line is intended ;)
else
Clipboard.copy ARGF.read
end