Skip to content

Instantly share code, notes, and snippets.

View niazangels's full-sized avatar
🔥
Beast mode: ON

Niyas Mohammed niazangels

🔥
Beast mode: ON
View GitHub Profile
@niazangels
niazangels / flask_stream_s3.py
Created November 18, 2018 06:51
Download a huge file to the user's computer in chunks from S3
import boto3
from boto3.s3.transfer import S3Transfer
from flask import Flask, Response
app = Flask(__name__)
class S3Storage:
def __init__(self, bucket_name, pictures_path="", video_path=""):
@niazangels
niazangels / qa-sample.json
Last active August 7, 2018 17:34
Sample QA log document
{
"query": "how much revenue did we generate in the last quarter from XYZ Corp?",
"response": { ... }
}
@niazangels
niazangels / pdf-2-tiff-2-txt.sh
Last active May 6, 2018 20:49 — forked from poppingtonic/extract.sh
convert a PDF to TIFF using gs, convert from TIFF to txt using tesseract
# $1 is the first argument
# remove result.txt
#rm output/result.txt
fname=`echo "$1" | awk -F "/" '{print $(NF)}'`
# convert the pdf to a group of tiffs
if [ ! -e extracted_tz_parliament/$fname.txt ];
then
@niazangels
niazangels / import-cypher.c
Last active January 28, 2018 14:15
Cypher query to import a graph from file using APOC
// Import from GraphML
CALL apoc.import.graphml('/tmp/complete-graph.graphml', {batchSize: 10000, storeNodeIds: false})
@niazangels
niazangels / export-all-cypher.c
Last active January 28, 2018 14:10
Export entire Neo4j graph using APOC
// Export entire database
CALL apoc.export.graphml.all('/tmp/complete-graph.graphml', {useTypes:true, storeNodeIds:false})
@niazangels
niazangels / celery-flask-progressbar.py
Created January 22, 2018 19:11
Simple progressbar with Flask + Celery
'''
testing celery progress reporting/polling
* start server
python tempserver.py
* start worker
celery -A tempserver.celery worker -c 1 --loglevel=DEBUG
* browse to localhost:5000/
'''
from flask import Flask, request, render_template_string
@niazangels
niazangels / render-malaylam-text.py
Created December 2, 2017 18:19
How to render malayalam text as images
from PIL import Image, ImageDraw, ImageFont
import matplotlib.pyplot as plt
import numpy as np
image = Image.new('RGB', (700, 40))
# Make sure the location to the font is correct
draw.text((40,5), 'നമ്മുടെ മലയാളം അടിപൊളിയായി ഇമേജിൽ വരുന്നു', font=ImageFont.truetype('./Manjari-Bold.ttf', 25))
plt.imshow(np.asarray(image))
@niazangels
niazangels / DRAGONS.txt
Last active July 8, 2017 11:19
DRAGONS.md
/*
, ,
/ \/ \
(/ //_ \_
.-._ \|| . \
\ '-._ _,:__.-"/---\_ \
______/___ '. .--------------------'~-'--.)__( , )\ \
`'--.___ _\ / | Here ,' \)|\ `\|
/_.-' _\ \ _:,_ Be Dragons " || (
.'__ _.' \'-/,`-~` |/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@niazangels
niazangels / lesson-6.ipynb
Last active May 24, 2017 20:47
3-char RNN model mostly always predicts a space
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.