Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Davies justindavies

View GitHub Profile
View convert_to_spacy.py
import sys
import json
fo = open(sys.argv[1], "r")
lines = fo.readlines()
for line in lines:
View extract_ners.py
from elasticsearch import Elasticsearch
import spacy
import os
import json
from pymongo import MongoClient
from spacy.pipeline import EntityRuler
import hashlib
import inflection
def set_custom_boundaries(doc):
View Data for AreaBump
[
{
"data": [
{
"x": 2013,
"y": 1
},
{
"x": 2014,
"y": 3
View routes.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: api-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
View Dockerfile-sitemaps
FROM nginx
RUN mkdir /usr/share/nginx/html/sitemaps
COPY *.xml /usr/share/nginx/html/sitemaps/
View generate_sitemaps.py
import urllib, json
import glob
import os
import pymongo
from pymongo import MongoClient
# Set the latest Block form the API
client = MongoClient(os.environ["DB"])
View Frontend Helm template
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
name: frontend
spec:
type: LoadBalancer
ports:
- name: http
View Sitemaps Job
apiVersion: batch/v1
kind: Job
metadata:
name: sitemap
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: sitemap
View Generate index
sitemapindex = '<?xml version="1.0" encoding="UTF-8"?>\n'
sitemapindex = sitemapindex + '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
for file in glob.glob('*.xml'):
sitemapindex = sitemapindex + '<sitemap>\n'
sitemapindex = sitemapindex + ' <loc>http://inkl.in/sitemaps/' + file + '</loc>\n'
sitemapindex = sitemapindex + '</sitemap>\n'
sitemapindex = sitemapindex + '</sitemapindex>'
View Generate sitemaps
for x in range(int(data["block_number"]), 1, -1):
line = line + "<url>\n"
line = line + "<loc>http://inkl.in/"+str(x)+ "</loc>\n"
line = line + "<changefreq>never</changefreq>"
line = line + "</url>\n"
counter=counter+1
if counter == 50000:
counter = 1
print("Writing " + str(filename))