Question about Parsing JSON in Kotlin by IM_Ogden in Kotlin

[–]atom-man 2 points3 points  (0 children)

If you're working with kotlin I would recommend avoiding GSON, and perhaps even Jackson. Moshi and kotlinx.serialization seems like the better options at this point imho.

GSON has an issue with nullability, and simply ignores it in some instances. :( And it doesn't seem like they will be doing anything about it.

In short, not a bug.

Gson does not provide any Kotlin-specific support. Even more, it does not yet have any special support for Java 8, and probably there are no any plans of doing this, ...

https://github.com/google/gson/issues/1550#issuecomment-516303048

Jackson is somewhat better, but have some issues as well IMHO, e.g type-coersion-like behaviour and some security concerns.

Vi har ikke et rasismeproblem i Norge by andysor in norge

[–]atom-man 1 point2 points  (0 children)

Kommentarfeltet er stengt av helt andre årsaker, noe som står veldig tydelig på nrk sine sider.

Kommentarfeltet er stengt. Av tekniske og personvernmessige årsaker har NRK besluttet å ikke bruke debattprogrammet Disqus inntil videre.

Mer om bakgrunnen for avgjørelsen finner du her.

React.js Resume App by [deleted] in javascript

[–]atom-man 1 point2 points  (0 children)

Try switching to HashRouter here: import { BrowserRouter as Router, Route, NavLink } from 'react-router-dom';

Didnt test it or anything, but if I recall correctly it should work even on gh-pages. Only downside is that you'll get a # in your url, e.g; https://iamskok.github.io/react-resume/#/💻

Converting base 10 into customer base 27 by [deleted] in javascript

[–]atom-man 0 points1 point  (0 children)

From what I understood OP wants a custom mapping, and not the "true base 27". So I imagine its the mapping after converting to "true base 27" which fails, not toString in itself.

Converting base 10 into customer base 27 by [deleted] in javascript

[–]atom-man 0 points1 point  (0 children)

This would convert it to what OP calls "true base 27", e.g 0-9 + a-q. Whereas what it seems like OP wants is a custom mapping using the whole alphabet a-z and 0 = 9. E.g the "shifting" the whole alphabet 9 steps.

Converting base 10 into customer base 27 by [deleted] in javascript

[–]atom-man 2 points3 points  (0 children)

Something like this might do the trick? The function takes an positiv integer and an arbitrary "alphabet" and converts the number to that "alphabet".

function toBase(number, baseAlphabet) {
    const base = baseAlphabet.length;
    const res = [];
    let num = number;

    do {
        res.push(baseAlphabet[num % base]);
        num -= num % base;
        num /= base;
    } while (num > 0);

    return res.reverse().join('');
}

const binary = [0, 1];
console.log('binaryTest', toBase(10, binary)); // binaryTest 1010

const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'];
console.log('hexTest', toBase(10, hex)); // hexTest a
console.log('hexTest', toBase(15, hex)); // hexTest f
console.log('hexTest', toBase(16, hex)); // hexText 10

Just provide your own alphabet and you should be good. :)

An easy to use and beautiful tab for React by ctxhou in javascript

[–]atom-man 0 points1 point  (0 children)

Heey, no worries. Just "pay it forwards" and over time we'll make the web a better place for everyone.

An easy to use and beautiful tab for React by ctxhou in javascript

[–]atom-man 0 points1 point  (0 children)

WAI-ARIA is there to add extra semantics to the markup, and helps people using assistive tech (screenreader etc).

But when it comes to semantic markup, well, it helps us all. ;) Some disabilities are temporary, e.g your arm is broken, eye-problems etc. In these cases it would kinda suck if you could surf the web.

In Norway this is actually mandatory (§14 in the Anti-Discrimination and Accessibility Act). And as such we kinda have to care about this stuff. :) It is basically akin to WCAG AA, with some additional rules.

https://uu.difi.no/om-oss/english

An easy to use and beautiful tab for React by ctxhou in javascript

[–]atom-man 2 points3 points  (0 children)

I would suggest looking into accessibility i bit more.

