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
| lapis = require "lapis" | |
| db = require "lapis.db" | |
| html = require "lapis.html" | |
| queries = require "queries" | |
| config = require("lapis.config").get! | |
| widgets = require "views.widgets" | |
| import get_redis from require "lapis.redis" | |
| --import cached from require "lapis.cache" | |
| import render_html from require "lapis.html" | |
| import notNil from require "utils" |
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
| // ES6 Version with Lodash | |
| /* | |
| titleCase('mcdonald') => McDonald | |
| titleCase('macdonald') => MacDonald | |
| titleCase("o'brien") => O'Brien | |
| */ | |
| var capitalize = (ignore, pre, rest) => _.capitalize(pre) + _.capitalize(rest) | |
| var titleCase = _.flow( |
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
| import macros | |
| macro extract(args: varargs[untyped]): typed = | |
| ## assumes that the first expression is an expression | |
| ## which can take a bracket expression. Let"s call it | |
| ## `arr`. The generated AST will then correspond to: | |
| ## | |
| ## let <second_arg> = arr[0] | |
| ## let <third_arg> = arr[1] | |
| ## ... | |
| result = newStmtList() |
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
| function _filterBodyDOM(dom) { | |
| while (child = dom.firstChild) { | |
| if (!this.isBadTopTag(child)) break; | |
| dom.removeChild(child); | |
| } | |
| while (child = dom.lastChild) { | |
| if (!this.isBadBottomTag(child)) break; | |
| dom.removeChild(child); | |
| } | |
| } |
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
| - certain endpoints are always blocked | |
| if nginx_uri == "/_access_token" or nginx_uri == "/_me" then | |
| ngx.exit(403) | |
| end | |
| -- import requirements | |
| local cjson = require "cjson" | |
| -- setup some app-level vars | |
| local app_id = "APP_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
| from __future__ import unicode_literals | |
| import sys | |
| # We only use unicode in our parser, except for __repr__, which must return str. | |
| if sys.version_info.major == 2: | |
| repr_str = lambda s: s.encode("utf-8") | |
| str = unicode | |
| else: | |
| repr_str = lambda s: s |
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
| export function isObject(item) { | |
| return (item && typeof item === 'object' && !Array.isArray(item) && item !== null); | |
| } | |
| export default function mergeDeep(target, source) { | |
| let output = Object.assign({}, target); | |
| if (isObject(target) && isObject(source)) { | |
| Object.keys(source).forEach(key => { | |
| if (isObject(source[key])) { | |
| if (!(key in target)) |
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
| function setDepth(obj, path, value) { | |
| var tags = path.split("."), len = tags.length - 1; | |
| for (var i = 0; i < len; i++) { | |
| obj = obj[tags[i]]; | |
| } | |
| obj[tags[len]] = value; | |
| } |
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
| import asynchttpserver, asyncdispatch | |
| import json | |
| import cgi | |
| var server = newAsyncHttpServer() | |
| proc handler(req: Request) {.async.} = | |
| let msg = %* {"message": "hello world"} | |
| await req.respond(Http200, $msg, newHttpHeaders([("Content-Type","application/json")])) |
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
| lapis = require "lapis" | |
| db = require "lapis.db" | |
| html = require "lapis.html" | |
| queries = require "queries" | |
| config = require("lapis.config").get! | |
| widgets = require "views.widgets" | |
| import get_redis from require "lapis.redis" | |
| import render_html from require "lapis.html" | |
| import notNil from require "utils" |