Skip to content

Instantly share code, notes, and snippets.

View janxious's full-sized avatar
🌰
.

Joel "The Gregarious" Meador janxious

🌰
.
View GitHub Profile
class Array
alias :orig_uniq__ :uniq
def uniq(attr = nil)
return orig_uniq__ if attr.nil?
[].tap do |c|
found = []
self.each_with_index do |el, i|
val = el.send(attr)
unless found.include? val
found << val
@janxious
janxious / docraptor_form_example.js
Created December 31, 2010 18:37
Hitting DocRaptor using jQuery, v2
// this function is based on code found:
// http://www.filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/
// to easily make a form and POST it
var download = function(url, data, method){
//url and data options required
if( url && data ){
jQuery('<form style="display: none" id="dr_submission" action="' + url
+ '" method="' + (method||'post') + '">'
+ '</form>').appendTo('body');
//credentials
@janxious
janxious / DocRaptorPagingSample.html
Created February 3, 2011 02:39
A very basic layout for controlling page sizes
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Document</title>
<style type="text/css">
@page { size: A4; }
@page cover { size: A6 portrait; background-color: rgb(243,241,224); }
#cover { page: cover; }
</style>
</head>
@janxious
janxious / ampersand-sample.html
Created March 22, 2011 15:57
All of these things should render the same. Check the ‘h1’s.
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Ampersand Test</title>
</head>
<body>
<h1>Stuff &#x26; Things</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.</p>
<h1>Stuff & Things</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.</p>
Any of these should be runnable at the command line by `ruby <filename>`
Any of these should be runnable at the command line by `ruby <filename>`.
@janxious
janxious / wrest-example.rb
Created June 20, 2011 04:34
Wrest-based interaction with http://docraptor.com
require 'rubygems'
require 'wrest'
Wrest.logger = Logger.new(STDOUT)
Wrest.logger.level = Logger::DEBUG # Set this to Logger::INFO or higher to disable request logging
response =
'https://docraptor.com/docs?user_credentials=YOUR_API_KEY_HERE'.to_uri.
post_form(:doc =>
{
@janxious
janxious / DocRaptor.cs
Created June 24, 2011 21:01 — forked from spacetc62/MainWindow.xaml.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";
@janxious
janxious / async_ruby_example.rb
Last active September 26, 2015 05:17 — forked from spacetc62/MainWindow.xaml.cs
DocRaptor Examples Set 2 - Ruby
require 'rubygems'
require 'doc_raptor'
TEN_SECONDS = 10
FIVE_MINUTES = 300
DocRaptor.api_key "YOUR_API_KEY_HERE"
pdf_html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en"><body><a href="http://google.com">google</a></body></html>'
@janxious
janxious / referral-based_document_generation.html
Last active September 26, 2015 06:07
Referral-Based Document Generation Example
<html>
<head>
<title>Referral-based Document!</title>
</head>
<body>
<p>
Here is some sample text. Click the link below to generate a PDF of this page.
<br />
<a href='http://docraptor.com/docs/from_site/?name=example_pdf&strict=none&document_type=pdf'>Referral-based Document Generation Example</a>
</p>