Skip to content

Instantly share code, notes, and snippets.

@illbzo1
illbzo1 / dc.rb
Created December 31, 2011 02:39
Dungeon Crawler full
require 'sinatra'
not_found do
halt 404, 'Shit\'s busted.'
end
get '/input' do
@input = params[:input]
case params[:input]
when "go north"
@illbzo1
illbzo1 / DocRaptor.cs
Created August 14, 2012 17:09 — forked from janxious/DocRaptor.cs
DocRaptor Examples Set 1 - Non-Ruby
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Web;
namespace DocRaptorConsoleExample {
class DocRaptor {
private const string PostFormat = "doc[{0}]={1}&doc[name]={2}&doc[document_type]={3}&doc[test]={4}";
private const string ApiKey = @"YOUR API KEY HERE";
@illbzo1
illbzo1 / async_excel_ruby_example.rb
Created August 14, 2012 17:21 — forked from janxious/async_ruby_example.rb
DocRaptor Examples Set 2 - Ruby
require 'rubygems'
require 'doc_raptor'
TEN_SECONDS = 10
FIVE_MINUTES = 300
DocRaptor.api_key "YOUR_API_KEY_HERE"
xls_html = "<table name='My First Sheet'><tr><td>Cell 1</td><td>Cell 2</td></tr></table>"
@illbzo1
illbzo1 / curl_example_excel.sh
Created August 14, 2012 19:05
DocRaptor Examples Set 3 - Simple Curl Commands
#This simple Curl example will create a sample test Excel file with the authentication information as part of the POST data. All you have to do is copy this code, plug in your API key, and paste it into a command line.
curl -H "Content-Type:application/json" -d'{"user_credentials":"YOUR_API_KEY_HERE", "doc":{"name":"docraptor_sample.xls", "document_type":"xls", "test":"true", "document_content":"<table><tr><td>Example!</td></tr></table>"}}' http://docraptor.com/docs > docraptor_sample.xls
@illbzo1
illbzo1 / Foo.html
Last active August 29, 2015 14:00
A sample model using the doc_raptor gem for PDF generation.
asdf
@illbzo1
illbzo1 / random_controller.rb
Created April 23, 2014 18:49
A sample controller action for creating PDFs with DocRaptor.
def show
@random = Random.find(params[:id])
respond_to do |format|
format.html
format.pdf { doc_raptor_send }
end
end
@illbzo1
illbzo1 / random_controller.rb
Created April 23, 2014 19:01
An update to our random_controller for sending HTML to DocRaptor.
def show
@random = Random.find(params[:id])
respond_to do |format|
format.html
format.pdf { doc_raptor_send }
end
end
def doc_raptor_send(options = { })
default_options = {
@illbzo1
illbzo1 / show.html.erb
Created April 23, 2014 19:03
Adding some code to a view file for generating a PDF using DocRaptor.
<%= show_for @random do |s| %>
<%= s.attribute :title %>
<% end %>
<%= link_to 'Edit', edit_random_path(@random) %> |
<%= link_to 'Back', randoms_path %>
<%= link_to("Download Random PDF", random_path(@random, format: :pdf)) %>
@illbzo1
illbzo1 / random.pdf.erb
Created April 23, 2014 19:09
A sample template for creating PDFs with DocRaptor.
<style type="text/css">
/* setup the page */
@page {
size: US-Letter;
margin: 0 0 35mm 0;
background: #ffffff;
}
/* setup the footer */
@page {
@illbzo1
illbzo1 / random.pdf.erb
Created April 24, 2014 16:00
A step by step Ruby on Rails implementation for DocRaptor
<style type="text/css">
/* setup the page */
@page {
size: US-Letter;
margin: 0 0 35mm 0;
background: #ffffff;
}
/* setup the footer */
@page {