Skip to content

Instantly share code, notes, and snippets.

View alexcg1's full-sized avatar

Alex Cureton-Griffiths alexcg1

View GitHub Profile
@alexcg1
alexcg1 / check_notebook.py
Created June 8, 2020 23:54
Check if a script is running in a notebook, and if so, return the notebook provider name
import os
def check_notebook():
if os.environ.get('COLAB_GPU', False):
return "colab"
elif os.environ.get('KAGGLE_DATA_PROXY_TOKEN', True):
return "kaggle"
else:
return False
@alexcg1
alexcg1 / stop-colab-timeout.js
Last active June 9, 2020 01:03
Stop Google Colab Timeout
function KeepClicking(){
console.log("Clicking");
document.querySelector("colab-connect-button").click()
}
setInterval(KeepClicking,60000)
@alexcg1
alexcg1 / sed_input
Created June 14, 2020 00:19
Changing mysql bind address
sed -i 's/#bind-address.*= 127.0.0.1/bind-address\t= 0.0.0.0/' mysqld.cnf
# Should allow any host to connect to mysql database
def index():
with f:
f.index_lines(['abc', 'cde', 'efg'], batch_size=64, read_mode='r', size=num_docs)
def index():
with f:
f.index_lines(filepath='data/startrek_tng.csv', batch_size=64, read_mode='r', size=num_docs)
num_docs = os.environ.get('MAX_DOCS', 50000)
num_docs = os.environ.get('MAX_DOCS', 500)
{
"matchDoc": {
"docId": 421,
"weight": 1.0,
"mimeType": "text/plain",
"text": "WORF!Vessel unknown, configuration unknown, sir.\n"
},
"score": {
"value": 0.748656,
"opName": "BiMatchRanker"
from jina.flow import Flow
# other code here
def index():
f = Flow.load_config('flows/index.yml')
!Flow
with:
logserver: true
pods:
crafter:
yaml_path: pods/craft.yml
read_only: true
encoder:
yaml_path: pods/encode.yml
replicas: $REPLICAS