Skip to content

Instantly share code, notes, and snippets.

View ultrox's full-sized avatar
🏠
Working from home

Marko Vujanic ultrox

🏠
Working from home
View GitHub Profile
@ultrox
ultrox / ExpectJson.elm
Last active August 9, 2023 22:29
How expectJson function works in Elm
{-
I got frustrated about how Http.get works, so I expanded all the function in Elm core to get to the bottom of line
-}
expectJson : (Result Error a -> msg) -> Decode.Decoder a -> Expect msg
expectJson toMsg decoder =
let
decodingResult string =
case (Decode.decodeString decoder string) of
Ok v ->
Ok v
@ultrox
ultrox / Main.elm
Last active August 9, 2023 20:32
Elm 0.19.1 + RemoteData. How to use RemoteDetails talk from Kris Jenkins - Slaying a UI antypattern
module Main exposing (..)
-- This code needs following dependencies:
-- elm/browser 1.0.2
-- elm/html 1.0.0
-- elm/http 2.0.0
-- elm/json 1.1.3
-- elm/random 1.0.0
-- krisajenkins/remotedata 6.0.1
-- NoRedInk/elm-json-decode-pipeline/ 1.0.1
-- Can try it here: https://ellie-app.com/nBCdHpv2jRta1
@ultrox
ultrox / Main.elm
Created July 29, 2023 09:11 — forked from s-m-i-t-a/Main.elm
How to update nested fields in record
module Main exposing (..)
type alias Bar =
{ baz : String }
type alias Foo =
{ bar : Bar }
@ultrox
ultrox / work.md
Last active July 27, 2023 12:33
Some of the work
import { createFactory, Component } from 'react'
export const withContext = (childContextTypes, getChildContext) => BaseComponent => {
const factory = createFactory(BaseComponent)
class WithContext extends Component {
getChildContext = () => getChildContext(this.props)
render() {
return factory(this.props)
}
@ultrox
ultrox / download-roc.md
Last active October 1, 2022 16:15
Download Latest Roc

Roc installation guide for x86 Linux systems

How to install Roc

Note: In order to develop in Roc, you need to install the Roc CLI, which includes the Roc compiler and various helpful utilities.

  1. Download Latest nightly Roc (find assets here)

Or use jq and curl for seamless copy/paste

@ultrox
ultrox / download-roc.sh
Created September 23, 2022 22:34
Download Latest Roc
curl -s https://api.github.com/repos/roc-lang/roc/releases|jq -r '.[0].assets [0].browser_download_url'|xargs -n1 -I % curl -L % --output roc_nightly.tar.gz
@ultrox
ultrox / tmux_italic.md
Created September 6, 2022 22:40 — forked from gyribeiro/tmux_italic.md
enable italic font on tmux
@ultrox
ultrox / promises_answer_sheet.md
Created July 26, 2022 08:02 — forked from nolanlawson/promises_answer_sheet.md
Promises puzzle cheat sheet
@ultrox
ultrox / useMemoUseCallback.js
Last active August 16, 2024 23:08
This is implementation of useMemo and useCallback directly from facebook/react, with some flow types removed and minor code changes.
/*type Hook = {|
memoizedState: any,
queue: UpdateQueue < any > | null,
next: Hook | null,
|};
*/
// Whether the work-in-progress hook is a re-rendered hook
let numberOfReRenders/*: number */= 0;
let isReRender/*: boolean */= false;
let firstWorkInProgressHook /*Hook | null */= null;