Skip to content

Instantly share code, notes, and snippets.

View ncammarata's full-sized avatar

Nick Cammarata ncammarata

View GitHub Profile
[
3,
2,
14,
18,
36,
15,
29,
39,
36,
[
10,
24,
74,
136,
310,
160,
283,
630,
698,
.messages
.message(
repeat<user> = @userMessages
class<active> = @activeUser.id == user.id
click = :activate user
)
.name {user.message}
.latest {.text (tail user.messages)}
.date {friendly message.timestamp}
import List
Task : { done: Boolean, id: Int, name: String }
Tasks : { name: String, tasks: List Task }
TasksList : List Tasks
Component "tasks-page" {
attrs: {tasks: Tasks}
state: {newTask: ""}
tweets = Socket "api.localhost.dev/tweets"
>> filter (.favorites > 1000)
>> sortBy .favorites
>> take 10
App {
state: { tweets }
template:
h1 Favorite Tweets
.tweet(
# Front end
api = connectAPI "https://localhost:3000"
Colors = api.collection 'colors'
colors = Colors
<< sortBy .name
App {
Flint = require('Flint')
api = Flint.api
colors = api.collection 'colors', {
add: (item) ->
remove: (id) ->
change: (id, newItem) ->
}
App {
state = { left = 50, name = "nick" },
template =
h1(left: @left) hello man
button(click: @left -= 50) go left
button(click: @left += 50) go right
h1() my name is {@name}
input(sync: @name)
App {
state: { activeMessage: 0 }
routes: {
message: {
route: "/messages/{id}"
action: :loadMessage
}
}
actions:
placeholder = "What needs to be done?"
type Filter = All | Active | Complete
filterFn = case Filter of
All: constant True
Complete: (eq .complete)
Active: (not << eq) .complete
App {