Skip to content

Instantly share code, notes, and snippets.

View CognitiveDave's full-sized avatar
⚔️
Fighting Python3, NodeJs, MongoDB aggregation Pipeline, CSS, HTML, Linux

David Moore CognitiveDave

⚔️
Fighting Python3, NodeJs, MongoDB aggregation Pipeline, CSS, HTML, Linux
View GitHub Profile
@CognitiveDave
CognitiveDave / cleaning.py
Created June 16, 2022 09:19
Cleaning my medium list
# -*- coding: utf-8 -*-
"""
Reading List exploration file
Exploring concepts and approaches to solving the problem
"""
#Step 1 - loading the browser and preparing for automation
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
@CognitiveDave
CognitiveDave / reading.py
Created June 8, 2022 19:40
readingList Explortation
# -*- coding: utf-8 -*-
"""
Reading List exploration file
Exploring concepts and approaches to solving the problem
"""
#Step 1 - loading the browser and preparing for automation
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
chrome_options = webdriver.ChromeOptions()
records = []
count = 0
for entry in logLines:
elems = entry.decode('utf-8').split('"')
if(len(elems)) > 1:
count += 1
rec = {
'remote_addr' : elems[0].split(' ')[0],
'remote_user' : elems[0].split(' ')[1],
@CognitiveDave
CognitiveDave / secureRoute.py
Created February 13, 2022 14:16
A secure FastApi endpoint
@app.get("/api/private")
async def private(response: Response, token: str = Depends(token_auth_scheme)): # 👈 updated code
"""A valid access token is required to access this route"""
result = VerifyToken(token.credentials).verify()
if result.get("status"):
response.status_code = status.HTTP_400_BAD_REQUEST
return result
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 8 18:47:58 2022
@author: davidmoore
"""
import uvicorn
from fastapi import FastAPI, Request
from fastapi.responses import FileResponse
@CognitiveDave
CognitiveDave / example.py
Created January 29, 2022 15:49
creating instances in a workflow
filesd = ["/home/david/Downloads/test.pdf",
"/home/david/Downloads/test2.pdf",
"/home/david/Downloads/test3.pdf",
"/home/david/Downloads/test4.pdf"
]
url = 'http://localhost:8080/engine-rest'
worker_id = '1'
for filei in filesd:
@CognitiveDave
CognitiveDave / fromfile.py
Created January 29, 2022 14:19
get data from file
def get_data_from_given_path(file_name: pycamunda.variable.Variable) -> typing.Dict[str, str]:
textback= p.from_file(file_name.value)
text = textback["content"].strip()
print(file_name)
if len(text) < 4000:
return {'text': text}
else:
return {'text': text[0:3800]}
@CognitiveDave
CognitiveDave / vueScript.vue
Created April 6, 2021 18:55
semanticScript for vue template
<script>
import axios from 'axios'
export default {
name: 'text',
props: {
msg: String
},
data() {
return {
@CognitiveDave
CognitiveDave / template.vue
Created April 6, 2021 18:54
UI_Change_Semantic
<template>
<div>
<div class="container">
<h1>{{ msg }}</h1>
<b-form @submit="getKeywords" @reset="onReset" v-if="show">
<b-form-group
id="input-group-1"
label="Job description:"
label-for="input-1"
description="Copy and Paste in the text you want to work with."
@app.route('/keywords', methods=['GET','POST'])
def keywords():
response_object = {'keywords': ['birds','scatt']}
post_data = request.get_json()
if post_data['text'] != None:
keywords = LangServices.keywords(post_data['text'])
if len(keywords) > 0:
response_object = {'keywords' : keywords['ranked phrases']}
return jsonify(response_object)