Skip to content

Instantly share code, notes, and snippets.

View nabilm's full-sized avatar
💭
I may be slow to respond.

Mohamed Nabil Hafez nabilm

💭
I may be slow to respond.
View GitHub Profile
@nabilm
nabilm / bgload.py
Created January 29, 2021 02:05
A less memory consuming dofn beam module based on bigquery load from gcs
"""
Can be called like this:
emails_list = [
('amy', 'amy@example.com'),
('carl', 'carl@example.com'),
('julia', 'julia@example.com'),
('carl', 'carl@email.com'),
]
| "create" >> beam.Create(emails_list)
| "write to google storage" >> WriteToText("gs://<bucket>/bq_load/file")
@nabilm
nabilm / dedup.py
Created January 23, 2021 03:24
An apache beam custom PTransform that do duplication based on the passed fields
import apache_beam as beam
class Dedupe(beam.PTransform):
"""
A substitute to distinct that accept list of fields
to highlight this distinction
"""
def __init__(self, dedupe_keys=[]):
"""
Since the async support in neo4j python driver is not clear ( released ) yet
i create a simple async class that wrap up neo4j write and read transaction functions
to run this class simple
import asyncio
loop = asyncio.get_event_loop()
config = {'user': 'neo4j' , 'password' : 'test' , 'uri' : 'bolt://localhost:7687'}
an = AsyncNeo4j(config=config, loop=loop)
and of course it require python3.7 and neo4j
now you should easily create queries with dynamic variables like
@nabilm
nabilm / extract email from images using pytesseract
Last active September 8, 2019 12:06
Extract email text from image using pytesseract , this will include how to install tesseract and pytesseract
$brew install tesseract
$pip install pytesseract
$pip install Pillow
$pip install expynent
```
from pytesseract import image_to_string
import pytesseract
from PIL import Image

Keybase proof

I hereby claim:

  • I am nabilm on github.
  • I am nabilm (https://keybase.io/nabilm) on keybase.
  • I have a public key ASATxVSrTncc4nzeyyZVCgKaDSSBkfRQ9uwtNMBKM2-uywo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am nabilm on github.
  • I am nabilm (https://keybase.io/nabilm) on keybase.
  • I have a public key ASATxVSrTncc4nzeyyZVCgKaDSSBkfRQ9uwtNMBKM2-uywo

To claim this, I am signing this object:

@nabilm
nabilm / index.haml
Created July 15, 2013 22:04
A CodePen by elleestcrimi. Pink Present - Just a present box that opens
.box
.side
.side
.side
.side
.side
.side
.lid
.front
.back