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

f4eamogj2e

@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

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:

# 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")
@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')
@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 / 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 / pacmd-loopback.fish
Last active October 5, 2020 04:43
Interactively loop audio with fzf and fish shell. I use this function to play audio on my headphones and bluetooth speakers at the same time. I do this by selecting my system output to be the speakers, and then looping the speaker output into my headphones.
function pacmd-loopback --description 'Loop a pacmd source into a pacmd sink interactively.'
if test (set source (pacmd list-sources | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a source" --phony); set sink (pacmd list-sinks | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a sink:"); printf "No\nYes" | fzf-tmux --header="CONFIRM: <$source> -> <$sink>") = "Yes"
pacmd load-module module-loopback source=$source sink=$sink
else
echo "Aborted."
@LinuxIsCool
LinuxIsCool / og_fish_prompt.fish
Created September 25, 2020 08:50
Backing up my favourite fish prompt. A modification of the gentoo omf theme.
function _virtualfish
if set -q VIRTUAL_ENV
echo -n -s (set_color white) "(" (basename "$VIRTUAL_ENV") ")" (set_color normal) " "
end
end
function fish_prompt
set fish_greeting
set -l cyan (set_color -o cyan)
set -l red (set_color -o red)
@LinuxIsCool
LinuxIsCool / path_explorer.fish
Created September 25, 2020 06:39
Fish recipe for interactively searching all of the commands on your path and openining the selected man page.
# Inspiration from: https://github.com/jorgebucaran/cookbook.fish#how-do-i-find-and-run-commands-in-fish
# Set $all_commands to a list of all commands available on $PATH
set -l all_commands (ls $PATH | column)
# Use `whatis` to append a one-line description of each command to a file
for p in $all_commands
whatis $p | tee -a all_command_descriptions
end