This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express'); | |
| var path = require('path'); | |
| var app = express(); | |
| var directory = path.resolve(process.argv[2] || "."); | |
| var port = process.argv[3] || 8888; | |
| console.log("Serving", directory); | |
| app.use('/', express.static(directory)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "estados": [ | |
| { | |
| "sigla": "AC", | |
| "nome": "Acre", | |
| "cidades": [ | |
| "Acrelândia", | |
| "Assis Brasil", | |
| "Brasiléia", | |
| "Bujari", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class @Rectangle | |
| @fromClientRect: (clientRect) -> | |
| new Rectangle( | |
| clientRect.left | |
| clientRect.top | |
| clientRect.right - clientRect.left | |
| clientRect.bottom - clientRect.top) | |
| @fromNode: (node) -> | |
| {left, top} = node.offset() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class @Rectangle | |
| constructor: (@left, @top, @width, @height) -> | |
| expand: (amount) -> | |
| yamount = amount / @width * @height | |
| new Rectangle( | |
| @left - amount | |
| @top - yamount | |
| @width + amount * 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Sayish.API.Mentionable | |
| _escapeRegex: (str) -> String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') | |
| _fuzzySearch: (users, query) -> | |
| reg = "" | |
| for v, i in query | |
| char = query.charAt(i) | |
| reg += @_escapeRegex(char) + ".*" | |
| users.filter (u) -> new RegExp(reg, "i").test(u.name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| </head> | |
| <body style="margin: 0; padding: 0; background: #f3f5f9"> | |
| <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" style="background: #f3f5f9"> | |
| <tr> | |
| <td align="center" valign="top"> | |
| <table border="0" cellpadding="0" cellspacing="0" width="600" style="background: #f3f5f9; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: normal;"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "single annotation", -> | |
| itP "returns the annotation", -> | |
| Annotation.groupedTimeline([memo.group.id]).then (notes) -> | |
| expect(notes).map("id").eql [memo.note.id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wrappableBreaks: (range) -> | |
| if range.startContainer.parentNode == range.endContainer.parentNode | |
| [range] | |
| else | |
| leftSideNodes = RangeTools.ancestorTextNodesLeft(range.startContainer, range.commonAncestorContainer) | |
| leftChildParentIndex = RangeTools.immediateChildForAncestorIndex(range.startNode, range.commonAncestorContainer) | |
| rightSideNodes = RangeTools.ancestorTextNodesRight(range.startContainer, range.commonAncestorContainer) | |
| rightChildParentIndex = RangeTools.immediateChildForAncestorIndex(range.endContainer, range.commonAncestorContainer) | |
| middleNodes = _.toArray(range.commonAncestorContainer.childNodes).slice(leftChildParentIndex + 1, rightChildParentIndex) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "Range", -> | |
| quickRange = (startContainer, startOffset, endContainer, endOffset) -> | |
| _.tap document.createRange(), (range) -> | |
| range.setStart(startContainer, startOffset) | |
| range.setEnd(endContainer, endOffset) | |
| describe ".previousSiblingsOffset", -> | |
| {previousSiblingsOffset} = RangeTools | |
| it "calculates the offset text of a text node given it's siblings", -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| User = require("../models/user.coffee") | |
| readline = require("readline") | |
| mongoose = require("mongoose") | |
| mongoose.connect "mongodb://localhost/sayish-" + (process.env.NODE_ENV || "development") | |
| mongoose.connection.once "open", -> | |
| rl = readline.createInterface(input: process.stdin, output: process.stdout) | |
| rl.question "Type your name: ", (name) -> |