Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
数学者に俺わ成る!

Flavio Corpa kutyel

🌊
数学者に俺わ成る!
View GitHub Profile
View snapview.elm
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 Oct 9, 2020 — forked from robrix/Optics.hs
Optics via fused-effects
View Optics.hs
{-# 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 Sep 1, 2020
Quick and dirty morse decoder in Haskell
View Morse.hs
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 Apr 15, 2020
Google Calendar Chart Web Component in Elm https://ellie-app.com/8B8tftGqV6Da1
View Main.elm
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 Apr 13, 2020
Translator to mi mi mi in Elm! ~20 mins.
View Mimimi.elm
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 Mar 18, 2020
Elm 0.19.1 GraphQL Star Wars Example!
View StarWars.elm
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 Feb 26, 2020
Format all Cabal files in a Haskell project
View cabal-fmt.sh
find . -name '*.cabal' -exec sh -c 'cabal-fmt $0 > output.tmp; mv output.tmp $0' {} ';'
View default.nix
{ 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 Dec 3, 2019
If there was no Conduit.mapM
View conduit.hs
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 Sep 19, 2019
i18n with React Hooks, no external libraries!
View i18n.js
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') }