Skip to content

Instantly share code, notes, and snippets.

View mindflayer's full-sized avatar

Giorgio Salluzzo mindflayer

View GitHub Profile
@mindflayer
mindflayer / gist:6524007
Created September 11, 2013 14:00
PHP middleware removal using nginx proxy, JSONP available if GET param callback is available
location ^~ /v02/contenz/ {
if ( $arg_callback ) {
add_header Content-Type application/javascript;
echo_before_body '$arg_callback(';
echo_after_body ');';
}
proxy_pass http://192.168.124.37:8001/;
}
@mindflayer
mindflayer / gist:6027026
Created July 18, 2013 06:05
For Python group on Facebook
>>> class Fruit(object):
... pass
...
>>> class Apple(Fruit):
... color = None
... def __init__(self, color):
... self.color = color
...
>>> apple_in_my_fridge = Apple('green')
>>> isinstance(apple_in_my_fridge, Apple)
from datetime import date
s = str(1900630375204)
gender = int(s[0])==1 and 'M' or 'F'
born_date = date(1900+int(s[1:3]), int(s[3:5]), int(s[5:7]))
city_code = int(s[7:])
print gender, borndate, city_code
@mindflayer
mindflayer / gist:5444129
Last active December 16, 2015 13:48
I have an index with the following (first file) _mapping, in which I added a dynamic template to assign a custom analyzer (second file) to all fields matching name "meta_*.title" and "meta_*.description". In the last file I added a sample content. Am I right if I say that with this configuration I'm able to perform some "autocomplete" like searc…
{
"webapp_contents": {
"content": {
"dynamic_templates": [
{
"metadata_title": {
"mapping": {
"analyzer": "autocomplete"
},