Skip to content

Instantly share code, notes, and snippets.

@bennokr
bennokr / README.md
Last active April 24, 2024 11:16
tljh setup

TLJH setup

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

@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 / bplist2json.py
Created March 1, 2016 17:57
Convert an Apple Binary Property List (bplist) to json
"""
Convert an Apple Binary Property List (bplist) to json
"""
import ccl_bplist # https://github.com/cclgroupltd/ccl-bplist
from datetime import datetime
def clean_archive(d):
if type(d) in [dict, ccl_bplist.NsKeyedArchiverDictionary]:
@bennokr
bennokr / README.md
Last active December 5, 2023 19:38
Extract citations from Wikipedia dumps

Extract citations from Wikipedia dumps

This script makes a best-effort at resolving inline references and citations. Wikipedia citations are complicated, so this is a quick and dirty hack. It's intented for research in resolving citations and natural language processing.

Similar tools:

@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 / categorylinks.sql
Last active January 12, 2023 13:43
Parsing Wikipedia Page Hierarchy in sqlite or duckdb
@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)