Skip to content

Instantly share code, notes, and snippets.

View ThomasCrevoisier's full-sized avatar

Thomas Crevoisier ThomasCrevoisier

View GitHub Profile
@ThomasCrevoisier
ThomasCrevoisier / npm_scripts.md
Last active October 27, 2016 08:34
Some thoughts about NPM scripts

Let's have some fun with NPM scripts

Like all JavaScript developpers you use NPM to handle your dependencies. Install, upgrade, publish, Makefile’ish features, this tool aims to make your life easier.

I'd like to show you in this post some fun stuff you can do with NPM scripts.

A quick recap on NPM scripts

What are NPM scripts, you wonder ?

{
"env": {
"es6": true
},
"parserOptions: {
"ecmaVersion": 6,
"sourceType": "module"
}
}
app.model({
state: { title: 'hep' },
reducers: {
update: (data, state) => {
console.log(data);
return { title: 'hey' };
}
},
effects: {
// In a file main.scss
@import 'plop';
@import 'hey';
// module _plop.scss
@mixin plop {
background: red;
}
// module _hey.scss
module Yolo where
combinaisons :: [Int] -> [[Int]]
combinaisons [] = []
combinaisons [x] = [[x]]
combinaisons [x, y] = [[x, y], [y, x]]
-- use fold
combinaisons arr = concat $ map (\y -> subcombinaisons y arr) arr
where
without e = filter (/= e)
@ThomasCrevoisier
ThomasCrevoisier / elm-events.elm
Created December 6, 2015 21:37 — forked from aymanosman/elm-events.elm
Demonstrate custom event capture in Elm
import Dict exposing (Dict)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
import Debug exposing (log)
import Json.Decode as Json
import Signal exposing (Address)
import StartApp.Simple
import Json.Decode as Json
@ThomasCrevoisier
ThomasCrevoisier / live-coding.js
Created September 28, 2015 11:57
String evaluation on ctrl+enter
var keypressed = Bacon.fromEvent(document.getElementById('text-editor'), 'keypress');
var evaluatedString = keypressed
.filter(function (event) { return event.ctrlKey && event.charCode === 10; })
.map(function (event) { return getSelection(event.target.value, event.target.selectionStart, event.target.selectionEnd); })
.filter(function (value) { return !!value.trim(); }).log();
fibs2 :: [Integer]
fibs2 = 1 : 1 : zipWith (\a b -> a + b) fibs2 (tail fibs2)
@ThomasCrevoisier
ThomasCrevoisier / HW04.hs
Created May 7, 2015 08:40
CIS194 - HW04
{-# OPTIONS_GHC -Wall #-}
module HW04 where
newtype Poly a = P [a]
-- Exercise 1 -----------------------------------------
x :: Num a => Poly a
x = P [0, 1]
{- Non-working version -}
foreign import mapHRecLabel
"function mapHRecLabel(f, rec) {\
\ var mapped = {};\
\ for (var k in rec) {\
\ if (rec.hasOwnProperty(k)) {\
\ mapped[k] = f(k, rec[k]);\
\ }\
\ }\
\ return mapped;\