Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Lester danlester

View GitHub Profile
@danlester
danlester / GACentric_Google_RegHandler.apex
Last active Oct 11, 2016
Google Apps Login for Salesforce
View GACentric_Google_RegHandler.apex
global class GACentric_Google_RegHandler implements Auth.RegistrationHandler{
global User createUser(Id portalId, Auth.UserData data){
List<User> users = [SELECT Id, username, email FROM User WHERE email = :data.email];
if (users.size() == 0) {
return null;
}
@danlester
danlester / model.py
Created Jun 15, 2018
Tensorflow Datasets API for processing CSV string column into int tensor
View model.py
CSV_COLUMNS = ['p{}'.format(i) for i in range(30)] + ['Image']
CSV_COLUMN_DEFAULTS = [[0.0]]*30 + [['']]
def parse_csv(rows_string_tensor):
columns = tf.decode_csv(rows_string_tensor, record_defaults=CSV_COLUMN_DEFAULTS)
raw_features = dict(zip(CSV_COLUMNS, columns))
image_str_array_sparse = tf.string_split([raw_features['Image']])
image_str_array = tf.sparse_to_dense(image_str_array_sparse.indices, image_str_array_sparse.dense_shape, image_str_array_sparse.values, '')
image_str_array = image_str_array[0]
@danlester
danlester / dockerspawner_tljh_config.py
Last active May 10, 2020
Config to add DockerSpawner to TLJH
View dockerspawner_tljh_config.py
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.image = 'ideonate/jh-voila-oauth-singleuser:latest'
from jupyter_client.localinterfaces import public_ips
c.JupyterHub.hub_ip = public_ips()[0]
c.DockerSpawner.name_template = "{prefix}-{username}-{servername}"
View streamlit_concurrency.py
import streamlit as st
from datetime import datetime
start_time = datetime.now()
st.write(start_time)
count = 0
if st.button('Increment'):
count += 1
View streamlit_concurrency2.py
import streamlit as st
@st.cache
def get_start_time():
from datetime import datetime
return datetime.now()
start_time = get_start_time()
st.write(start_time)
View plotlydash_concurrency.py
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
from datetime import datetime
app = dash.Dash(__name__)
start_time = datetime.now()
app.layout = html.Div(children=[
View jupyterhub_groups_rest_api.py
import requests
api_url = 'https://myjupyterhub.net/hub/api'
token = '<token from token menu of an admin user>'
# List all groups
r = requests.get(api_url + '/groups',
headers={
View Voila Username API.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danlester
danlester / make_lots_of_files.py
Created Dec 6, 2021
Generate a lot of files for testing
View make_lots_of_files.py
import os
from pathlib import Path
jupyter_user = os.environ['JUPYTERHUB_USER']
def make_files(depth, breadth, start_folder, key, max_depth=3):
print(f"Make Files at depth {depth}")
for i in range(0,breadth):
with Path(start_folder, f"testfile_{key}_{depth}_{i}.txt").open("wt") as f:
f.write("Here is the file.")
if depth < max_depth:
@danlester
danlester / kubernetes.tf
Created Jan 13, 2022
Traefik CRD Terraform problem
View kubernetes.tf
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.7.1"
}
}
required_version = ">= 1.0"
}