Skip to content

Instantly share code, notes, and snippets.

View haikyuu's full-sized avatar

Abdellah haikyuu

View GitHub Profile
@busypeoples
busypeoples / Simplified-Redux-Reducers.js
Created January 2, 2018 23:21
Simplified Redux Reducers
import Maybe from 'folktale/maybe';
const Inc = 'Inc';
const Dec = 'Dec';
const IncBy = 'IncBy';
const IncFn = state => state + 1;
const DecFn = state => state - 1;
const IncByFn = (state, action) => state + action.incBy;
@evancz
evancz / data-interchange.md
Last active April 29, 2024 16:53
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@threepointone
threepointone / deep-string.js
Last active March 13, 2019 20:09
deep update of text in a react component
import React from 'react'
import { render } from 'react-dom'
// with fiber, we'll be able to write components that update text deep
// inside another string without wrapper dom, or rerendering the whole component
// before
class Lorem extends React.Component {
state = {
str: ''
@timdorr
timdorr / MainApplication.java
Created February 11, 2017 14:36
Tesla App is now React Native!
package com.teslamotors.TeslaApp;
import android.app.Application;
import com.BaiduMaps.BaiduPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
function increment(props, state) {
return {
value: state.value + props.step,
};
}
function decrement(props, state) {
return {
value: state.value - props.step,
};
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

You’ll hear this talk at Elm Europe in June 2017. Massive thanks to @chrisui, @stealthpig, @zsoobhan, @spryle, @dumbNickname and everyone else who helped shape this proposal. You guys are awesome!

 

how frontend microservices
help us stay flexible

Choosing the right technologies when starting a project is super important. It’s almost impossible to change the stack later on. Betting on Elm is therefore a bit risky. Right?

Not anymore! Now we can use frontend microservices to pick the right tool for every job!

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@tonysneed
tonysneed / vs-code-ts-version.md
Created October 23, 2016 07:09
Use Specific Version of TypeScript with VS Code

NOTE: These steps are only required if you want to use a version of TypeScript that is not the same as the version that is bundled with Visual Studio Code.

  • Install the latest version of TypeScript

    npm install -g typescript@version
    
  • Configure VS Code to use installed version of TypeScript by opening Preferences, User Settings.