Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈

Ryan Haskell-Glatz ryannhg

🌈
View GitHub Profile
@ryannhg
ryannhg / 10-markdown.elm
Created Sep 27, 2016
Elm Markdown Example
View 10-markdown.elm
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
@ryannhg
ryannhg / SortableTable.elm
Created Nov 13, 2016
Simple sortable table functionality implemented with Try Elm | http://elm-lang.org/try
View SortableTable.elm
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.App as App
type CellType
= String
| Int
| Bool
@ryannhg
ryannhg / Lunch.elm
Created Dec 1, 2016
Get Lunch Suggestions
View Lunch.elm
import Html exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Random
main =
Html.program
{ init = init
View Sluggify.Elm
import Html exposing (..)
import Char
main = text <| sluggify "Sluggify's Example String!"
sluggify : String -> String
sluggify string =
string
|> removeSpecialCharacters
View ScrollSpy.html
<!DOCTYPE html>
<html>
<head>
<title>VueJS | Scrollspy</title>
<style type="text/css">
body {
margin: 0;
font-family: Arial;
@ryannhg
ryannhg / undottify.js
Last active Feb 6, 2018
Expands out JSON with dots in the property name.
View undottify.js
/* Input:
{
"person.name.first": "Ryan",
"person.name.last": "Haskell-Glatz",
"person.age": 23
}
... undottify magic ...
Output:
{
"person": {
@ryannhg
ryannhg / RepeatableFields.js
Last active Nov 15, 2017
Used for expanding KeystoneJS fields, and flattening the response
View RepeatableFields.js
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) => ({
@ryannhg
ryannhg / 01-app.js
Last active Feb 27, 2018
Vue.js - Props with Inline Templates
View 01-app.js
Vue.component('List', {
data: () => ({
names: [
'Ryan',
'Alexa',
'Jimmy'
]
})
})
@ryannhg
ryannhg / 01-app.js
Last active Feb 27, 2018
Vue.js - Props with String Templates
View 01-app.js
Vue.component('List', {
template: `
<div class="list">
<item v-for="name in names" v-bind:name="name" />
</div>
`,
data: () => ({
names: [
'Ryan',
'Alexa',
@ryannhg
ryannhg / equals.js
Created Mar 2, 2018
Check deep equality in javascript
View equals.js
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