Skip to content

Instantly share code, notes, and snippets.

View akiellor's full-sized avatar

Andrew Kiellor akiellor

View GitHub Profile
a b c
1 2 3
reader = PDF::Reader.new('some.pdf')
filename = "transactions.csv" # obtain this from the XFA in the pdf
page = reader.pages.first
attachment_name_reference = page.objects.find do |k, v|
page.objects.obj_type(k) == :Hash && v[:Type] == :Filespec && v[:UF] == filename }.first
end
attachment_content_reference = page.objects[attachment_name_reference][:EF][:F]
attachment_content = page.objects[attachment_content_reference].unfiltered_data
@akiellor
akiellor / Dockerfile.flowtype-dev
Last active March 1, 2018 02:46
Flow performance degradation bisect scripts
FROM ubuntu
WORKDIR /data
RUN apt-get update -y
RUN apt-get install -y git opam m4
RUN yes | opam init --comp 4.03.0
RUN git clone https://github.com/facebook/flow.git /data
RUN yes | opam update
RUN yes | opam pin add -n flowtype .

Keybase proof

I hereby claim:

  • I am akiellor on github.
  • I am akiellor (https://keybase.io/akiellor) on keybase.
  • I have a public key ASAapijc2AXhZDL-pfVbgWFs-uNQcTS8vsLleuOWq3LnBwo

To claim this, I am signing this object:

@akiellor
akiellor / gist:12db63d9b578447b9aed
Created February 6, 2015 03:46
Mocha/Promise error detection.
var falafel = require('falafel');
var fs = require('fs');
var file = process.argv[2];
var src = fs.readFileSync(file).toString();
var output = falafel(src, {loc: true}, function (node) {
if (node.type === 'Identifier' && node.name === "it") {
var testBody = node.parent.arguments[1].body.body
var lastStatement = testBody[testBody.length - 1];
@akiellor
akiellor / Main.java
Last active December 20, 2015 08:49
Maven + JRuby + Pry Example
package com.example.pry;
import org.jruby.embed.ScriptingContainer;
public class Main {
public static void main(String... args){
ScriptingContainer container = new ScriptingContainer();
container.runScriptlet("require 'pry'; binding.pry");
}
}
class Foo
def self.with_bar
Foo.new(Bar.new)
end
def initiatize bar
@bar = bar
end
def something_fun
class Blah
def to_ary
[1, 2, 3]
end
end
blah = Blah.new
one, two, three = blah
import math
class Calculator:
def plus(self, first, second):
return first + second
def pi(self):
return math.pi
YAML.add_builtin_type('yes_no') {|type, value| value == 'Y'}
YAML.load("blah: !yes_no 'Y'") == {'blah' => true}