Skip to content

Instantly share code, notes, and snippets.

@therealFoxster
therealFoxster / nif.py
Created April 4, 2023 20:35
Newton's Iterative Formula in SageMath
# Function variable x
x = var('x');
# Function f(x)
f(x) = (x-3)*ln(x)-1;
# Derivative f'(x)
df = diff(f,x);
# Newton's Iterative Formula
@therealFoxster
therealFoxster / DownloadItem.h
Created May 24, 2023 03:40
Some of uYou's header files
#import "uYouItem.h"
@interface DownloadItem : NSObject <NSCoding>
@property (nonatomic, readwrite, strong) NSString *downloadIdentifier;
@property (nonatomic, readwrite, strong) NSString *videoID;
@property (nonatomic, readwrite, strong) NSString *filePath;
@property (nonatomic, readwrite, strong) NSURL *remoteURL;
@property (nonatomic, readwrite, strong) uYouItem *uYouItem;
@property (nonatomic, readwrite, assign) int type;
@property (nonatomic, readwrite, strong) NSURLSessionDownloadTask *downloadTask;
@therealFoxster
therealFoxster / jquery-sel.js
Last active February 14, 2024 04:17
jQuery-like element selector
export const $ = s => s.startsWith("#") && ![".", " ", ">"].some(c => s.includes(c))
? document.getElementById(s.substring(1))
: document.querySelector(s);
export const $$ = s => document.querySelectorAll(s);
@therealFoxster
therealFoxster / custom-select.js
Last active August 19, 2025 05:13
A solution to get filtered options in React Select
import { useState } from 'react';
import Select, { components } from 'react-select';
export default function CustomSelect() {
const [filteredOptions, setFilteredOptions] = useState<Options<{ value: string | number; label: string }>>([]);
const currentFilteredOptions = useRef<Options<{ value: string | number; label: string }>>([]);
useEffect(() => {
const newOptions = currentFilteredOptions.current;
if (JSON.stringify(newOptions) !== JSON.stringify(filteredOptions)) {