Skip to content

Instantly share code, notes, and snippets.

View AnSavvides's full-sized avatar

Andreas Savvides AnSavvides

View GitHub Profile
<style>
#browser { padding: 20px; }
img { width: 100px; height: 100px; float: left; }
</style>
<h1>THE CATS</h1>
<button>Pls give me a cat</button>
<div id="cats"></div>
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
stringList := strings.Fields(s)
wordCount := make(map[string]int)
@AnSavvides
AnSavvides / jsonp_flask.py
Created June 24, 2014 15:10
Supporting jsonp with Flask
from functools import wraps
from flask import request, current_app
def support_jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
content = str(callback) + '(' + str(f().data) + ')'
@AnSavvides
AnSavvides / gist:4197614
Created December 3, 2012 20:05
action_histograms real fix
# Create an index:
#
curl -XDELETE 'http://127.0.0.1:9200/articles'
curl -XPUT 'http://127.0.0.1:9200/articles' -d '
index :
number_of_shards : 1
'
# Insert the action mapping:
#
@AnSavvides
AnSavvides / gist:4195194
Created December 3, 2012 13:55
action_histograms fix?
# Create an index:
#
curl -XDELETE 'http://127.0.0.1:9200/articles'
curl -XPUT 'http://127.0.0.1:9200/articles'
# Insert the action mapping, as a child of articles:
#
curl -XPUT 'http://127.0.0.1:9200/articles/article/_mapping' -d '
{
"article": {
@AnSavvides
AnSavvides / gist:4177014
Created November 30, 2012 17:02 — forked from markbirbeck/gist:1684506
[ElasticSearch] Insert 6 records and query for a single record with facets: Failure when the number of records is greater than the shard size
# Create an index:
#
curl -XDELETE 'http://127.0.0.1:9200/articles'
curl -XPUT 'http://127.0.0.1:9200/articles'
# Insert the action mapping, as a child of articles:
#
curl -XPUT 'http://127.0.0.1:9200/articles/article/_mapping' -d '
{
"article": {