Skip to content

Instantly share code, notes, and snippets.

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

Flavio Corpa kutyel

🌊
数学者に俺は成る!
View GitHub Profile
@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') }
module GoogleChart exposing (..)
import Html exposing (Html)
import Html.Attributes as HtmlA
import Json.Encode as E
import List.Extra as List
import Chart exposing (..)
colors =
@kutyel
kutyel / .babelrc
Created August 7, 2019 10:23
Personal JS options 😉🚀
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 2 versions",
"ie >= 11"
function sum(a, b) {
// Aquí puede haber comentarios importantes...
// ...sobre todo para gente que hace librerías, etc...
return a + b;
}
// En la primera versión de la especificación...
sum.toString() // > "function sum() { return a + b }"
Symbol('react').description // > "react"
Symbol.iterator.description // > "Symbol.iterator"
Symbol.for('preact').description // > "preact"