Skip to content

Instantly share code, notes, and snippets.

View sepbot's full-sized avatar
👞
shoehorning code

sepbot

👞
shoehorning code
View GitHub Profile
@sepbot
sepbot / roomy.zsh-theme
Created October 30, 2023 23:56
roomy zsh prompt
PROMPT=$'\n'
PROMPT+=' %{$fg[yellow]%}%n@%m%{$reset_color%}'
PROMPT+=' %{$fg[cyan]%}%~%{$reset_color%} $(git_prompt_info)'
PROMPT+=$'\n'" "
PROMPT+="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT+="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
val ctx = Context.newBuilder()
.allowAllAccess(true)
.build()
@Language("Python") val script = """
import polyglot
@polyglot.export_value
def main(x):
return x + 1
""".trimIndent()
use std::{env, io::Error as IoError, net::SocketAddr};
use futures_util::StreamExt;
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::accept_async;
use tungstenite::Error;
async fn handle_connection(raw_stream: TcpStream, addr: SocketAddr) -> tungstenite::Result<()> {
defmodule Test do
# runs command and logs outputs when they become available, mostly useful for long running commands that
# provide incremental output as the command progresses
def run_command_and_log!(host, conn, command) do
res = Enum.reduce(
SSHEx.stream(conn, command, channel_timeout: 10_000, exec_timeout: 3_600_000),
%{:status => nil,:stdout => [], :stderr => []},
fn (x, acc) ->
case x do
{:stdout, row} ->
@sepbot
sepbot / touch.ts
Created February 4, 2020 21:07
somehow implementing these touch event handlers from scratch yielded less code than using something like hammer.js
import { XY } from './types';
export const setupTouch = (
container: HTMLElement,
animate: () => void,
tapped: (position: XY) => void,
panned: (delta: XY) => void,
pinched: (delta: number) => void,
) => {
const ctx = {
@sepbot
sepbot / poly.py
Created October 21, 2019 05:12
sklearn Polynomial Regression
class PolynomialRegression(BaseEstimator):
def __init__(self, degree=2):
self.features = PolynomialFeatures(degree=degree)
self.model = LinearRegression()
def get_params(self, deep=True):
return {'degree': self.features.degree}
def set_params(self, **params):