Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / Example code
Created December 22, 2011 03:48
Still working on Dungeon Crawler redirection
# trying to set a method so I can use @input in other methods
class Input
def initialize(input)
@input = params[:input]
end
end
# collecting the input with a form here
get '/input' do
@input = params[:input]
@illbzo1
illbzo1 / An example of the form method from a view
Created December 14, 2011 02:33
Working with form methods in Sinatra
<form method="get" action="/input">
<input type="text" name="input" />
<input type="submit" value="Submit" />
</form>
@illbzo1
illbzo1 / aan.rb
Created November 15, 2011 02:42
Random Phrase Generator, Refactored
require 'yaml'
words = YAML::load(File.open('words.yml'))
loop do
puts "Generate new phrase? (y / n)"
input = gets.chomp()
unless input == "n"
new_phrase = %w[adj2 noun].map { |type| words[type].sample }
addition = rand(7)
@illbzo1
illbzo1 / aan
Created November 10, 2011 02:37
Random Phrase Generator
files = Dir.glob("*.txt")
adjective_list1 = IO.readlines("adj1.txt")
adjective_list2 = IO.readlines("adj2.txt")
noun_list = IO.readlines("noun.txt")
prefix_list = IO.readlines("prefix.txt")
suffix_list = IO.readlines("suffix.txt")
rand1 = rand(adjective_list1.length)
rand2 = rand(adjective_list2.length)
@illbzo1
illbzo1 / madlib.rb
Created November 8, 2011 03:15
Madlibs Generator, Objectified
@counter = 0
files = Dir.glob("*.madlib")
if files.size > 1
puts "CHOOSE YOUR FILE:"
x = 0
files.each do |file|
x += 1
puts "#{x}. #{file}"
@illbzo1
illbzo1 / madlibs
Created October 30, 2011 23:08
Madlibs Generator, Second Refactoring
def generate_mad_lib
puts "Bear with me. I'm going to need 16 singular nouns."
@nouns = []
16.times { @nouns << gets.chomp }
@nouns = @nouns.reverse
puts "Awesome, now I'm going to need 6 plural nouns."
@plural_nouns = []
6.times { @plural_nouns << gets.chomp }
@plural_nouns = @plural_nouns.reverse