Skip to content

Instantly share code, notes, and snippets.

View matin's full-sized avatar

Matin Tamizi matin

View GitHub Profile
>> require 'pdf/reader'
=> true
>> receiver = PDF::Reader::RegisterReceiver.new
=> #<PDF::Reader::RegisterReceiver:0x00000100a5b5a0 @callbacks=[]>
>> pdf = PDF::Reader.file("somefile.pdf", receiver)
TypeError: can't convert nil into String
from /opt/local/lib/ruby/gems/1.9.1/gems/pdf-reader-0.8.5/lib/pdf/reader/parser.rb:140:in `block in hex_string'
from /opt/local/lib/ruby/gems/1.9.1/gems/pdf-reader-0.8.5/lib/pdf/reader/parser.rb:137:in `loop'
from /opt/local/lib/ruby/gems/1.9.1/gems/pdf-reader-0.8.5/lib/pdf/reader/parser.rb:137:in `hex_string'
from /opt/local/lib/ruby/gems/1.9.1/gems/pdf-reader-0.8.5/lib/pdf/reader/parser.rb:55:in `parse_token'
from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey
from sqlalchemy.orm import sessionmaker, scoped_session, relationship
from sqlalchemy.ext.declarative import declarative_base
Session = scoped_session(sessionmaker())
class Model(object):
from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey
from sqlalchemy.orm import sessionmaker, scoped_session, relationship
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('postgresql://test:test@localhost/test', echo=True)
Session = scoped_session(sessionmaker(bind=engine))
Base = declarative_base(bind=engine)
import unittest
import copy
from sqlalchemy import create_engine, Column, Integer, PickleType
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from mechanize import Browser
from mechanize._clientcookie import CookieJar
def retry(tries):
def decorator(function):
def decorated_function(*args, **kwargs):
tried = 0
while tried <= tries:
try:
return function(*args, **kwargs)
except Exception, exc:
tried += 1
raise exc
@retry(3)
def fails_sometimes():
...
@matin
matin / test-psql-ondelete-cascade.py
Created December 10, 2010 22:46
Test SQLAlchemy use of PostgreSQL ON DELETE CASCADE
import unittest
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer
from sqlalchemy import String
from sqlalchemy import Text
from sqlalchemy import ForeignKey
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import relationship
require 'balanced'
# create a test marketplace
api_key = Balanced::ApiKey.new.save
Balanced.configure(api_key.secret)
marketplace = Balanced::Marketplace.new.save
# charge $100.00 on a card
buyer = Balanced::Account.new(
:email_address => "[email protected]",
@matin
matin / gist:4585229
Last active December 11, 2015 10:18
override default selector style
/* month / year expiry stuff */
.select {
height: 24px;
border: 1px solid #ccc;
border-top: 1px solid #888;
padding: 0px 0 0 0px;
background: url(https://www.poundpay.com/images/dropdown.png) no-repeat right #fff;
-webkit-appearance: none;
-moz-appearance: none;
overflow: hidden;
### Keybase proof
I hereby claim:
* I am matin on github.
* I am matin (https://keybase.io/matin) on keybase.
* I have a public key ASCViy2GV3VMclPpFPFveI1Nh2vpy4uUw_60r4P7LML9-Ao
To claim this, I am signing this object: