Skip to content

Instantly share code, notes, and snippets.

View bigsnarfdude's full-sized avatar

BigsnarfDude bigsnarfdude

View GitHub Profile
@bigsnarfdude
bigsnarfdude / Phi-4-reasoning-plus.py
Created May 1, 2025 12:36
Phi-4-reasoning-plus.py
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-reasoning-plus")
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-reasoning-plus", device_map="auto", torch_dtype="auto")
messages = [
{"role": "system", "content": "You are Phi, a language model trained by Microsoft to help users. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracing, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> {Thought section} </think> {Solution section}. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summ
@bigsnarfdude
bigsnarfdude / time_series_forcasting_neuralProphet.py
Created April 28, 2025 17:48
time_series_forcasting_neuralProphet.py
from neuralprophet import NeuralProphet
import pandas as pd
df = pd.read_csv('daily_video_counts_vs_chalk_talks.csv')
m = NeuralProphet()
metrics = m.fit(df, freq="D")
forecast = m.predict(df)
You can want different things from a university—superlative basketball, an arts center, competent instruction in philosophy or physics, even a cure for cancer. No wonder these institutions struggle to keep everyone happy.
And everyone isn’t happy. The Trump Administration has effectively declared open war on higher education, targeting it with deep cuts to federal grant funding. University presidents are alarmed, as are faculty members, and anyone who cares about the university’s broader role.
Because I’m a historian of science and technology, part of my terrain is the evolving role of the university—from its medieval, clerical origins to the entrepreneurial R. & D. engines of today. I teach among the humanists, and my courses are anchored in the traditional program of the liberal arts, in the hope of giving shape to humans equal to the challenge of freedom. But my subject is the rise of a techno-scientific understanding of the world, and of ourselves in it. And, if that is what you care about, the White Ho
@bigsnarfdude
bigsnarfdude / upgrade_recommendations_gemini.md
Created April 22, 2025 16:05
upgrade_recommendations_gemini.md

Codebase Overview

  • Technology: Ruby on Rails (likely v5/6), PostgreSQL, CoffeeScript, jQuery, SCSS, RSpec, Devise, Pundit, Administrate, Que/Sucker Punch, Griddler, Liquid templates, Webpacker[cite: 13, 14, 17, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29].
  • Structure: Standard Rails MVC, utilizing service objects (app/services) [cite: 14] and model concerns (app/models/concerns) [cite: 13] for logic organization. Includes background jobs (app/jobs) [cite: 13] and Pundit policies (app/policies) [cite: 14] for authorization.
  • Key Features: Event/Membership management, Scheduling, Invitations/RSVP system, Email processing (incoming via Griddler, outgoing via multiple mailers), Admin dashboard, JSON API[cite: 13, 14, 16].
  • Legacy Integration: Contains code (LegacyConnector, SyncMembers, SyncPerson services) [cite: 14, 448, 453, 463, 464, 473, 474] suggesting integration with an older system, adding complexity.
  • Testing: Includes a substantial RSpec test suite (spec/)[cite:
@bigsnarfdude
bigsnarfdude / gist:7bdabbd2c6abc80e27cfb923a3890e45
Last active April 21, 2025 15:31
need to validate rails 5.2 to 6

ere's a checklist for testing the defaults in your new_framework_defaults_6_0.rb file:

  1. # Rails.application.config.action_view.default_enforce_utf8 = false

    • Purpose: Stops Rails from automatically adding accept-charset="UTF-8" to forms. This was mainly for older IE versions and is usually unnecessary now.
    • How to Test:
      • Enable it (remove the line or set to false).
      • Check your forms in various browsers, especially if you need to support very old ones. Ensure character encoding works as expected, particularly with non-ASCII characters submitted via forms.
  2. # Rails.application.config.action_dispatch.use_cookies_with_metadata = true

  • Purpose: Embeds purpose and expiry metadata into signed/encrypted cookies to prevent tampering (e.g., copying a cookie's value to another).
@bigsnarfdude
bigsnarfdude / workshops.md
Last active April 21, 2025 04:05
workshops.md

Ruby Upgrade Recommendations

Currently on Ruby 3.0:

  1. Ruby 3.1: Less dramatic changes than 3.0, but introduces pattern matching refinements and a new debugger.

  2. Ruby 3.2: Offers significant performance improvements with YJIT, better error messages, and syntax improvements.

Moving to 3.2 would be a good target as it has performance benefits without being too cutting edge.

You need to restore a PostgreSQL dump to your Docker container. Here's how to do it:
1. First, make sure you're working with the correct database container (`wsdb-upgrade`) which is running PostgreSQL 13.1
2. Use the `docker exec` command to pipe the dump file into the `psql` command inside the container:
```bash
cat workshops_staging.dump | docker exec -i wsdb-upgrade psql -U postgres -d workshops
```
@bigsnarfdude
bigsnarfdude / zipGit.sh
Created April 19, 2025 16:12
bash to zip git all files for checkins
# Define the oldest and newest commit hashes
OLDEST_COMMIT="e8264b948705ec4adefb9caa875c569753134516"
NEWEST_COMMIT="5b524772c15f9b7cff017bdb000db40709da28a4"
# Create a temporary directory to store the files
mkdir -p rails6_upgrade_files
# Get list of all changed files between these commits
git diff --name-only $OLDEST_COMMIT..$NEWEST_COMMIT > changed_files.txt
@bigsnarfdude
bigsnarfdude / image_segmentation_gemini_api.html
Created April 18, 2025 15:30
image_segmentation_gemini_api.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gemini API Image Mask Visualization</title>
<script type="module">
import { GoogleGenerativeAI } from "https://esm.run/@google/generative-ai";
import { marked } from "https://esm.run/marked";
@bigsnarfdude
bigsnarfdude / image_segmentation.py
Created April 16, 2025 15:23
image_segmentation.py
# Copyright 2024 Big Vision Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,