This file contains 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
Stream.interval(1000) | |
|> Stream.map fn(_) -> get_memory_usage end | |
|> Stream.chunk(60) # group every 60 seconds together | |
|> Stream.map &( {Enum.min(&1), Enum.max(&1)} ) | |
|> Enum.each fn ({min, max) -> | |
send_to_graphite("min_memory_usage", min) | |
send_to_graphite("max_memory_usage", max) | |
end |
This file contains 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
defmodule Coercion do | |
defmacro get({:when, _, [path, {:is_integer, _, [{val, _, _}]}]}) do | |
{path, [{val, :integer}]} | |
end | |
defmacro get(route) do | |
{route, []} | |
end | |
end | |
defmodule Route do |
This file contains 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
defmodule ConcatTest do | |
def append do | |
1..10000 |> Enum.reduce([], fn (x, acc) -> | |
acc ++ [x] | |
end) | |
end | |
def prepend do | |
1..10000 |> Enum.reduce([], fn (x, acc) -> | |
[x] ++ acc | |
end) |> Enum.reverse |
This file contains 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
reduce for x <- [1,2,3], | |
y <- [3,4,5], | |
{n,m} = {2,3}, | |
x != 2, | |
acc: {sum, product} = {0,1} do | |
{sum + x + y + n + m, product*x*y*n*m} | |
end |
This file contains 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
selSort [] = [] | |
selSort l = let | |
x = minimum l | |
in x : selSort $ delete x l |
This file contains 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
defmodule Test do | |
defmacro foo_macro(bar, block) do | |
IO.inspect bar | |
IO.inspect block | |
end | |
def foo(bar, block) do | |
IO.inspect bar | |
IO.inspect block | |
end |
This file contains 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
Flask: | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
if __name__ == "__main__": | |
app.run() |
This file contains 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 Backbone.RaphaelView extends Backbone.View | |
delegateRaphaelEvents: (elements)-> | |
for name,element of elements | |
@delegateRaphaelElementEvents name, element | |
delegateRaphaelElementEvents: (name, element) -> | |
events = [ | |
"mouseup" | |
"mousedown" | |
"mousemove" | |
"mouseover" |
This file contains 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
It's a mostly empty database with only 4 records being emitted from the view (with reduce=false) | |
curl -u hamiltop https://hamiltop.cloudant.com/cs360/_design/purchases/_view/most_recent?reduce=false | |
{"total_rows":4,"offset":0,"rows":[ | |
{"id":"22b7dd2f647009d2161c42bb46d6c5e7","key":["Peter",1338416091.0237810612],"value":10}, | |
{"id":"5c7c2731a493d8cfafd036a7a93415fc","key":["Peter",1338416093.9606831074],"value":30}, | |
{"id":"8d2c99d15c9f37e0af0244c643fe7c84","key":["Peter",1338416096.3526899815],"value":22}, | |
{"id":"22b7dd2f647009d2161c42bb46da3b52","key":["Peter",1338416107.6635489464],"value":19} | |
]} |
This file contains 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
# my goal is for one module (of many) to use https://webcache.foo.com/ in place of /common/ for a set of static assets. | |
#here's what I have: | |
# root __init__.py | |
config.add_static_view('common', 'foo_web.layout:static/', cache_max_age=3600) | |
# my module __init__.py | |
config.add_static_view('https://webcache.foo.com/', 'foo_web.layout:cloudfront/', cache_max_age=3600) | |
config.override_asset( |
OlderNewer