Skip to content

Instantly share code, notes, and snippets.

Avatar

pietro909 pietro909

View GitHub Profile
View en.json
{
"Home": "Home",
"Matches": "Matches",
"Sign up": "Sign up",
"My Bets": "My Bets",
"Account": "Account",
"More": "More",
"Welcome back!": "Welcome back!",
"No results": "No results",
"We sent you a code": "We sent you a code",
@pietro909
pietro909 / elm-compile-benchmark.md
Last active Mar 29, 2019
Elm 0.18 vs 0.19 - compile time
View elm-compile-benchmark.md

Elm 0.18 with debug

$ time ./node_modules/.bin/elm-make src/Main.elm --output dist/index.js --debug Success! Compiled 219 modules. Successfully generated dist/index.js ./node_modules/.bin/elm-make src/Main.elm --output dist/index.js --debug 173.55s user 40.82s system 160% cpu 2:13.39 total

@pietro909
pietro909 / nested-navigator-example.js
Created Jun 18, 2017
React Native: nested Navigator example
View nested-navigator-example.js
import React from "react";
import {
NavigationActions,
StackNavigator,
TabNavigator,
} from "react-navigation";
/* ...import pages... */
export const Welcome =
@pietro909
pietro909 / index.html
Created Apr 13, 2017
JS Bin Convert JSON to valid Elm data structure (record) // source http://jsbin.com/duneqo
View index.html
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Convert JSON to valid Elm data structure (record)">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script>
View fonts-meg.css
@font-face {
font-family: 'Futura-BT-normal';
src: url( 'http://www.magdaazab.it/assets/fonts/futura/futura_book_bt/FUTURAN.TTF' );
}
@font-face {
font-family: 'Futura-BT-bold';
src: url( 'http://www.magdaazab.it/assets/fonts/futura/futura_heavy_bt/FUTURAH.TTF' );
}
@pietro909
pietro909 / flatten.js
Created Feb 7, 2017
A recursive flatten function for arbitrary nested arrays. Stack is the limit :-)
View flatten.js
/**
* Flatten arbitrary nested arrays.
*
* @arg the array to flatten
* @return array with depth 1, empty array for non-arrays
*/
const flatten = (arrayOfArrays = []) => {
if (arrayOfArrays.length === 0) {
return []
}
View a-simple-name.elm
import Html exposing (beginnerProgram, div, input, text)
import Html.Events exposing (onInput)
main =
beginnerProgram
{ model =
{ name = ""
}
, view = view
@pietro909
pietro909 / kata.scala
Last active Jan 3, 2017 — forked from anonymous/kata.scala
Functional Programming in Scala - Chapter 2
View kata.scala
import com.scalakata._
@instrument class Playground {
// help
def isSorted[A](as: Array[A], ordered: (A, A) => Boolean): Boolean = {
def go(n: Int): Boolean =
if (n >= as.length-1) true
else if (!ordered(as(n), as(n+1))) false
else go(n+1)
@pietro909
pietro909 / runtime-error-elm.elm
Created Oct 28, 2016
Trying to reproduce runtime error conditions
View runtime-error-elm.elm
import Html exposing (text, div)
import String
import List
contains c s =
-- we should use String.contains
(List.length (String.indexes c s)) > 0
main =
div []
@pietro909
pietro909 / defensive-approach-javascript.js
Last active Oct 28, 2016
Example of how to handle unknown input
View defensive-approach-javascript.js
function contains(c, s) {
var index = typeof s === 'string' ? s.indexOf(c) : -1;
return index > -1;
}
console.log(contains("hi", "there")); // false
console.log(contains("hi", "hi, all")); // true
console.log(contains("hi", 1)); // false
console.log(contains("hi", null)); // false