Skip to content

Instantly share code, notes, and snippets.

@ozkatz
ozkatz / lakefs_resolver.py
Created Feb 19, 2021
lakeFS python resolver (returns S3 addresses for objects under a prefix)
View lakefs_resolver.py
#!/usr/bin/env python
from urllib.parse import urlparse
from typing import Iterator
from bravado.requests_client import RequestsClient
from bravado.client import SwaggerClient
class lakeFSResolver(object):
"""
An example lakeFS client that allows resolving
View cla.txt
lakeFS Individual Contributor License Agreement
Adapted from http://www.apache.org/licenses/ © Apache Software Foundation
Thank you for your interest in lakeFS (the "Foundation"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Foundation must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Foundation and its users; it does not change your rights to use your own Contributions for any other purpose. If you have not already done so, please complete and sign, then scan and email a pdf file of this Agreement to hello@treeverse.io
Please read this document carefully before signing and keep a copy for your records.
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Foundation. In return, the Foundation
View gist:4b5b69f45b507ae1cea5313171beae8d
### Keybase proof
I hereby claim:
* I am ozkatz on github.
* I am ozk (https://keybase.io/ozk) on keybase.
* I have a public key whose fingerprint is 1AB0 E63A 96C0 217D 04EB 70A7 71DF 2351 5439 C3A1
To claim this, I am signing this object:
View gist:8872402
import urllib2
import multiprocessing
import sqlite3
# With this line in place, calling urlopen() below
# will simply hang on OSX 10.9.1 (Python 2.7.5)
# comment the line out and urlopen() works as it should.
c = sqlite3.connect('/tmp/some.db')
View boto_resolver.py
# Add this to your fabfile.py (or import it from there)
from boto.ec2.connection import EC2Connection
class EC2Resolver(object):
AWS_KEY_ID = 'xxxxxxx'
AWS_SECRET_ACCESS_KEY = 'xxxxxx' # Alternitavely take this info from environment variables or some other resource.
def __init__(self):
@ozkatz
ozkatz / ec2_ssh_config.py
Created Jun 21, 2013
generate an ~/.ssh/config file from your EC2 instances, so that you'd never have to lookup those fugly ec2-xx-xx-xx-xxx.compute-1.amazonaws.com hostnames again. Use your instance name instead!
View ec2_ssh_config.py
#!/usr/bin/env python
import os
import sys
import argparse
try:
from boto.ec2.connection import EC2Connection
except ImportError:
sys.stderr.write('Please install boto ( http://docs.pythonboto.org/en/latest/getting_started.html )\n')
sys.exit(1)
@ozkatz
ozkatz / bogosort.py
Created May 26, 2013
A bogosort implementation in Python. For all your big data needs.
View bogosort.py
from random import shuffle
def is_ordered(l):
for i, x in enumerate(l):
if i == 0:
continue
if x < l[i - 1]:
return False
return True
@ozkatz
ozkatz / gist:5520308
Last active Apr 14, 2020
A wrapper around Django's EmailMultiAlternatives that renders templates.
View gist:5520308
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string
class EMail(object):
"""
A wrapper around Django's EmailMultiAlternatives
that renders txt and html templates.
Example Usage:
@ozkatz
ozkatz / 99bottles
Created Nov 26, 2011 — forked from gsiegman/99bottles
99 Bottles of Beer on the Wall (as a one liner. I don't know why.)
View 99bottles
import os; [ os.system('say %d bottles of beer on the wall, %d bottles of beer, if one of those bottles should happen to fall, %s bottles of beer on the wall' % (99 - i, 99 - i , 99 - i - 1)) for i in range(0, 99) ]