Skip to content

Instantly share code, notes, and snippets.

View adamshamsudeen's full-sized avatar
🎯
Focusing

Adam Shamsudeen adamshamsudeen

🎯
Focusing
View GitHub Profile
@adamshamsudeen
adamshamsudeen / characters.py
Created October 13, 2018 16:40
Malayalam character unicodes
malayalam_character = ['അ','ആ','ഇ','ഈ','ഉ','ഊ','ഋ','ഌ','എ','ഏ','ഐ','ഒ','ഓ','ഔ','ക','ഖ','ഗ','ഘ','ങ','ച','ഛ','ജ','ഝ','ഞ','ട','ഠ','ഡ','ഢ','ണ','ത','ഥ','ദ','ധ','ന','ഩ','പ','ഫ','ബ','ഭ','മ','യ','ര','റ','ല','ള','ഴ','വ','ശ','ഷ','സ','ഹ','ഺ','\u0d3c','ഽ','ാ','ി','ീ','ു','ൂ','ൃ','ൄ','െ','േ','ൈ','\u0d49','ൊ','ോ','ൌ','്','ൎ','ൗ','ൠ','ൡ','ൢ','ൣ','൦','൧','൨','൩','൪','൫','൬','൭','൮','൯','൹','ൺ','ൻ','ർ','ൽ','ൾ','ൿ','ං']
@adamshamsudeen
adamshamsudeen / get_ngrok_hotsname.sh
Last active November 22, 2018 08:59
script to extract the ngrok forwarding hostname
#!/bin/bash
# Thanks to @fvclaus
curl --silent --show-error http://127.0.0.1:4040/api/tunnels | sed -nE 's/.*public_url":"(https:[^"]*).*/\1/p'
@adamshamsudeen
adamshamsudeen / mongo.py
Created November 30, 2018 08:00
Basics of using mongodb with python
from pymongo import MongoClient
client = MongoClient()
db = client.alexa
users_collection = db.user_details
#insert
users_collection.insert_one({"user":id,
"time":datetime.datetime.utcnow(),
"activated":False,
@adamshamsudeen
adamshamsudeen / cmd.sh
Created January 8, 2019 07:18 — forked from meain/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/
@adamshamsudeen
adamshamsudeen / docker.sh
Created January 10, 2019 11:50
Pushing to google container registry
gcloud auth configure-docker
#gcloud project name - deeplearning-181416
#local image name - eminn/grafana-dashboard
#grafane-image is image and v1 is the tag
docker tag eminn/grafana-dashboard gcr.io/deeplearning-181416/grafane-image:v1
docker push gcr.io/deeplearning-181416/grafane-image:v1
import logging
import logging.handlers as handlers
import time
logger = logging.getLogger('my_app')
logger.setLevel(logging.INFO)
# Here we define our formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
@adamshamsudeen
adamshamsudeen / process_pool.py
Created January 25, 2019 14:44
Using all the processors to complete a task in python effectively (multi processing)
import glob
import os
from PIL import Image
import concurrent.futures
def make_image_thumbnail(filename):
# The thumbnail will be named "<original_filename>_thumbnail.jpg"
base_filename, file_extension = os.path.splitext(filename)
thumbnail_filename = f"{base_filename}_thumbnail{file_extension}"
@adamshamsudeen
adamshamsudeen / main.py
Last active February 27, 2019 10:40
running flask app with all the gunicorn and logging
import logging
app = Flask(__name__)
# gunicorn_error_logger = logging.getLogger('gunicorn.error')
# app.logger.handlers.extend(gunicorn_error_logger.handlers)
# app.logger.setLevel(logging.DEBUG)
# app.logger.debug('this will show in the log')
# gunicorn_logger = logging.getLogger(‘gunicorn.error’)
@adamshamsudeen
adamshamsudeen / chardet.sh
Last active March 13, 2019 13:40
If chardet error raises uring doc_bot install
sudo apt install --reinstall python-debian python3-debian python-chardet python3-chardet
@adamshamsudeen
adamshamsudeen / postgres
Last active December 9, 2019 15:24
postgress setup on ubuntu for django
sudo apt-get install libpq-dev postgresql postgresql-contrib
sudo -u postgres -i
psql
create database tagger;
create user tagger_user with password 'passsss';
grant all privileges on database tagger to tagger_user;
ALTER ROLE tagger_user SET client_encoding TO 'utf8';
ALTER ROLE tagger_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE tagger_user SET timezone TO 'UTC';