This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{cell::RefCell, rc::Rc, time::Duration}; | |
use slint::{Image, Rgba8Pixel, SharedPixelBuffer, Timer, TimerMode, SharedString}; | |
slint::slint! { | |
import { LineEdit, HorizontalBox, Slider, VerticalBox, CheckBox, SpinBox, TextEdit } from "std-widgets.slint"; | |
export global Properties { // trying separate global structs just in case: | |
in-out property <int> counter: 0; // https://github.com/slint-ui/slint/discussions/3948 | |
in-out property <float> red: 0.65; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Union, Generator, Iterator | |
from pydantic import BaseModel | |
import os | |
import requests | |
class Pipeline: | |
class Valves(BaseModel): | |
OPENROUTER_API_BASE_URL: str = "https://openrouter.ai/api/v1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Union, Generator, Iterator | |
from pydantic import BaseModel | |
import os | |
import requests | |
class Pipeline: | |
class Valves(BaseModel): | |
DEEPSEEK_API_BASE_URL: str = "https://api.deepseek.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created in response to Stack Overflow question: | |
# http://stackoverflow.com/questions/38504004/interpolate-multiline-string-with-correct-indent | |
module CoreExtensions | |
module String | |
module Heredoc | |
# Special character to flag lines that are part of a multiline HEREDOC interpolation | |
# Any character that is not part of the output string will work. Using "\r" because | |
# it's rarely used in hard-coded strings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following code lets you iterate over large collections of Active Record | |
# objects without having to load them all at once, thus reducing memory usage. | |
# It’s allowed me to run cron jobs which iterate over thousands of records | |
# without getting the cron’d process killed for using too much of a system’s | |
# resources. | |
# | |
# Taken from Flying Machine Studios | |
# http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/ | |
# Author: Daniel Higginbotham |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Surround a heredoc with quotes and you can continue the code on the same line: | |
render :status => 404, :text => <<-'EOH' and return unless setup | |
article not found<br/> | |
I, as a server, have failed<br/> | |
https? | |
EOH | |
Quotes also give you more freedom/creativity with the terminal ID: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'stemmer' | |
class NaiveBayes | |
# provide a list of categories for this classifier | |
def initialize(categories) | |
# keeps a hash of word count for each category | |
@words = Hash.new | |
@total_words = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Spinner | |
private | |
@work | |
@job | |
def spinner | |
return(['\\','|','/','-'][@i%4]) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Find bloating passengers and kill them gracefully. Run from cron every minute. | |
# | |
# required for passenger since cron has no environment | |
ENV['HTTPD'] = 'httpd' | |
MEM_LIMIT = ARGV[0] || 500 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Spinner | |
private | |
@work | |
@job | |
def spinner | |
return(['\\','|','/','-'][@i%4]) | |
end |