Skip to content

Instantly share code, notes, and snippets.

View stephenlb's full-sized avatar
😀
Coding with Rust

Stephen Blum stephenlb

😀
Coding with Rust
View GitHub Profile
@stephenlb
stephenlb / draw-pytorch-image.py
Last active November 15, 2025 00:26
Draw the Pytorch Image
# -*- coding: utf-8 -*-
import torch
import math
import numpy as np
import matplotlib.pyplot as plt
import torchvision.io as io
import torchvision.transforms as T
from torch.utils.data import TensorDataset, DataLoader
@stephenlb
stephenlb / tutorial.py
Created November 10, 2025 21:28
mnist tensorflow keras tutorial!
import tensorflow as tf
import tensorflow_datasets as tfds
(ds_train, ds_test), ds_info = tfds.load(
'mnist',
split=['train', 'test'],
shuffle_files=True,
as_supervised=True,
with_info=True,
)
@stephenlb
stephenlb / .vimrc
Created October 8, 2025 20:43
Stephen's Vim RC File
set nowrap
set nobackup
set undofile " Undo across sessions
set undolevels=800 " Keep 800 changes to be undone
set undodir=~/.vim/tmp/undo//
nmap <F2> :.w !pbcopy<CR><CR>
vmap <F2> :w !pbcopy<CR><CR>
set noswapfile
@stephenlb
stephenlb / easy_install.sh
Last active September 29, 2025 20:27
# Neovim + Rust Analyzer installation
brew install neovim
rustup component add rust-analyzer
brew install luajit
sudo ln -s `which luajit` /usr/local/bin/lua
nvim -u NORC -c "source https://raw.githubusercontent.com/lumen-oss/rocks.nvim/master/installer.lua"
nvim
:Rocks install rustaceanvim
:RustAnalyzer start
// https://gist.github.com/stephenlb/d1a2972222864afea79076b793e4f58d
const http = require("xhr");
const pubnub = require("pubnub");
const dataUrl = 'https://gist.githubusercontent.com/stephenlb/d1a2972222864afea79076b793e4f58d/raw/4854f61998c6972a87dc63c257b8c8138ea4a541/Chat-flooding_api_calls.json';
const publishKey = '...............';
const subscribeKey = '...............';
let data = null;
let position = 0;
@stephenlb
stephenlb / .screenrc
Created November 13, 2024 18:23
Terminal Setup GNU Screen
startup_message off
vbell on
msgwait 1
defscrollback 200000
hardstatus alwayslastline
hardstatus string '%{= kG}[ Stephen Blum ]%{g}[%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]'
caption string "%{W}%n%f %t%?(%u)%?%{r}"
rendition so =rb 04
@stephenlb
stephenlb / README.md
Last active November 8, 2024 06:35
FemtoGPT Inference Mode

FemtoGPT Inference Mode

To compile and execute the program from a different source file, such as infer.rs, and name the resulting binary infer, follow these modified instructions:

Step-by-step Instructions

  1. Update Project Structure: Create a new source file named infer.rs in the src directory.

    touch src/infer.rs
@stephenlb
stephenlb / blip2-bettertransformer.py
Last active August 30, 2024 20:09
Blip2 transformer with BetterTransformer HuggingFace Optimum 🚀
# YouTube Video https://youtu.be/SDCzXr-mBcw
import torch
import requests
from PIL import Image
from transformers import Blip2Processor, Blip2ForConditionalGeneration
from optimum.bettertransformer import BetterTransformer
# Load the processor and model
processor = Blip2Processor.from_pretrained("Salesforce/blip2-flan-t5-xl")
Images from 120ms to 30ms: Python 🐍 to Rust 🦀🚀 article
@stephenlb
stephenlb / README.md
Created June 19, 2024 23:45
AsyncIO PubNub Subscribe Example

AsyncIO PubNub Subscribe Example

pubnub-asyncio-simple-example

Usage example:

pip install asyncio pubnub
export PUBNUB_PUBLISH_KEY=demo
export PUBNUB_SUBSCRIBE_KEY=demo
python main.py