Skip to content

Instantly share code, notes, and snippets.

View amol-'s full-sized avatar

Alessandro Molina amol-

View GitHub Profile
std::vector<Int64Builder> builders(num_chunks);
ChunkResolver index_resolver(values.chunks());
for (int64_t requested_index = 0; requested_index < num_indices; ++requested_index) {
uint64_t index = poc_get_index(indices, requested_index);
ChunkLocation resolved_index = index_resolver.Resolve(index);
int64_t chunk_index = resolved_index.chunk_index;
if (chunk_index < 0) {
// ChunkResolver doesn't throw errors when the index is out of bounds
@amol-
amol- / request_validation.py
Created September 3, 2019 21:20
Test TurboGears request.validation in minimal mode
from wsgiref.simple_server import make_server
import tg
from tg import RestController, expose, validate, MinimalApplicationConfigurator
from formencode import validators
class RootController(RestController):
@expose('json')
@amol-
amol- / HelloWorld.jsx
Last active January 23, 2017 00:36
Isomorphic React applications in Python
export class HelloWorld extends React.Component {
render() {
return (
<div className="helloworld">
Hello {this.props.name}
</div>
);
}
}
@amol-
amol- / HelloWorld.jsx
Last active September 26, 2016 20:41
React, WebAssets, Babel and DukPY
export class HelloWorld extends React.Component {
render() {
return (
<div className="helloworld">
Hello {this.props.name}
</div>
);
}
}
@amol-
amol- / tgoneline.py
Last active April 17, 2016 18:02
Oneline TurboGears2 web application
from tg import expose, TGController, AppConfig
from wsgiref.simple_server import make_server
make_server('', 8080, AppConfig(
minimal=True,
root_controller=type('RootController', (TGController,), {
'index': expose()(lambda *args, **params: 'Hello World')
})()
).make_wsgi_app()).serve_forever()
@amol-
amol- / tg2_opbeat.py
Created February 23, 2016 11:46
OpBeat integration for TurboGears2
from tg.appwrappers.base import ApplicationWrapper
class OpBeatApplicationWrapper(ApplicationWrapper):
def __init__(self, handler, config):
super(OpBeatApplicationWrapper, self).__init__(handler, config)
from tg.support.converters import aslist
import logging
log = logging.getLogger('opbeat')
@amol-
amol- / babelfilter.py
Last active October 29, 2015 09:26
WebAssets Filter to compile ES6 to ES5 using DukPY and BabelJS
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
from webassets.filter import Filter
__all__ = ('BabelJS',)
# NOTE: When using the BabelJS compiler for code
# that needs to run in the browser make sure to add
# https://cdnjs.cloudflare.com/ajax/libs/babel-core/4.6.6/browser-polyfill.js
@amol-
amol- / tg2_appenlight
Created November 25, 2014 23:01
AppEnlight TurboGears2
TurboGears2 exception logging and performance monitoring
========================================================
Approx. integration time: **2 minutes**
WSGI middleware is the most common way to use App Enlight with your web application written in TurboGears2 web framework.
Installation and Setup
----------------------
@amol-
amol- / gist:8645500
Last active January 4, 2016 16:09
Proxy WSGI App
class ReverseProxied(object):
'''
location /myprefix {
proxy_pass http://192.168.0.1:5001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /myprefix;
}
'''
@amol-
amol- / gist:6061958
Created July 23, 2013 12:21
TurboMail on TurboGears 2.3
from __future__ import absolute_import
from turbomail.control import interface
from paste.deploy.converters import asbool
import re
from tg import config
class FakeConfigObj(object):
def __init__(self, real_config):