This gist has been turned into a full GitHub project: https://github.com/brandonscript/Flex
This file contains 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 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 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 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 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; |