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 / rustr.fish
Created November 15, 2024 18:53
Function for building and running a rust script using local build directory
function rustr
if test (count $argv) -ne 1
echo "Usage: rustr <filename>"
return 1
end
set filename $argv[1]
set output_file (string replace -r '\.rs$' '' $filename)
# Create the build directory if it doesn't exist
@LinuxIsCool
LinuxIsCool / generat_ requirements.sh
Created November 7, 2024 17:22
Generate requirements.txt from poetry
poetry export -f requirements.txt --without-hashes | sed 's/;.*//' > requirements.txt
@LinuxIsCool
LinuxIsCool / serialize_param.py
Last active October 17, 2024 23:20
Simple Serialization for Nested Parameterized Objects
import param as pm
import pandas as pd
def serialize_param(obj: pm.Parameterized, skip_dataframes=True, exclude_params=None):
"""
Recursively serialize a Parameterized object into a nested dictionary.
Parameters:
- obj: pm.Parameterized
The object to serialize.
@LinuxIsCool
LinuxIsCool / hvpoints.py
Created October 5, 2024 16:44
Simple but Powerful usage of Holoviews Points
import holoviews as hv
hv.extension('bokeh')
import pandas as pd
nodes = [
{
'name': 'A',
'x': 1,
'y': 0.5,
@LinuxIsCool
LinuxIsCool / line.py
Created September 26, 2024 17:07
Simplest line between two points in hvplot and holoview
import pandas as pd
import holoviews as hv
import hvplot.pandas
hv.Points((1,1)).opts(size=10) * hv.Points((2,2)).opts(size=10) * pd.DataFrame([[1,1],[2,2]]).hvplot.line(x='0',y='1')
@LinuxIsCool
LinuxIsCool / poetry_requirements.sh
Created May 7, 2024 20:15
Create simple requriements file from poetry environment
poetry export -f requirements.txt --without-hashes | sed 's/;.*//' > requirements.txt
@LinuxIsCool
LinuxIsCool / market_sim_stream.py
Created April 26, 2024 17:53
Simple data generator with streamz
from streamz import Stream
def market_step(market_inputs):
return {'market_movement': market_inputs['market_movement']}
def write(x):
print(x)
def f(n=5):
source = Stream(asynchronous=True) # Configure the stream for asynchronous operation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LinuxIsCool
LinuxIsCool / hvplot_legends.py
Created March 26, 2024 16:13
Modifying legend positions in hvplot
import pandas as pd
import hvplot.pandas
df = pd.DataFrame({'x':range(10),'y':range(10), 'z':range(10)})
df.hvplot.step(x='x').opts(legend_position='top_left')
df = pd.DataFrame({'x':range(10),'y':range(10),'z':range(10)})
df.hvplot.line(x='x', legend='left')
@LinuxIsCool
LinuxIsCool / panel_param_hvplot_resettable.py
Created March 24, 2024 00:39
Python Param Panel with Resettable Button
import param as pm
import panel as pn
import hvplot.pandas
import pandas as pd
import numpy as np
pn.extension()
class ResettableParameterized(pm.Parameterized):
def _reset(self):
with pm.parameterized.batch_call_watchers(self):