This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
not_found do | |
halt 404, 'Shit\'s busted.' | |
end | |
get '/input' do | |
@input = params[:input] | |
case params[:input] | |
when "go north" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="get" action="/input"> | |
<input type="text" name="input" /> | |
<input type="submit" value="Submit" /> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |