Skip to content

Instantly share code, notes, and snippets.

View LinuxIsCool's full-sized avatar
💭
Preparing the ship.

Shawn Anderson LinuxIsCool

💭
Preparing the ship.
View GitHub Profile
@LinuxIsCool
LinuxIsCool / chess.py
Created March 12, 2021 16:51 — forked from rsheldiii/chess.py
chess program for python
"""CONVENTIONS:
positions are done row-column from the bottom left and are both numbers. This corresponds to the alpha-number system in traditional chess while being computationally useful. they are specified as tuples
"""
import itertools
WHITE = "white"
BLACK = "black"
@LinuxIsCool
LinuxIsCool / BokehFigure.py
Created March 15, 2021 02:59 — forked from philippjfr/BokehFigure.py
Defines a BokehFigure element which allows wrapping bokeh Figures in a HoloMap - BSD-3 License
from holoviews import Element, Store
from bokeh.models import Column
from holoviews.plotting.bokeh import ElementPlot
class BokehFigure(Element):
"""Wraps bokeh figure"""
class BokehFigurePlot(ElementPlot):
def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
@LinuxIsCool
LinuxIsCool / jupyter_logging.py
Created April 3, 2021 00:42 — forked from wassname/jupyter_logging.py
simple logging for jupyter or python which outputs to stdout (or a console or terminal) and a log file
"""
In jupyter notebook simple logging to console
"""
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
# Test
logger = logging.getLogger('LOGGER_NAME')
# pip install pandas hvplot==0.7.1 holoviews==1.14.3 bokeh panel==0.11.3
# panel serve holoviz_linked_brushing.py --auto --show
import hvplot.pandas
import holoviews as hv
import panel as pn
from bokeh.sampledata.iris import flowers
pn.extension(sizing_mode="stretch_width")
hv.extension("bokeh")

Keybase proof

I hereby claim:

  • I am linuxiscool on github.
  • I am ygg_odin (https://keybase.io/ygg_odin) on keybase.
  • I have a public key ASAyiq1D9Xh1wB3cC9OrzdrA2p0GoPnx6sgqFA2kaYCLlwo

To claim this, I am signing this object:

@LinuxIsCool
LinuxIsCool / Django for Jupyter.md
Created May 12, 2022 16:44 — forked from codingforentrepreneurs/Django for Jupyter.md
Django Setup for use in Jupyter Notebooks

Django for Jupyter

It's true packages exist to make it "easy" to use Django inside of a jupyter notebook. I seem to always run into issues successfully running these packages. I've found the below method useful although I cannot recall how I discovered how this works (aka attribution needed).

Requirements

  • Virtual Environment (virtualenv, venv, pipenv, etc)
  • Django installed & project created (we'll use the project name cfehome)
  • Jupyter installed at least in the virtual environment

f4eamogj2e

@LinuxIsCool
LinuxIsCool / README.md
Created November 20, 2022 02:44 — forked from nikoheikkila/README.md
Fish Shell function for sourcing standard .env files

envsource

I've been using Fish shell for years which is great and all, but one thing that has got me frustrated is using it with .env files.

When attempting to run source .env in a project, I usually encounter this problem:

.env (line 2): Unsupported use of '='. In fish, please use 'set KEY value'.
from sourcing file .env
source: Error while reading file '.env'
@LinuxIsCool
LinuxIsCool / panel_param.py
Created November 30, 2022 21:45
Most basic python panel param hvplot dataframe example possible.
"""
Run this in a Jupyter Cell
"""
import param as pm
import pandas as pd
import numpy as np
import hvplot.pandas
class A(pm.Parameterized):
@LinuxIsCool
LinuxIsCool / dynamic_display_threshold.py
Created November 30, 2022 22:31
Minimum viable embedded app and dynamic display threshold example for python param panel
import param as pm
import panel as pn
pn.extension()
class Protocol(pm.Parameterized):
display_level = pm.Integer(default=1, bounds=(0, 2), step=1, precedence=2)
target_apy = pm.Number(0.15, bounds=(0,1), precedence=1)
total_curve_pool_tvl = pm.Number(1e7, bounds=(0,None), precedence=0)
def __init__(self):