Skip to content

Instantly share code, notes, and snippets.

View danlester's full-sized avatar

Dan Lester danlester

View GitHub Profile
@danlester
danlester / GACentric_Google_RegHandler.apex
Last active October 11, 2016 15:18
Google Apps Login for Salesforce
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 June 15, 2018 10:13
Tensorflow Datasets API for processing CSV string column into int tensor
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 08:12
Config to add DockerSpawner to TLJH
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}"
import streamlit as st
from datetime import datetime
start_time = datetime.now()
st.write(start_time)
count = 0
if st.button('Increment'):
count += 1
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)
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=[
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={
@danlester
danlester / Voila Username API.ipynb
Created September 9, 2020 18:29
Voila Username API
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 December 6, 2021 16:31
Generate a lot of files for testing
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 January 13, 2022 10:32
Traefik CRD Terraform problem
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.7.1"
}
}
required_version = ">= 1.0"
}