Skip to content

Instantly share code, notes, and snippets.

View wilkerlucio's full-sized avatar

Wilker Lúcio wilkerlucio

View GitHub Profile
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));
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
class @Rectangle
@fromClientRect: (clientRect) ->
new Rectangle(
clientRect.left
clientRect.top
clientRect.right - clientRect.left
clientRect.bottom - clientRect.top)
@fromNode: (node) ->
{left, top} = node.offset()
class @Rectangle
constructor: (@left, @top, @width, @height) ->
expand: (amount) ->
yamount = amount / @width * @height
new Rectangle(
@left - amount
@top - yamount
@width + amount * 2
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)
<!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;">
describe "single annotation", ->
itP "returns the annotation", ->
Annotation.groupedTimeline([memo.group.id]).then (notes) ->
expect(notes).map("id").eql [memo.note.id]
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)
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", ->
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) ->