Skip to content

Instantly share code, notes, and snippets.

View kutyel's full-sized avatar
🌊
数学者に俺は成る!

Flavio Corpa kutyel

🌊
数学者に俺は成る!
View GitHub Profile
port module Main exposing (main)
import Browser
import Html exposing (Html, button, canvas, div, h1, h3, p, text)
import Html.Attributes exposing (class, height, id, width)
import Html.Events exposing (onClick)
port subscribeToVideoUpdates : () -> Cmd msg
@kutyel
kutyel / Optics.hs
Created October 9, 2020 22:19 — forked from robrix/Optics.hs
Optics via fused-effects
{-# LANGUAGE RankNTypes #-}
module Optics where
import Control.Category ((>>>))
import qualified Control.Category as Cat
import Control.Effect.Empty
import Control.Effect.NonDet hiding (empty)
import Control.Monad ((<=<))
-- riffing off of @serras’s post https://gist.github.com/serras/5152ec18ec5223b676cc67cac0e99b70
@kutyel
kutyel / Morse.hs
Last active September 1, 2020 14:25
Quick and dirty morse decoder in Haskell
module Codewars.Kata.DecodeMorse (decodeMorse) where
import Codewars.Kata.DecodeMorse.Preload (morseCodes)
import Data.List.Split (splitOn)
import Data.Map.Strict ((!))
decodeMorse :: String -> String
decodeMorse = unwords . filter (not . null) . map ((>>= (morseCodes!)) . words) . splitOn " "
@kutyel
kutyel / Main.elm
Last active April 15, 2020 08:51
Google Calendar Chart Web Component in Elm https://ellie-app.com/8B8tftGqV6Da1
module Main exposing (main)
import Dict
import Html exposing (Html)
import Html.Attributes exposing (attribute, property)
import Json.Encode as Encode
main : Html msg
main =
Html.node "google-calendar"
[ attribute "type" "calendar"
@kutyel
kutyel / Mimimi.elm
Created April 13, 2020 10:47
Translator to mi mi mi in Elm! ~20 mins.
module Main exposing (..)
import Browser
import Html exposing (Html, div, h1, input, p, text)
import Html.Attributes exposing (placeholder)
import Html.Events exposing (onInput)
import Regex as R
@kutyel
kutyel / StarWars.elm
Created March 18, 2020 10:18
Elm 0.19.1 GraphQL Star Wars Example!
module Main exposing (main)
import Browser
import GraphQL.Client.Http as GraphQLClient
import GraphQL.Request.Builder exposing (..)
import Html exposing (Html, div, text)
import Task exposing (Task)
{-| Responses to `starWarsRequest` are decoded into this type.
@kutyel
kutyel / cabal-fmt.sh
Created February 26, 2020 13:34
Format all Cabal files in a Haskell project
find . -name '*.cabal' -exec sh -c 'cabal-fmt $0 > output.tmp; mv output.tmp $0' {} ';'
{ nixpkgs ? (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.09.tar.gz)
, system ? builtins.currentSystem
}:
let
haskellnix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz);
overlay = _: pkgs:
let
hnPkgs = pkgs.haskell-nix.stackProject {
src = ./.;
@kutyel
kutyel / conduit.hs
Last active December 3, 2019 11:12
If there was no Conduit.mapM
getPersonStream :: ConduitT () PeopleRequest ServerErrorIO ()
-> ConduitT PeopleResponse Void ServerErrorIO ()
-> ServerErrorIO ()
getPersonStream source sink = runConduit $ source .| reStream .| sink
where
reStream = do
req <- await
case req of
Nothing -> return ()
Just r -> do
@kutyel
kutyel / i18n.js
Created September 19, 2019 10:58
i18n with React Hooks, no external libraries!
import React, { useReducer, createContext } from 'react'
import { propOr } from 'ramda'
import en from '../../assets/literals/EN'
import es from '../../assets/literals/ES'
const translations = { en, es }
const getTranslate = lang => key => propOr(key, key, translations[lang])
const initialState = { lang: 'en', t: getTranslate('en') }