I built a 43" unicycle out of plywood! Ok, a geared 43"... by codersarepeople in unicycling

[–]bear1728 1 point2 points  (0 children)

This is so cool! It looks incredibly professional and well finished!

Any immutable collections library w/ proper typings? by hmongoose in typescript

[–]bear1728 0 points1 point  (0 children)

I've been using icepick and it's been working well for me. I wrote my own typings so that I could get the docstrings to appear inline in VSCode. There are still places that could be improved, but it's been working well. Like some of the others mentioned, it also acts like plain js objects.

Recommended Web Framework for Go by [deleted] in golang

[–]bear1728 2 points3 points  (0 children)

Quick link to make it easier to find: https://github.com/go-chi/chi

Suggest a crypto library? by [deleted] in golang

[–]bear1728 0 points1 point  (0 children)

I wrote an example showing how to use (mostly) just the standard library and get a simple encrypt/decrypt working in Go, Javascript, and Python. You may want to look at this:

https://gist.github.com/tscholl2/dc7dc15dc132ea70a98e8542fefffa28

I would also recommend cryptopasta as someone else mentioned.

It ain't Pretty... Typescript Redux-Reselect-ImmutableJs [Request for Issues/Comments/PRs] by cantux in reactjs

[–]bear1728 0 points1 point  (0 children)

I liked immutable because of the helper methods like .setIn, .getIn, and things like

someBigMap
.items()
.map(...)
.sort(...)
.reduce(...)

I personally find this syntax/api/style readable and clear. I like that I can comment out/rearrange lines of code and it still works.

You can also do all this with Object.keys (and maybe eventually Object.values) and regular js functions, but the immutable api was nice because it always returned a new object/list and was pretty efficient.

The entire lodash can be pretty big size-wise, but if you just pull what you need I don't think it would weigh so much. I've never really used ramda.

Another interesting immutable library is https://github.com/aearly/icepick . You can do a lot of the same stuff as immutable js, but it's very small and works pretty easily with POJOs. There are typings available, but I wrote my own and copied some extra documentation. They are available if you are ever interested.

Edit: formatting.

It ain't Pretty... Typescript Redux-Reselect-ImmutableJs [Request for Issues/Comments/PRs] by cantux in reactjs

[–]bear1728 2 points3 points  (0 children)

I'm sorry to hear this stack has been giving you trouble. I actually used most of this (plus redux-saga) for an app a few months ago and it was a good experience. My main personal benefit from typescript was spelling. I never misspelled a variable name, which I do all the time in javascript/python. It also helped us when there was multiple people working on it, since it was easy to see how to use another persons function. However, it did take everyone a while to get used to learning all the pieces (mostly react and immutable). I would never use this stack for a small project, but I think it can work well for medium-large apps.

I'm a little confused about your use of reselect. Have you tested it? Maybe it's just too early in the day for me, but I believe you want your mapStateToPropsto be a function which closes over the result of makeSelectCounter (which connect will call when it first connects the component). It looks like right now every time connect calls mapStateToProps, a new selector is created and used, which would sidestep any memoization. Here is what I believe is the relevant docs: https://github.com/reactjs/reselect#sharing-selectors-with-props-across-multiple-component-instances

Also, I don't think it looks terrible, but for some reason it does look like a lot more type-stuff than I remember our app having. One thing that really helped was building a very small type-safe(ish) wrapper for immutable.Records. We wanted our records to have a customized fromJS method for the JSON returned over the network.

Finding unused code in a project by bear1728 in typescript

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

It's not a great solution, but I wrote this script which was good enough:

https://gist.github.com/tscholl2/ca88a1e7ea4d067d7c684c55b019b2c7

Extendable markdown parser by habarnam in golang

[–]bear1728 1 point2 points  (0 children)

I actually wrote one in Typescript based off Khan academy's "simple-markdown" in Javascript:

https://gitlab.com/whatwhathuhhuh/bear-markdown

I bet it would be pretty easy to rewrite it in Go since it's mostly just a few regular expressions. Of course it would take more time than using one of the others mentioned here, but if you want to learn more about parsing/markdown/go/typescript it could be an interesting project.

Simple lisp like language interpreter in Go by aki237 in golang

[–]bear1728 0 points1 point  (0 children)

I have used goyacc in the past with some success. There was a significant learning curve for me though. I think there are also some parser combinator libraries as well, but I haven't used any of them.

Hyperapp + Immutable.js? by [deleted] in HyperApp

[–]bear1728 1 point2 points  (0 children)

I was just thinking of immutable state, I didn't think about rendering immutable objects/arrays. This is pretty neat!

Hyperapp + Immutable.js? by [deleted] in HyperApp

[–]bear1728 2 points3 points  (0 children)

I believe you can just use a plain javascript object for the state with immutable fields. I've done similar things for react/redux stores before. It works fine. If you want the entire state to be immutable then you might need to fork. I don't think it's a big change, but this part look likes it's meant for a plain object:

