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_admin = AdminBundle(User, 'user', 'admin/user') | |
user_admin.push_bundle(application) |
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 bundle | |
class Room(bundle.APIBundle): | |
@bundle.expose('/<int:id>') | |
def get(self, id): | |
"Return room info" | |
return {} | |
@bundle.expose('/<int:id>/message', methods=['POST']) | |
def post_message(self, 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
apis = list(bundle.dump_api(app)) | |
for m in apis: | |
print m | |
{'name': 'room.post_message', 'url': '/room/{id}/message', 'args': ['id'], 'methods': ['POST'], 'host': '', 'desc': 'Post new message'} | |
{'name': 'room.get', 'url': '/room/{id}', 'args': ['id'], 'methods': ['GET'], 'host': '', 'desc': 'Return room info'} |
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
api = bundle.generate_api(apis, '127.0.0.1:5000') | |
print api.room.get.__dict__ | |
print 'API call result', api.room.get(id=1) | |
{'host': '127.0.0.1:5000', 'method': {'name': 'get', 'url': '/room/{id}', 'args': ['id'], 'methods': ['GET'], 'host': '', 'desc': 'Return room info'}} | |
{} |
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
-module(validate). | |
-compile(export_all). | |
list_to_number(L) -> | |
try list_to_float(L) | |
catch | |
error:badarg -> list_to_integer(L) | |
end. |
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
#! /bin/sh | |
kbuildsycoca4 | |
kquitapp plasma-desktop | |
plasma-desktop |
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
-module(fact). | |
-export([fac/1, fac2/1, benchmark/1]). | |
fac(1) -> | |
1; | |
fac(N) -> | |
N * fac(N - 1). | |
fac2(N) -> |
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 time | |
from jinja2 import Template as j | |
from django.template import Template as d | |
from django.template import Context | |
template = """ | |
Good template without includes, only cycles. | |
{% for i in d %} | |
<p>{{ i }}</p> |
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 time | |
from jinja2 import Template as j | |
from django.template import Template as d | |
from django.template import Context | |
template = """ | |
<div> | |
{% for priority in priorities %} | |
<div class="{{ priority.slug }}" priority="{{ priority.id }}" max_prods="{{ priority.max_prods }}" rank="{{ priority.rank }}"> |
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
% | |
% Rect library - work with rects | |
% | |
-module(rect). | |
-export([intersect/2, normalize/1]). | |
intersect(R1, R2) -> | |
{{X1, Y1}, {X2, Y2}} = R1, |
OlderNewer