Skip to content

Instantly share code, notes, and snippets.

@bennokr
bennokr / app.py
Created April 9, 2024 09:12
Annotate literature search results
from flask import Flask, request, abort, render_template
app = Flask(__name__, template_folder='.')
import gspread
import textwrap
gc = gspread.oauth(
credentials_filename='credentials.json',
@bennokr
bennokr / credentials.json
Created March 5, 2024 14:18
Scopus Review
{"installed":{"client_id":"258409864674-jcqkeivqrd8dcb2gv5egl76g384vflld.apps.googleusercontent.com","project_id":"scopus-review","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost"]}}
@bennokr
bennokr / README.md
Last active January 19, 2024 12:18
tljh setup

TLJH setup

the path is to customize /opt/tljh/hub/share/jupyterhub/templates/login.html

@bennokr
bennokr / leaderboard.py
Last active May 6, 2023 06:57
Minimal Flask app of an ML competition leaderboard for JupyterHub
from flask import Flask, g, request, render_template_string, redirect, url_for
from werkzeug.middleware.proxy_fix import ProxyFix
import sqlite3
import pathlib
app = Flask(__name__)
app.url_map.strict_slashes = False
app.wsgi_app = ProxyFix(
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1
)
@bennokr
bennokr / README.md
Last active February 15, 2023 12:04

Jupyter Binder with git collaboration

Binder

This gist can be changed via binder!

This file has been truncated, but you can view the full file.
[
{
"id": 10259,
"cuisine": "greek",
"ingredients": [
"romaine lettuce",
"black olives",
"grape tomatoes",
"garlic",
"pepper",
@bennokr
bennokr / partition.py
Created March 25, 2022 11:05
Partition non-overlapping item clusters
from mip import *
import string, collections
a = string.ascii_uppercase
item_clusters, cluster_size = {}, collections.Counter()
for ci,c in enumerate([a[:6],a[:3],a[3:6],a[6:10],a[10:12]]):
for i in c:
name = 'c'+str(ci)
cluster_size[name] += 1
item_clusters.setdefault(i, set()).add( name )
print(item_clusters, cluster_size)
@bennokr
bennokr / super-classification-report.ipynb
Created March 10, 2022 13:48
Super Classification Report
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bennokr
bennokr / categorylinks.sql
Last active January 12, 2023 13:43
Parsing Wikipedia Page Hierarchy in sqlite or duckdb
@bennokr
bennokr / extract.py
Created February 19, 2020 07:40
PDF table extraction
import collections, itertools
import fitz
def is_inside(inner, outer):
return (
(inner['x2'] >= outer['x1']) and
(inner['y2'] >= outer['y1']) and
(outer['x2'] >= inner['x1']) and
(outer['y2'] >= inner['y1'])
)