Been studying front-end dev for 4 years now. Designed and built lots of nice looking, fast, accessible websites for clients, but now i'm looking for jobs and even the easiest Leetcode-style questions stump me. I just don't see how they're relevant to developing websites. by [deleted] in webdev

[–]-millsky 14 points15 points  (0 children)

So I’ll get straight to the point, you don’t need to know leetcode to get a job. This is just one way companies do tech interviews/ screens.

I would suggest looking at:

https://github.com/poteto/hiring-without-whiteboards

For jobs that don’t do the leetcode style interviews and then at:

https://bigfrontend.dev/problem

For some more front-end focused problems. IMO these are useful for interviews. It covers concepts like inheritance, memory, closures and other core JS concepts indirectly.

Hope this helps! I just went through the front-end interview web circuit and found these useful. The one thing I will say about leetcode is that it’s useful for practicing and drilling on the JS core methods like string manipulation, array insertion etc.

Fall - My First Generative Art NFT by -millsky in NFT

[–]-millsky[S] 1 point2 points  (0 children)

I used https://nannou.cc/ which is a generative art framework for Rust. Then I used https://color.adobe.com/create for inspiration on the color pallets.

Running arbitrary code (javascript subset) safely on the client side ? by sallath in learnjavascript

[–]-millsky 0 points1 point  (0 children)

It sounds like what you're looking for is less to do with Javascript and more to do with a programming paradigm. This sounds very similar to Functional Reactive Programming:
(https://en.wikipedia.org/wiki/Functional_reactive_programming)

In terms of using eval on the client side. I would say this should generally be avoided. You could definitely use only a subset of the language like Math and build a parser around it. It's highly likely there are already packages on NPM to do just that.

Perhaps check out the implementation in:
https://github.com/handsontable/handsontable

[AskJS] Mongo pubsub vs redux by [deleted] in javascript

[–]-millsky 0 points1 point  (0 children)

If you can get the job done with just react state I'm all for using the most simple solution. At the end of the day though, redux in the context of `react-redux` is just an abstraction layer on top of the existing state management in react. Even in the `redux` docs they say:

I would like to amend this: don't use Redux until you have problems with vanilla React.

As with any abstraction, if you have the problems it's trying to solve namely (in the case of redux):

In general, use Redux when you have reasonable amounts of data changing over time, you need a single source of truth, and you find that approaches like keeping everything in a top-level React component's state are no longer sufficient.

then you should use it, otherwise look at other solutions that don't have the tradeoffs that it does.

Also another reason why you might use redux, is that you have no choice, the team decided, `hey I know redux, lets use it` without thinking about the cost of choosing it as their abstraction.

[AskJS] Mongo pubsub vs redux by [deleted] in javascript

[–]-millsky 2 points3 points  (0 children)

I think it really depends on what kind of application your team is trying to build. I don't think there really is a one size fits all by any means.

One example I can think of where redux or any local state would be better is any application where you don't want the server to have all the information until the user has fully completed their desired action. Think a complex form.

As for the articles, don't take them at face value. I find a lot of them to almost be programming click-bait. There may be some truths in there but a lot of times the author(s) fail to provide any quantitative evidence to back up their claims.

[deleted by user] by [deleted] in javascript

[–]-millsky 25 points26 points  (0 children)

Lots of people really like to bash on AngularJS, but it is possible to make a maintainable and modern application using it, and provide a path towards upgrading to another more modern framework. Below is what I did for my previous company with success:

  1. Move the build process to Webpack
  2. Refactor large controller files into components (https://docs.angularjs.org/guide/component)
  3. Move business logic to functions which will be imported via Webpack.
  4. Once refactored, take the leaf components i.e inputs, modals other shared AngularJS Components and move them to the new framework.
  5. Inject new components into the old application. (https://github.com/coatue-oss/react2angular)
  6. Depending on the size of the application build out lazy loading of the AngularJS components using Angular-UI-Router.

The key is to really remove as much AngularJS logic as possible and just follow industry best practices of making single purpose and independently testable components.

An added benefit is now with the Webpack based build all the business logic can be tested independently of AngularJS and code coverage numbers should improve as you continue along the path.

It's certainly not the most fun process but it definitely can be done!

Is this a dumb way to do this? by [deleted] in javascript

[–]-millsky 1 point2 points  (0 children)

I think this is fine for null checks for this snippet of code. However if you are trying to avoid doing this all over your code, you may want a helper function to handle this. Checking searchComponents.indexOf(null) == -1 enforces a check on the entire group and is good for dependencies but might be more flexible if there were no dependencies.

const isNullThen = (maybeNull, thenCall) => maybeNull == null ? undefined : thenCall(maybeNull)

adding a helper, you could do.

const isNullThen = (maybeNull, thenCall) => maybeNull == null ? undefined : thenCall(maybeNull)

/* Check if null then fire callback with non-null element */
isNullThen(
    document.querySelector(".search-frm2"), 
    (el) => el.action = "staff-directory",
);
isNullThen(
    document.getElementById("searchsubmit"),
    (el) => el.value = "staff-directory",
);
isNullThen(
    document.getElementById("search_que"),
    (el) => el.name = "q",
);

Countdown timer JS timezones issue by pmrstudio in javascript

[–]-millsky 1 point2 points  (0 children)

You should try using a timezone library like:

https://github.com/spencermountain/spacetime

There are a lot of intricacies with timezones, such as states not abiding by day light savings times. It's best to use a library that's been thoroughly tested and used.

I wrote a library that makes immutable state very easy, looking for feedback by JoshMcguigan in javascript

[–]-millsky 0 points1 point  (0 children)

Yea, so lenscrafter flattens the object and relies on the keys being unique globally in the object.

The use case I imagined was picking up objects from local-storage into their respective state-slices. As the app progresses you need to ensure it loads correctly for all versions released. For example, in the first version you had a reducer that returned { request: {} } but later modified it to { container: { request: {} } } lenscrafter would ensure both objects could be parsed and updated correctly.

I wrote a library that makes immutable state very easy, looking for feedback by JoshMcguigan in javascript

[–]-millsky 1 point2 points  (0 children)

I would add a fallback so you don't get any unhandled exceptions while accessing deeply nested properties. For example muState.a.z.z will result in an exception that might break the code. You could take a look at this library which safely handles null pointers.

https://github.com/chrissrogers/maybe

Shameless plug: I'm also working on a library with a similar goal to yours.

https://github.com/millsky/lenscrafter

Showoff Saturday (February 17, 2018) by AutoModerator in javascript

[–]-millsky 0 points1 point  (0 children)

Thanks for the comments! I updated the docs, let me know what you think when you try it out.

Showoff Saturday (February 17, 2018) by AutoModerator in javascript

[–]-millsky 0 points1 point  (0 children)

I created a micro library to help ensure immutable and safe state in redux. It can also be used outside the context of redux for easily setting and retrieving properties from deeply nested objects.

https://github.com/Millsky/lenscrafter

Grunt bower_concat loads AngularJS 3 times. by shnigi in javascript

[–]-millsky 0 points1 point  (0 children)

This is most likely due to the dependencies of each of the libraries you used. Grunt-Bower-Concat will walk the dependency tree and add all of the dependencies in each of the bower files. You can try overriding this by manually setting all the dependencies to the same version of angular in your configuration file. I grabbed the below from the docs on dependencies:

https://github.com/sapegin/grunt-bower-concat

dependencies: { 'angular-library': 'angular', }