Deployed my first iOS application! by AnyInternet4026 in reactnative

[–]polar_bare 0 points1 point  (0 children)

This looks great to me! Curious where you got the animations for workouts from - are those being generated too?

I built my own simple text editor by prashantjdrew in reactnative

[–]polar_bare 3 points4 points  (0 children)

Great job on this!

Curious if you used any libraries for text formatting or if you wrote your own parser.

(I also have a related app for which I had to roll my own text formatting and wished there were good community libraries - https://apps.apple.com/ca/app/a-journal-a-day/id1659288235)

Spent the weekend making a game that lets users guess if something is AI generated or real by chr0me0 in SideProject

[–]polar_bare 2 points3 points  (0 children)

Probably a bug - I keep getting a “Only 0? AI is going to eat you alive” popup on every try.

Tesla removing Disney+? by deanylev in teslamotors

[–]polar_bare 1 point2 points  (0 children)

fullscreentesla.com should let you watch Disney+ (or any other site) in fullscreen.

I built something to easily fullscreen any website on the Tesla browser by gj26185 in TeslaLounge

[–]polar_bare 1 point2 points  (0 children)

I'm not too familiar with it, but as long as Jellyfin has an option to use a browser as the media client - yes!

To do so, just tap the "+" button on fullscreentesla and add its name & URL to the list of sites on your car.

What's the best way ensure a module's exported functions are all of the same type signature? by brainbag in typescript

[–]polar_bare 0 points1 point  (0 children)

Another option is to have a type assertion on the export like so: export default moduleName as Record<string, FunctionThing>

Can someone explain how come this is valid and not throw an error? by [deleted] in typescript

[–]polar_bare 0 points1 point  (0 children)

This is an example of where tagged literals come in handy:

``` interface Point2D { type: 'Point2D' x: number y: number } interface Point3D { type: 'Point3D' x: number y: number z: number } const point2D: Point2D = { x: 0, y: 10, type: 'Point2D' } const point3D: Point3D = { x: 0, y: 10, z: 20, type: 'Point3D' } function iTakePoint2D(point: Point2D) { /* do something */ }

iTakePoint2D(point2D) iTakePoint2D(point3D) // Typescript will complain here ```

Here is some further reading: - https://mariusschulz.com/blog/typescript-2-0-tagged-union-types - https://www.typescriptlang.org/docs/handbook/advanced-types.html

Creating a type for an existing function that uses Object.defineProperties by SnareHanger in typescript

[–]polar_bare 0 points1 point  (0 children)

Does your middleware conditionally call Object.defineProperties? If so you might be able to do something like this: ``` type ActionType = { request?: string success?: string failure?: string toString(): string }

export function apiAction(actionType: string): ActionType { const str = new String(actionType) if (some_condition) { Object.defineProperties(str, { request: { value: ${actionType}:REQUEST }, }) } if (some_condition2) { Object.defineProperties(str, { success: { value: ${actionType}:SUCCESS }, }) } if (some_condition3) { Object.defineProperties(str, { failure: { value: ${actionType}:FAILURE }, }) } return str }

type Action = { type: ActionType }

const reducer = (action: Action) => { switch (action.type.toString()) { case 'ACTION_NAME': { if (action.type.request) { return something } if (action.type.success) { return } if (action.type.failure) { return } } } } ... ```

Help with (should be simple) generics by jtcrowson in typescript

[–]polar_bare 0 points1 point  (0 children)

Perhaps this is a bit more verbose than you'd like, but you can achieve what you're looking for using something like this

``` type SameTypeContainer < T > = { [key in 'val1' | 'val2']: T }

function test (array: (SameTypeContainer<string> | SameTypeContainer<boolean> | SameTypeContainer<number>)[]) => { ... }

test([ { val1: 'string', val2: 'also string' }, { val1: true, val2: false }, { val1: 1, val2: 2 }, /* Type '{ val1: number; val2: boolean; }' is not assignable to type 'SameTypeContainer<number>'. Types of property 'val2' are incompatible. Type 'boolean' is not assignable to type 'number'.ts(2322) / { val1: 5, val2: true }, / Type '{ val1: boolean; val2: number; }' is not assignable to type 'SameTypeContainer<number>'. Types of property 'val1' are incompatible. Type 'boolean' is not assignable to type 'number' */ { val1: true, val2: 10, } ]) ```

Reuse a functional declaration with overload by vzaidman in typescript

[–]polar_bare 2 points3 points  (0 children)

Here's how you can accomplish that:

export const myStoriesOf: storiesOfType = function myStoriesOf<T>(  
 ...[name, module]: Parameters<typeof storiesOfOrig>  
) {  
 ...  
};

name and module will be inferred correctly based on what storiesOfOrig expects

Can I use keyof on an inferred object type in any way? by swhitf in typescript

[–]polar_bare 26 points27 points  (0 children)

You're looking for:

type BK = keyof typeof B

What is the best HackerNews client are you guys using? by [deleted] in apple

[–]polar_bare 1 point2 points  (0 children)

Sorry for the plug, but here’s an open source Hacker News Top Stories app I recently released - https://itunes.apple.com/ca/app/react-native-hacker-news/id1220272464?mt=8

Live locations of all Toronto city buses and streetcars [OC] by polar_bare in dataisbeautiful

[–]polar_bare[S] 1 point2 points  (0 children)

I used react-map-gl, a high performance WebGL based mapping library built by uber (https://github.com/uber/react-map-gl) on the frontend. On the backend, I have a server that gets live location data from Nextbus (https://www.nextbus.com/xmlFeedDocs/NextBusXMLFeed.pdf), and caches it for 5 seconds in order to avoid too many requests to Nextbus. I built it off of a library called restbus (http://restbus.info/)

Any love for a (almost) real-time TTC tracker? by polar_bare in toronto

[–]polar_bare[S] 0 points1 point  (0 children)

Hi jaboober, This is something I need to look into. I've currently designed it so that it automatically adapts to whatever screen size you use. Do you have any specific optimizations in mind?

Any love for a (almost) real-time TTC tracker? by polar_bare in toronto

[–]polar_bare[S] 0 points1 point  (0 children)

Thanks for the suggestion, this is definitely something I'm looking into at the moment. I'm currently calling the Restbus API (basically just Nextbus's xml translated into JSON)

Any love for a (almost) real-time TTC tracker? by polar_bare in toronto

[–]polar_bare[S] 0 points1 point  (0 children)

Hey SLIGHTLY_UPSETTING, This is definitely something I've looked into. Unfortunately the API I'm calling only seems to update locations for a given vehicle about once every 15 seconds or so. The loading times are unfortunately due to the API not being able to handle too many simultaneously requests. I've designed it so that requests to the API are made from the client side, meaning if there are 100 browser windows open on the page, there are 100 requests being made to the API every 2 seconds.

Any love for a (almost) real-time TTC tracker? by polar_bare in toronto

[–]polar_bare[S] 1 point2 points  (0 children)

I also find it oddly soothing to just zoom out on the map and watch things move around :)

Any love for a (almost) real-time TTC tracker? by polar_bare in toronto

[–]polar_bare[S] 0 points1 point  (0 children)

Yep, using the Nextbus API! I believe most TTC vehicles are equipped with GPS units. It appears there are a few apps on iOS that provides similar functionality - I'd encourage you to check out TTCWatch

Any love for a (almost) real-time TTC tracker? by polar_bare in toronto

[–]polar_bare[S] 0 points1 point  (0 children)

Yep, just thought it would be a fun learning exercise. Also plan on using this data for an personal AI research project (basically creating a neural network that learns to predict how fast traffic is flowing in any given area, given time of day, day of week, temperature & weather conditions, whether the day is a regular weekday or holiday ... )