Skip to content

Instantly share code, notes, and snippets.

View adamshamsudeen's full-sized avatar
🎯
Focusing

Adam Shamsudeen adamshamsudeen

🎯
Focusing
View GitHub Profile
@iqbalali
iqbalali / user-feedback-tagging-openai.py
Created December 15, 2022 19:23
Using OpenAI to tag user feedback. You can use this as starting block to build an app iterating over user feedback items and tagging them.
import openai
openai.api_key = 'sk-****' # Get your own API key from OpenAI, I ain't sharing mine!
prompt = """
Decide whether to tag the following review with one or more of the following themes:
Pricing, Efficiency, Reliability, Food, Service, Positive, Negative
Review: Great authentic Indian food. Good prices and childrens menu too (seems quite rare in Indian restaurants). I would definitely recommend going. The waiter service was good and waiting Tim's for food was minimal. We visited based on the good reviews on here and they seemed justified.
The only reason it isn't a 5 star was because me and my family found the lady who greeted us quite abrupt and rude and didn't allow me yo point out we had a table booked instead sent us to wait for a table to be ready in the waiting area.
@nathanborror
nathanborror / instructions.txt
Last active May 17, 2023 00:55
Example Kubernetes setup with Postgres and two Services for serving an API and a static site using Ingress. Also have a CronJob example for kicks.
*** Cluster Setup for Google Container Engine ***
0/ Install and configure local gcloud and kubectl: https://cloud.google.com/sdk/docs/
> gcloud components install kubectl
1/ Configure Google Cloud account:
> gcloud config set account YOUR_EMAIL_ADDRESS
> gcloud config set project YOUR_PROJECT_ID
> gcloud config set compute/zone us-west1-a
> gcloud config set container/cluster example
@k4ml
k4ml / slacktg_bridge.py
Last active March 22, 2020 22:36
2 way bridge between Slack and Telegram.
"""
Copyright 2017 k4ml@twitter.com.
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
@meain
meain / cmd.sh
Created June 30, 2017 05:46 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@rafaelhdr
rafaelhdr / cherrypyserver.py
Last active February 7, 2024 19:04
Cherrypy server with Flask application
# Reason for choosing cherrypy
# https://blog.appdynamics.com/engineering/a-performance-analysis-of-python-wsgi-servers-part-2/
#
# Flask application based on Quickstart
# http://flask.pocoo.org/docs/0.12/quickstart/
#
# CherryPy documentation for this
# http://docs.cherrypy.org/en/latest/deploy.html#wsgi-servers
# http://docs.cherrypy.org/en/latest/advanced.html#host-a-foreign-wsgi-application-in-cherrypy
# Install: pip install cherrypy
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@dannguyen
dannguyen / README.md
Last active September 10, 2024 19:41
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

NLTK API to Stanford NLP Tools compiled on 2015-12-09

Stanford NER

With NLTK version 3.1 and Stanford NER tool 2015-12-09, it is possible to hack the StanfordNERTagger._stanford_jar to include other .jar files that are necessary for the new tagger.

First set up the environment variables as per instructed at https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software

@nlothian
nlothian / Penn Treebank II Tags.md
Last active June 11, 2024 19:06
Penn Treebank II Tags
@JustinTArthur
JustinTArthur / reverse_proxy_view.py
Last active April 15, 2024 11:43
A Django 1.4+ view function that acts as a reverse proxy. Great for testing locally or for using as a starting point to code that needs to cache or manipulate the proxied response. If one needs to proxy in production without any response manipulation, performing this in the web container (like nginx or apache) would be recommended instead of thi…
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def reverse_proxy(request):
"""
Reverse proxy for a remote service.
"""
path = request.get_full_path()
#Optionally, rewrite the path to fit whatever service we're proxying to.