Skip to content

Instantly share code, notes, and snippets.

View Chadtech's full-sized avatar

Chadtech Chadtech

  • SuperFocus.ai
  • Pennsylvania
View GitHub Profile
_ = require 'lodash'
main = document.createElement "div"
main.id = "main"
document.body.appendChild main
data = []
_ = require 'lodash'
# app = Elm.Main.fullscreen()
main = document.createElement "div"
canvas = document.createElement "canvas"
main.appendChild canvas
ctx = canvas.getContext "2d"
{-| -}
onDoubleClick : (Point -> msg) -> Attribute msg
onDoubleClick message =
on "dblclick" <|
Json.map
(positionInCanvas >> message)
positionDecoder
positionInCanvas : ( Point, Point ) -> Point
@Chadtech
Chadtech / Point.Elm
Last active February 22, 2017 04:34
module Canvas.Point
exposing
( Point
, fromFloats
, fromInts
, toFloats
, toInts
)
var Html = require("html");
var Attributes = Html.Attributes;
var Events = Html.Events;
Html.App({
init: {
model: {
field: "Dank memes!"
}
allAlphanumeric : String -> Bool
allAlphanumeric str =
List.map isAlphanumeric (String.toList str)
|> List.foldr (||) False
isAlphanumeric : Char -> Bool
isAlphanumeric char =
String.contains (String.fromChar char) alphanumeric
try : RegisterModel -> ( RegisterModel, Cmd Msg )
try model =
if List.isEmpty model.problems then
log "ayy register!" ( model, register model )
else
{ model
| showProblems = True
}
! []
// What you do in redux to my knowledge
switch (action) {
case "update username field" :
return {
username: payload,
...state
}
case "submit" :
submit();
var cp = require("child_process");
var util = require("gulp-util");
var paths = {
mainElm: "./source/Main.elm",
dev: "./development"
};
gulp.task("elm-make", function () {
var cmd;
SetRegistration key value ->
{ model
| adminModel =
model.adminModel.userToRegister
|> updateUser key value
|> insertUser model.adminModel
}
! []
updateUser : String -> String -> User -> User