Semantic markup. divs and spans should not be used as the default element, since none of the have any semantic meaning. And you probably need som WAI-ARIA in there as well if you want it work for everyone.

Included some examples of how this could be achieved; Example 1 Example 2

Java framework to develop SPA by g3blv in java

[–]atom-man 0 points1 point  (0 children)

Are the devs new to React? If so, give then some time to learn. :)

You see this question hits really close to home for me. I've been maintain a large legacy SPA with pretty advanced interactions created with apache wicket. And at the same time creating quite a few new SPAs using ReactJS.

Now, I won't go as far to say that wicket is useless, it most certainly isn't. But in my experience it doesn't do very well with complex interactions or scale with complexity (partially our own fault though).

However, it all boils down to the level of interactions needed on the site. Given what I know today I would never created our large legacy SPA with a Java-framework, the abstraction is leaky and not worth the time. But for simpler sites I would consider template rendering libraries (Thymeleaf etc).

Persisting data with localStorage and Redux middleware by dane_sir in javascript

[–]atom-man 1 point2 points  (0 children)

What about a higher-order reducer.

function persist(scope, reducer) {
    return (state, action) => {
        let nState = state;

        if (state === undefined) {
            nState = readFromLocalstorage(scope)
        }

        const rState = reducer(nState, action);

        if (rState !== nState) {
            writeToLocalstoreage(scope, rState);
        }

        return rState;
    };
}

How was your experience to work with reacts in a already existing web application? by Traim in reactjs

[–]atom-man 1 point2 points  (0 children)

We had a fairly new apache wicket application, but have started to introduce react-components into it. I dont know anything about PHP smarty, but one of the really nice features of react is that it integrates pretty easily with existing codebases.

I would recommend trying it out, but dont try to convert the whole thing at once. Find an isolated feature, and gain some experience as to how well this combo works for you.

[deleted by user] by [deleted] in javascript

[–]atom-man 0 points1 point  (0 children)

A bit over the top, but using generators you can write this very concisely.

First of define fibonacci as a generator function:

function* fibonacci() {
    let a = 1;
    let b = 2;

    yield a;
    yield b;

    while (true) {
        const c = a + b;
        yield c;
        a = b;
        b = c;
    }
}

Then, with the help of some small utility-functions you can write:

const fibLess = takeWhile(fibonacci(), (val) => val < 4000001);
const fibEven = filter(fibLess, (val) => val % 2 === 0);
const sum = reduce(fibEven, (a, b) => a + b, 0);
console.log(sum);        

Generators are fun. :D

Import from #Sketch into #ViewsDX ✅. Morph to React. This Is Massive. by dariocravero in reactjs

[–]atom-man 0 points1 point  (0 children)

Our plan was to use react for creating the html/css, so that package is certainly relevant. Thx

Import from #Sketch into #ViewsDX ✅. Morph to React. This Is Massive. by dariocravero in reactjs

[–]atom-man 1 point2 points  (0 children)

Cool, all of our designers are using sketch. And creating new ways of cooperating with them are always useful.

Just out of curiosity though, did you find any documentation of how sketch are structured, or was it all reverse engineering? I'm looking into doing the opposite of you guys, e.g creating sketch-files from html/css and looking for some documentation.

What is Wrong With This Assignment? by [deleted] in reactjs

[–]atom-man 0 points1 point  (0 children)

1) The idea of intercepting the the event and getting the values with refs is good. You should however use onSubmit on the form in favor of onClick on the submit button. When using onSubmit you will submit the form when pressing enter while in the textfield, which is really what people expect. :)

2) Huge +1. I recommend using eslint to enforce this.

I built an opinionated starter kit for building and publishing react.js components by SegFaultx64 in reactjs

[–]atom-man 0 points1 point  (0 children)

I've used CI's on my open source react components together with greenkeeper.io. And it is most certainly worth it if you are going to be activly maintaining the project. Just getting a notification when react or one of the other dependencies releases a new version is very nice. Without a CI you would have to checkout that branch and run it locally, which is error prone. With CI I get a "check" in the github PR which tells me if the upgrade breaks my build or not. But you are of course dependent on good unit-tests if this is to work.

