Skip to content

Instantly share code, notes, and snippets.

View keleshev's full-sized avatar
🐪

Vladimir Keleshev keleshev

🐪
View GitHub Profile
@app.route('/<int:id>')
def my_view(id):
player = Player.get(id)
yield player.as_json, 200
player.update_stats() # Called *after* the response is made.
from time import sleep
from flask import Flask, Response, request
app = Flask('hello')
@app.route('/')
def hello():
Node(s, 0..<3, name: "value", text: "(1)", children:
[Node(s, 0..<3, name: "expr", text:, "(1)", children:
[Node(s, 0..<1, text: "("),
Node(s, 1..<2, name: "sum", text: "1", children:
[Node(s, 1..<2, name: "prod", text: "1", children:
[Node(s, 1..<2, name: "value", text: "1", children:
[Node(s, 1..<2, name: "number", text: "1", children:
[Node(s, 1..<2, text: "1")])]),
Node(s, 2..<2, text: "")]),
Node(s, 2..<2, text: "")]),
class Value
class << self
alias [] new
end
def ==(other)
return false unless other.is_a? self.class
self.uninitialize == other.uninitialize
end
alias_method :eql?, :==
# let b = Buffer.create 0 in
Buffer.add_substitute b (function "hello" -> "bye") "$hello world";
Buffer.contents b;;
- : string = "bye world"
task :default => :test
PACKAGES = ['core', 'sexplib.syntax']
MENHIR = 'menhir --explain'
TEST_SOURCES = FileList['**/test_*.ml'].exclude(/build\//)
TEST_BINARIES = TEST_SOURCES.pathmap 'build/%X.d.byte'
task :test do |t|
ocamlbuild TEST_BINARIES
module Interval = struct
type 'a t = {start: 'a; finish: 'a}
end
module Position = struct
type t = {line: int; column: int}
end
query = {
'level': '1',
'box.top': '2',
'box.left': 'foo',
'box.bottom': 'bar',
'box.right': 'baz',
'fox.mox.dox': '0.5',
'fox.mox.dox': '0.5',
}
include (struct
type 'a t = 'a * string list
exception FatalWarning of string list
let to_exn: 'a t -> 'a = function
| value, [] -> value
| value, warnings -> raise (FatalWarning warnings)
let map f (value, warnings) = f value, warnings