Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
sergiolucero / graphqlapp.py
Created June 20, 2019 13:33
basic flask-graphql app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from flask_graphql import GraphQLView
#################################
app = Flask(__name__)
app.debug = True
@rgalhama
rgalhama / spacy_parse_as_conllu.py
Last active November 21, 2018 13:06
Script to parse text with Spacy and print the output in CoNLL-U format.
"""
__author__ = "Raquel G. Alhama"
__email__ = "rgalhama@gmail.com"
Script to parse text with Spacy and print the output in CoNLL-U format.
Refs:
https://spacy.io/
http://universaldependencies.org/format.html
"""
@MauricioMoraes
MauricioMoraes / access_postgresql_with_docker.md
Last active May 2, 2024 10:21
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@GreenRiverRUS
GreenRiverRUS / convert.py
Created November 25, 2017 20:41
Simple converter to ConLL-2003 NER format for spaCy model training
DATA = [
[
[['Who', 'is', 'Shaka', 'Khan', '?'], ['O', 'O', 'I-PER', 'I-PER', 'O']]
],
[
[['I', 'like', 'London', 'and', 'Berlin', '.'], ['O', 'O', 'I-LOC', 'O', 'I-LOC', 'O']]
]
]
with open('output.conll', 'w') as f:
@chssch
chssch / spacy_srl.py
Last active March 1, 2023 18:01
Use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions
# This small script shows how to use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions
# Script installs allennlp default model
# Important: Install allennlp form source and replace the spacy requirement with spacy-nightly in the requirements.txt
# Developed for SpaCy 2.0.0a18
from allennlp.commands import DEFAULT_MODELS
from allennlp.common.file_utils import cached_path
from allennlp.service.predictors import SemanticRoleLabelerPredictor
from allennlp.models.archival import load_archive
@leanderjanssen
leanderjanssen / registry-minio.md
Last active February 29, 2024 06:28
Docker Registry with Minio storage example

Running a docker registry with Minio S3 backend

Run minio in a container

docker run -d -p 9000:9000 --name minio minio/minio server /export

Use docker logs to retrieve access key and secret key from minio container

docker logs minio

Create config.yml for Docker Registry

This file will have to be mounted to /etc/docker/registry/config.yml

@pcan
pcan / README.md
Created April 3, 2017 09:16
Compile Redis with Cygwin

Prerequisites

Install Cygwin with make, gcc & g++. Download Redis tar.gz package, unpack it.

Patch

Edit deps/hiredis/net.c and add the following lines just after the include directives:

@sourceperl
sourceperl / detect_tones.py
Last active January 9, 2023 05:37
Display sound spectral view with scipy FFT and matplotlib
#!/usr/bin/python3
# detect tones in sound spectrum with scipy FFT
# here sound source is a USB microphone with ALSA (channel 1)
from collections import deque
import struct
import sys
import time
import threading
@IanHopkinson
IanHopkinson / lxml_examples.py
Created November 24, 2015 19:42
Examples of xpath queries using lxml in python
#!/usr/bin/env python
# encoding: utf-8
import lxml.etree
import lxml.html
import requests
xml_sample = """<?xml version="1.0" encoding="UTF-8"?>
<foo:Results xmlns:foo="http://www.foo.com" xmlns="http://www.bah.com">
<foo:Recordset setCount="2">
@tecoholic
tecoholic / osm2geo.js
Created November 27, 2011 04:57
OSM2GEO - A JS Converter to convert OSM to GeoJSON
/**************************************************************************
* OSM2GEO - OSM to GeoJSON converter
* OSM to GeoJSON converter takes in a .osm XML file as input and produces
* corresponding GeoJSON object.
*
* AUTHOR: P.Arunmozhi <aruntheguy@gmail.com>
* DATE : 26 / Nov / 2011
* LICENSE : WTFPL - Do What The Fuck You Want To Public License
* LICENSE URL: http://sam.zoy.org/wtfpl/
*