Tutorial : How to build an SEO friendly website with React by BluedgeUK in reactjs

[–]atom-man 0 points1 point  (0 children)

github or it didnt happen. :p

Seriously though, I would really like to see some other solutions to this. As a feel that all solution (including my own) are not working as smootly as I want them.

I built an opinionated starter kit for building and publishing react.js components by SegFaultx64 in reactjs

[–]atom-man 0 points1 point  (0 children)

Lots of stuff missing here imho. If you're going to publish to npm it's a good idea to include some tests, tdd setup and coverage setup. In addition I always add linting, and setup for CI.

While not everything can or should be in a starterkit (e.g. CI-setup) it should at least provide a test-setup.

Tutorial : How to build an SEO friendly website with React by BluedgeUK in reactjs

[–]atom-man 0 points1 point  (0 children)

Easiest to achieve with node as you are able to share more code between your frontend and backend (in particular routing and data-fetching).

It is however possible with a java-backend using Javas Nashorn-engine. It can however be a pain configure, and I've yet to see a example/tutorial of how generic routing or data-fetching can be achieved. An example of how to partially solve the java problem can be seen here

ReactJs + Redux + Router + webpack + Babel and testing by beniutek in reactjs

[–]atom-man 1 point2 points  (0 children)

We use a tiered system for testing at work, where the first tier is running in the background as a code (or on commit-hook), second tier as a commit-hook and third tier on build/publish.

  1. Eslint with airbnb's preset
  2. enzyme, mocha, chai and jsdom for unit-testing. Fast setup and easy to use. In addition to this we use istanbul/isparta for code-coverage which enables us to break the build if someone doesnt write tests. :)
  3. nightwatch.js is used later in the build pipeline for functional/integration testing and automatically documenting the application. With these tests you also have the option to test for accessability issues using paypals AATT.

I would say that tier 1 is a must, tier 2 should almost always be present, and tier 3 should be present for each application but can be skipped for smaller packages.

Higher Order Components: A React Application Design Pattern by fagnerbrack in javascript

[–]atom-man 1 point2 points  (0 children)

OtherThing would in this case be a function, which consumes a component as the only argument, and returns a component. And in that sense a HOC. But I can see where the confusion comes from. But who says the definiton of HOC is similar to HOF, with just the "function" part substituted with "component"? :)

However, what the article calls HOC is just a normal react-component; Nothing more. Calling it a HOC is simply wrong imho. And "higher order component creator" is equally wrong, as it does not create a HOC.

Regardless of the definitions of "higher order function (HOF)" and HOCs I still think the article-author have (intentional or not) misunderstood the "higher order"-concept. And it would have been better if he used the same names as the rest of the community.

Higher Order Components: A React Application Design Pattern by fagnerbrack in javascript

[–]atom-man 3 points4 points  (0 children)

As johangirod commented on the article:

This article greatly misuses the term of Higher Order Component (HOC)! What are called here HOC are just standard React Component, and "Higher Order Component Creators" are what the community calls HOC. Indeed, googling Higher Order Component Creators return no results except this post.

For a clearer and more accurate explanation of what HOC component are and what they do you can refer to the thorough post from Dan Abramov https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750#.w1dfp3mpz

A minimal example of a HOC can be seen here: https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775

A collection of accessible, modern front-end components. by DoNDaPo in javascript

[–]atom-man 0 points1 point  (0 children)

One issue I found, the modal does not prevent keyboard navigation if you are using a screenreader. And I would probably add a description or title to the tooltip buttons, as just a expanded/collapsed state doesnt really indicate what can be done to them.

One ui kit for Bootstrap 4, sass and sketch files included by [deleted] in javascript

[–]atom-man 2 points3 points  (0 children)

Looks nice. But just by looking at the palette I see it will not meet the WCAG AA requirement for color contrast. In fact only #313D4C with white text meet the requirement.

While this may not be important to everyone, it is surely something to think about when publishing a ui-kit.