This gist has been turned into a full GitHub project: https://github.com/brandonscript/Flex
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
#!/bin/bash | |
# Trap ctrl+C (SIGINT) to exit functions mid-execution | |
trap "echo -e '\nBitrates was interrupted, exiting...'; exit 1" SIGINT | |
# Initialize variables | |
calc_enabled=false | |
organize_enabled=false | |
organize_test=false | |
delete_mode=false |
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 client"; | |
// This file is copied from MUI's Slider component and modified to support multiple thumbs with the getThumbIndex API | |
// exposed as a prop so that we can programatically determine which thumb is focused outside of this component. | |
// Original source: https://github.com/mui/material-ui/blob/v5.x/packages/mui-material/src/Slider/Slider.js | |
// Docs: https://v5.mui.com/material-ui/react-slider/ | |
import _extends from "@babel/runtime/helpers/esm/extends"; | |
import { | |
SliderMark, |
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
import { TextField, type TextFieldProps } from "@mui/material"; | |
import { forwardRef, useImperativeHandle, useState } from "react"; | |
import { type Options as UseDebouncedCallbackOptions, useDebouncedCallback } from "use-debounce"; | |
export type DebouncedTextFieldRef = { | |
cancelDebounce?: () => void; | |
clear: () => void; | |
}; | |
type DebouncedTextFieldProps = TextFieldProps & { |
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
import classNames from "classnames"; | |
// This is from another project isn't properly published yet, | |
// but you can grab it from https://github.com/brandonscript/mui-flexy | |
import { FlexBox, FlexBoxProps } from "components/ui/flexbox"; | |
import deepmerge from "deepmerge"; | |
import { toFiniteInt } from "lib/numbers"; | |
import { toSentenceCase } from "lib/strings"; | |
import NextImage, { ImageProps as NextImageProps } from "next/image"; |
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 python | |
from pathlib import Path | |
from typing import Union, Iterable | |
def is_sys_file(path: Union[str, 'Path', 'WalkPath']) -> bool: | |
"""Checks to see if the path provided is a system file. | |
Args: | |
path (str or Pathlike): Path to check |
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
// Requires macros: | |
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI)) | |
#define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI) | |
- (UIImage *)imageRotatedByDegrees:(CGFloat)degrees | |
{ | |
// calculate the size of the rotated view's containing box for our drawing space | |
UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.size.width, self.size.height)]; | |
CGAffineTransform t = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees)); |
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
- (UIImage *)fixRotation | |
{ | |
if (self.imageOrientation == UIImageOrientationUp) return self; | |
CGAffineTransform transform = CGAffineTransformIdentity; | |
switch (self.imageOrientation) { | |
case UIImageOrientationDown: | |
case UIImageOrientationDownMirrored: | |
transform = CGAffineTransformTranslate(transform, self.size.width, self.size.height); | |
transform = CGAffineTransformRotate(transform, M_PI); |
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
// If you're using Interface Builder, set your UITextView or UIScrollView bottom constraint to the bottom layout guide, constant=0, then create an IBOutlet for the constraint. | |
// If you're writing it in code, create that constraint programatically and make sure it's a @property. | |
- (void)viewDidAppear:(BOOL)animated | |
{ | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; | |
// You're probably going to do this, but it's not actually part of the example | |
_textView.delegate = self; |