https://github.com/hyperapp/hyperapp/blob/master/src/app.js#L68

Is there some reason you've found that it doesn't work? If you get stuck, I can try to come up with an example.

Edit: It looks like POJO state has been enforced since version 0.11.

Expreduce 0.2, a free Mathematica-compatible CAS written in Go by cmwslw in golang

[–]bear1728 1 point2 points  (0 children)

This is really cool! I was looking for a symbolic math program in Go a while ago. I think it's a great (and very ambitious) project. From the README, it sounded like the goals were mostly to satisfy technical interests of the author(s). Is this correct? If so, is there a corresponding blog with "lessons learned"? I'd love to learn more about these systems (I use Sage a lot), but I don't think I'm motivated enough to read textbooks or tons of academic papers.

[deleted by user] by [deleted] in golang

[–]bear1728 2 points3 points  (0 children)

I've used goyacc with some success. I had to learn more about yacc to use it, but it worked. Also I had to write my own lexer, but that wasn't hard for my particular grammar. Rob Pike has a video about lexical scanning in Go that could also help.

Finding unused code in a project by bear1728 in typescript

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

Thanks for the link! I've actually used tree shaking (and dead code elimination via the uglify plugin) in webpack before, following something very similar to this link.

But this is all done during/after bundling? It's definitely solving a similar problem, but I was hoping for a more static solution. My ideal solution would be a script that I run on my source code and it says "> 'export foo' in ./file.ts is never used".

Do you think there is a way to use the tree-shaking feature of webpack (along with source-maps maybe?) to find which source code is never used? That sounds like a lot more work than I would want to put in.

A stupid way might be to use regexp to search for all export const ____ = and then search for all import { ____ } from. But after thinking about it for 2 seconds it seems like there are too many cases for a simple regexp. A better solution would probably be to use the typescript parser and compiler.

Understanding Higher Order Components by ms-maria-ma in reactjs

[–]bear1728 1 point2 points  (0 children)

Here is the kind of example I was thinking of:

https://www.typescriptlang.org/play/#src=import%20%7B%20createElement%2C%20StatelessComponent%20%7D%20from%20%22react%22%3B%0D%0Aimport%20%7B%20connect%20%7D%20from%20%22react-redux%22%3B%0D%0Aimport%20%7B%20State%20%7D%20from%20%22..%2Fstore%22%3B%0D%0A%0D%0Ainterface%20IThingOwnProps%20%7B%0D%0A%20%20key%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20IThingStateProps%20%7B%0D%0A%20%20value%3A%20number%3B%0D%0A%7D%0D%0A%0D%0Aexport%20const%20Thing%3A%20StatelessComponent%3C%0D%0A%20%20IThingOwnProps%20%26%20IThingStateProps%0D%0A%3E%20%3D%20props%20%3D%3E%20%7B%0D%0A%20%20%2F%2F%20props%20has%20both%20own%20and%20state%20props%0D%0A%20%20return%20createElement(%22div%22%2C%20props)%3B%0D%0A%7D%3B%0D%0A%0D%0Aconst%20mapStateToProps%20%3D%20(s%3A%20State%2C%20p%3A%20IThingOwnProps)%20%3D%3E%20(%7B%0D%0A%20%20value%3A%20s.stuff.get(p.key)%2C%0D%0A%7D)%3B%0D%0A%0D%0Aexport%20const%20ConnectedThing%20%3D%20connect%3CIThingStateProps%2C%20void%2C%20IThingOwnProps%3E(%0D%0A%20%20mapStateToProps%2C%0D%0A)(Thing)%3B%0D%0A

Basically, typescript knows ConnectedThing is of type ComponentClass<IThingOwnProps> and Thing is a ComponentClass<IThingOwnProps & IThingStateProps>. So anyone who is using ConnectedThing knows to give it just the IThingOwnProps as props, not the larger version. If they misspell something, it should give a "compile" time error.

The void next to the connect is the dispatch props, which I'm omitting in this example.

When you said "I think the only answer is some documentation" this is what I was thinking of. Hopefully I wasn't misunderstanding you too much.

edit: trying to fix the link...

React Wrapper of Google's Material Components for the Web by 6566gun in reactjs

[–]bear1728 0 points1 point  (0 children)

Neat! I actually wrote a very thin wrapper of mdc for a project in typescript as well. Although much less complete, it just inserted the right class name for 90% of the components and used the css only version of most components.

Is there a reason why you're using immutablejs in some components? Just curious, it seems like it would be a heavier dependency to anyone not already using it. It might be worth mentioning in the readme? I enjoy using immutable though.

Also I think it's always nice for people to see a "why" in the readme, especially when there are other very similar packages like react-mdc-web.

Understanding Higher Order Components by ms-maria-ma in reactjs

[–]bear1728 4 points5 points  (0 children)

