| Profile | download (kb/s) | upload (kb/s) | latency (ms) |
|---|---|---|---|
| Native | 0 | 0 | 0 |
| GPRS | 50 | 20 | 500 |
| 56K Dial-up | 50 | 30 | 120 |
| Mobile EDGE | 240 | 200 | 840 |
| 2G Regular | 250 | 50 | 300 |
| 2G Good | 450 | 150 | 150 |
| 3G Slow | 780 | 330 | 200 |
| import { TextField } from '@mui/material'; | |
| import { useRef } from 'react'; | |
| export default function TextFieldExt(props) { | |
| const { type } = props; | |
| const noStupidWheelScroll = type === 'number'; | |
| const thisTextField = useRef(null); | |
| const noOnWheelFn = (wheelEv) => { | |
| wheelEv.preventDefault(); | |
| }; |
| // zod schema | |
| z.object({ | |
| // valid if string or: | |
| optional: z.string().optional(), // field not provided, or explicitly `undefined` | |
| nullable: z.string().nullable(), // field explicitly `null` | |
| nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined` | |
| }); | |
| // type | |
| { |
| I've moved this to a proper GitHub project. | |
| Check it out at: | |
| https://github.com/jasonsnell/PurpleAir-AQI-Scriptable-Widget |
| // | |
| // CAMediaTimingFunction.swift | |
| import UIKit | |
| extension CAMediaTimingFunction { | |
| static let linear = CAMediaTimingFunction(name: .linear) | |
| static let easeOut = CAMediaTimingFunction(name: .easeOut) |
| import Foundation | |
| class Box<T> { | |
| let unbox: T | |
| init(_ value: T) { self.unbox = value } | |
| } | |
| struct Notification<A> { | |
| let name: String | |
| } |
I was fresh out of college, still wet behind the ears, and about to enter the beta phase of my first professional game project -- a late-90s PC title. It had been an exciting rollercoaster ride, as projects often are. All the content was in and the game was looking good. There was one problem though: We were way over our memory budget.
Since most memory was taken up by models and textures, we worked with the artists to reduce the memory footprint of the game as much as possible. We scaled down images, decimated models, and compressed textures. Sometimes we did this with the support of the artists, and sometimes over their dead bodies.
We cut megabyte after megabyte, and after a few days of frantic activity, we reached a point where we felt there was nothing else we could do. Unless we cut some major content, there was no way we could free up any more memory. Exhausted, we evaluated our current memory usage. We were still 1.5 MB over the memory limit!
At this point one of the mos
| void CRWaitMinimumDurationAndExecute(NSTimeInterval start, NSTimeInterval minimumDuration, void(^block)(void)) { | |
| double diff = [NSDate date].timeIntervalSince1970-start; | |
| double delayInSeconds = MAX(0.0, minimumDuration-diff); | |
| dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
| dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
| if (block) block(); | |
| }); | |
| } | |
| //Usage |
| extension Array { | |
| func first() -> Element? { | |
| if isEmpty { | |
| return nil | |
| } | |
| return self[0] | |
| } | |
| func last() -> Element? { |
| // Fix for https://github.com/bryanjclark/ios-darken-image-with-cifilter | |
| -(instancetype)darkened:(CGFloat)alpha andBlurredImage:(CGFloat)radius blendModeFilterName:(NSString *)blendModeFilterName { | |
| CIImage *inputImage = [[CIImage alloc] initWithImage:self]; | |
| CIContext *context = [CIContext contextWithOptions:nil]; | |
| //First, create some darkness | |
| CIFilter* blackGenerator = [CIFilter filterWithName:@"CIConstantColorGenerator"]; |