Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
module Scratch exposing (..)
import String
-- arguments first then return
-- so the arguments are wrapped in braces for disambiguation
-- http://guide.elm-lang.org/types/reading_types.html
@deepak
deepak / general-to-specific-elm-type.elm
Last active September 13, 2016 06:07
moving from Elm's general type to specific type
module Build exposing (..)
import Debug
type alias Foobar number =
{ foo : number, bar : number }
build : number -> number -> { foo : number, bar : number }
@deepak
deepak / Build.elm
Last active September 13, 2016 06:40
elm-make --warn leaves me with a bad type
-- Version 1
-- No error or warning here
module Build exposing (..)
build : a -> b -> { foo : b, name : a }
build a b =
{ name = a, foo = b }

http://guide.elm-lang.org/core_language.html says

Unlike JavaScript, Elm makes a distinction between integers and floating point numbers. Just like Python 3, there is both floating point division (/) and integer division (//).

> 9 / 2
4.5

> 9 // 2
4
@deepak
deepak / redux for form submission.txt
Created September 1, 2016 05:41
redux for form submission
- INIT
- INPROGRESS
- SUCCESS
- ERROR
reducer is:
{
status: "SUCCESS" | "ERROR" | "INPROGRESS",
data: { },
@deepak
deepak / mocha mock does not work
Created August 31, 2016 09:11
mocha mock does not work
it('needs auth to be passed in', (done) => {
const usedMock = nock('http://example.com/v1', {
reqheaders: {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": `Basic ${btoa(auth)}`
}
}).post('/user').reply(200, jsonResponse);
const storedAuthMock = nock('http://example.com/v1', {
@deepak
deepak / test should pass on each commit.sh
Created August 30, 2016 23:50
test should pass on each commit
git rebase origin/master -x 'bundle exec rspec'
@deepak
deepak / mocha-require-using-webpack-root.txt
Last active August 30, 2016 14:18
How does mocha require work
my question is related to http://stackoverflow.com/questions/31326199/mocha-equivalent-to-webpacks-resolve-root
am using root paths in my app code.
webpack config snippet:
```json
const path = require('path'),
webpack = require('webpack'),
PATHS = {
app: path.join(__dirname, 'app'),
@deepak
deepak / monotonically-increasing.js
Last active August 12, 2016 12:51
javascript helper to get monotonically increasing values
const helpers = {
*monotonicallyIncreasingGen(start, step) {
var counter = start;
while (true) {
yield counter;
counter += step;
}
},
@deepak
deepak / redux-saga-readme-translated
Created August 9, 2016 13:34
translate redux-saga readme from traditional chinese
#### note
translate https://github.com/yelouafi/redux-saga/blob/7da88a9096268ed70cfd9e6f0a54454274ad5ddd/README_zh-hant.md
using google translate
# Redux-saga
[! [Npm version] (https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)] (https://www.npmjs.com/package/redux-saga )
Another Side Effect model Redux app. Instead of thunk redux-thunk sent. You can create * * Sagas in one place to focus all Side Effect logic.