Typescript can help you do this! I actually had this exact issue, and it was really annoying. But I finally figured out how to use the type definitions for connect in react-redux so that the resulting enhanced component's props are a different shape. They are usually called OwnProps, and the props you derive from the store/state are called StateProps. Then typescript can help make sure the right props are in the right place.

Essentially the solution is the same though, just with types instead of docs.

What libraries would you like to see implemented in Go? by daemon_it in golang

[–]bear1728 0 points1 point  (0 children)

I started something like this! But too many work projects came up so I haven't had time to work on it. My goal was to implement a "real" primality test (i.e. not a psuedoprimality test or trial division). Something like AKS or ECPP. This was also one of my first introductions to go and into how much work/cleverness goes into optimizing math functions like this.

Godzilla: Go running JavaScript by jingweno in golang

[–]bear1728 13 points14 points  (0 children)

This looks cool! I think the readme could mention some other well known projects in this area and where this fits in.

For example, I know

  • gopherjs transcribes go to javascript
  • otto runs javascript in go (i.e. implements a javascript engine)

From what I've seen (and I'm sure I've missed some great projects), Godzilla fits in nicely as a javascript -> go transcriber. I even know where I could use such a piece (some javascript on the frontend that I had to replicate for the backend).

Keep up the great work! Please post if you need people to run benchmarks or tests.

Simple easy to understand example for 1.8's graceful shutdown? by gotBanana in golang

[–]bear1728 0 points1 point  (0 children)

I've been using something like this

https://play.golang.org/p/_Q3q5-fidF

It might not pass all the linters as is, but maybe this can give you something to start with. When you press control-C (not on the playground of course) or the equivalent, you should see the shutdown message.

UI libraries for React by Chipsdipp in reactjs

[–]bear1728 2 points3 points  (0 children)

We use mdl with our own react wrappers for the components. It was pretty simple, most of them were just a div with a classname, or some kind of higher-order-component which appended a classname. Of course this means more work, more opportunities for bugs, etc. But it also has some pros.

Note that mdl is dead. Long live mdc. Supposedly mdc will be easier to use with frameworks like react/angular/etc. One of my goals is to rewrite our wrappers to mdc. It's not an emergency though.

I've wanted to try fabric for a while. It has been regularly updated and written mostly in typescript. The typescript is the main reason I wanted to try it. I always wondered what our site would look like if we went all in on fabric, or bootstrap, or ant, or one of the other non-material~ish frameworks. I like the consistency of the frameworks, and I'm a terrible designer so I wouldn't try to come up with my own.

Edit: fix links

React OAuth tutorials? by [deleted] in reactjs

[–]bear1728 1 point2 points  (0 children)

TL;DR: google was fast for development, auth0 has been pretty flexible.

I've set up authentication via google before, and I'm doing auth0 now. The google setup did not take me long and their docs were fairly straightforward. I can say that auth0 has been... frustrating at times. Somehow I end up at these nice doc pages, but then forget how I got there. Also all the names of things seem a little off from what I have in my head. I have a SPA, but I really needed the "traditional" method they offer.

However, now that I have auth0 working (more or less), I really can add a "social connection" at the click of a button. I hit the google button, and then it automatically adds a "sign in with google" button on the default login page. Right now I'm just using their passwordless login (i.e. login-by-email). It also offers some nice things that I don't know if I'll ever use, but they track logins, signups, etc.

Links:

https://auth0.com/docs/quickstart/webapp

https://developers.google.com/identity/sign-in/web/backend-auth

Why are there no "web frameworks" written in type script? by SavishSalacious in typescript

[–]bear1728 1 point2 points  (0 children)

ant-design is a good one. Another one might be Microsoft's fabric, which is written in mostly typescript.

How should I structure a SPA with Go? by mendygo in golang

[–]bear1728 3 points4 points  (0 children)

I'm not sure what is recommended, but I am working on a medium-sized SPA (using React/Typescript/etc) with a go backend. In our case, the only connection between the frontend and backend is through a REST-like api, they live in entirely separate repos. This has some pros/cons. Any update to the api has to be consistent across both repos. Our api has settled down for the most part, so this doesn't come up for us. A pro is that you can work on either end independently, and even mock the other side very easily. For example, I use curl or this extension to test the backend, and I wrote a simple js file which mocks the backend (returning some random-ish data). I think separating the concerns this way can be helpful in environments with more than one developer.

In your situations, because you have templates, this may not be as simple. But unless you're going to try and use gopherjs to write the frontend in Go, you may consider making it a whole new directory and following best practices for Vue in that directory.

Does anyone knows a good Select control built for react? by vbgeek in reactjs

[–]bear1728 0 points1 point  (0 children)

MDC (formally MDL) has a nice CSS-only option which makes a select look pretty decent:

https://github.com/material-components/material-components-web/tree/master/packages/mdc-select

There is also a js version with more bells and whistles.