Skip to content

Instantly share code, notes, and snippets.

View ryan-haskell's full-sized avatar

Ryan Haskell ryan-haskell

View GitHub Profile
@ryan-haskell
ryan-haskell / 10-markdown.elm
Created September 27, 2016 04:59
Elm Markdown Example
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import String
import Markdown
main =
Html.beginnerProgram
{ model = model
@ryan-haskell
ryan-haskell / SortableTable.elm
Created November 13, 2016 06:21
Simple sortable table functionality implemented with Try Elm | http://elm-lang.org/try
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.App as App
type CellType
= String
| Int
| Bool
@ryan-haskell
ryan-haskell / Lunch.elm
Created December 1, 2016 17:19
Get Lunch Suggestions
import Html exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Random
main =
Html.program
{ init = init
@ryan-haskell
ryan-haskell / Sluggify.Elm
Created December 2, 2016 16:28
Sluggify | Elm
import Html exposing (..)
import Char
main = text <| sluggify "Sluggify's Example String!"
sluggify : String -> String
sluggify string =
string
|> removeSpecialCharacters
<!DOCTYPE html>
<html>
<head>
<title>VueJS | Scrollspy</title>
<style type="text/css">
body {
margin: 0;
font-family: Arial;
@ryan-haskell
ryan-haskell / undottify.js
Last active February 6, 2018 07:07
Expands out JSON with dots in the property name.
/* Input:
{
"person.name.first": "Ryan",
"person.name.last": "Haskell-Glatz",
"person.age": 23
}
... undottify magic ...
Output:
{
"person": {
@ryan-haskell
ryan-haskell / RepeatableFields.js
Last active November 15, 2017 17:41
Used for expanding KeystoneJS fields, and flattening the response
const getRange = (start, end) => {
let list = []
if (start <= end) {
for (let i = start; i <= end; i++)
list.push(i)
}
return list
}
const RepeatableField = (fields, prefix) => ({
@ryan-haskell
ryan-haskell / 01-app.js
Last active February 27, 2018 06:15
Vue.js - Props with Inline Templates
Vue.component('List', {
data: () => ({
names: [
'Ryan',
'Alexa',
'Jimmy'
]
})
})
@ryan-haskell
ryan-haskell / 01-app.js
Last active February 27, 2018 06:17
Vue.js - Props with String Templates
Vue.component('List', {
template: `
<div class="list">
<item v-for="name in names" v-bind:name="name" />
</div>
`,
data: () => ({
names: [
'Ryan',
'Alexa',
@ryan-haskell
ryan-haskell / equals.js
Created March 2, 2018 18:37
Check deep equality in javascript
const equals = (obj1, obj2) => {
const sortKeys = (obj) =>
(obj && typeof obj === 'object')
? Object.keys(obj)
.sort((a, b) => a < b)
.reduce((newObj, key) => {
newObj[key] = sortKeys(obj[key])
return newObj
}, {})
: obj