Skip to content

Instantly share code, notes, and snippets.

@frankie567
frankie567 / interactive_google_oauth2.py
Last active July 29, 2023 22:07
Interactive Google OAuth2 flow with Streamlit
import asyncio
import streamlit as st
from httpx_oauth.clients.google import GoogleOAuth2
st.title("Google OAuth2 flow")
"## Configuration"
client_id = st.text_input("Client ID")
@tvst
tvst / SessionState.py
Last active April 14, 2024 20:24
DO NOT USE!!! Try st.session_state instead.
"""Hack to add per-session state to Streamlit.
Usage
-----
>>> import SessionState
>>>
>>> session_state = SessionState.get(user_name='', favorite_color='black')
>>> session_state.user_name
''
@fperez
fperez / LogisticRegressionPart2.ipynb
Created November 8, 2018 16:50
LogisticRegression notebook from Data100 - test for load/kernel creation time on JupyterLab. On my system (2017 13" MBP) this nb takes 14s to open and 15s *extra* to get a kernel with JLab 0.35.4, and 4s total in Classic (no extra time for kernel)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@branflake2267
branflake2267 / database.dart
Last active July 27, 2022 17:37
Flutter - Firebase Realtime Database Persistence
import 'dart:async';
import 'package:firebase_database/firebase_database.dart';
import 'package:intl/intl.dart';
class Database {
static Future<String> createMountain() async {
String accountKey = await _getAccountKey();
@fperez
fperez / README.md
Last active July 1, 2021 04:43
Polyglot Data Science with IPython

Polyglot Data Science with IPython & friends

Author: Fernando Pérez.

A demonstration of how to use Python, Julia, Fortran and R cooperatively to analyze data, in the same process.

This is supported by the IPython kernel and a few extensions that take advantage of IPython's magic system to provide low-level integration between Python and other languages.

See the companion notebook for data preparation and setup.

@maptastik
maptastik / remoteGeoJSONToGDF.py
Last active February 2, 2020 15:42
Pull GeoJSON from the toobz and create a GeoDataFrame
import requests, json, geopandas as gpd
def remoteGeoJSONToGDF(url, display = False):
"""Import remote GeoJSON to a GeoDataFrame
Keyword arguments:
url -- URL to GeoJSON resource on web
display -- Displays geometries upon loading (default: False)
"""
r = requests.get(url)
data = r.json()
@karanvs
karanvs / gist:44599464f72988b138f5bc783f423b07
Created July 7, 2017 07:24
A solution to putting multiple ListViews inside a ScrollView in Flutter
return new Scaffold(
appBar: new AppBar(
title: new Text("Project Details"),
backgroundColor: Colors.blue[800]),
body:
new CustomScrollView(
slivers: <Widget>[
new SliverPadding(padding: const EdgeInsets.only(left: 10.0,right: 10.0,
top: 10.0,bottom: 0.0),
sliver: new SliverList(delegate:
@fperez
fperez / Light data with Google Science Journal.ipynb
Last active February 25, 2019 13:18
Real-world data in a few minutes with Google Science Journal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iandanforth
iandanforth / canvascapture.md
Last active October 5, 2022 10:57
Capture WebGL frames to disk

How to capture WebGL/Canvas by piping data over a websocket.

This Gist builds on https://gist.github.com/unconed/4370822 from @unconed.

Instead of the original method which writes to the browsers sandboxed filesystem here we use a websocket connection provided by websocketd to pipe image data to a short python script that writes out the .png files to disk.

Install websocketd

@timlinux
timlinux / show_project.py
Last active April 3, 2019 14:53
Load and show a QGIS project in python
# coding=utf-8
# A simple demonstration of how to load a QGIS project and then
# show it in a widget.
# This code is public domain, use if for any purpose you see fit.
# Tim Sutton 2015
import os
from qgis.core import QgsProject
from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge