Skip to content

Instantly share code, notes, and snippets.

@rishiloyola
rishiloyola / gist:9099f8eb59825feaa08d
Created October 18, 2015 06:48
Geo Diastance filter
streamingClient.search({
index: 'checkin',
type: 'city',
body: {
query : {
match_all : {}
},
filter : {
geo_distance : {
distance : "12km",
var myApp = angular.module('myApp', ['elasticsearch','ngMap']);
myApp.service('client', function (esFactory) {
return esFactory({
host: 'https://Uxa3m5nPP:ae4d2bf0-7669-4ba7-8849-3475576501c3@scalr.api.appbase.io',
});
});
@rishiloyola
rishiloyola / proxy.go
Created December 9, 2015 16:51 — forked from vmihailenco/proxy.go
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
package main
import (
"fmt"
"strconv"
"time"
"github.com/fsouza/go-dockerclient"
"github.com/samuel/go-zookeeper/zk"
)
data-controller.js
Creates a prototype which is responsible for four different queries. This file contains four functions which help to stream the data from appbase.
1.getSuggestions()
This function matches the input strings with the stored data and provides the suggestions related to specific queries.
2.getSearchCheckin()
Provides existing checkins according to the searched city.
3.getliveData()
Streams the live checkins. Which renders on a map with the blue marker.
4.getDragData()
This function streams the old data around the radius of 2000km from the center of map
A Check in JSON data looks like this:
{
"shout": "Columbus Realtors Directors Meeting",
"city": "columbus",
"category": "Office",
"latitude": 39.996149824327,
"longitude": -82.93393505324137,
"venue": "Columbus REALTORS®",
"city_suggest": "Columbus",
"url": "swarmapp.com/c/96gB6gzzl34",
if err != nil {
pc, fn, line, _ := runtime.Caller(1)
message := fmt.Sprintf("[error] %s[%s:%d] %s", runtime.FuncForPC(pc).Name(), fn, line, err.Error())
log.Println(message)
}
this.getSuggestions = function(text) {
return appbaseRef.search({
index: 'checkin',
body: {
suggest: {
mysuggester: {
text: text,
completion: {
field: 'city_suggest'
}
<!DOCTYPE html>
<html data-ng-app="myApp">
<head>
<title>Now : A RealTime Application</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Css START -->
<link rel="stylesheet" href="src/bower_components/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="src/bower_components/font-awesome/css/font-awesome.min.css" />
<link href="https://fonts.googleapis.com/css?family=Lato:400,100,100italic,300,300italic,400italic,700,700italic,900,900italic%7cOpen+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic" rel=stylesheet type=text/css />
function dragProcess(response) {
if (response.hits) {
for (var i = 0; i < response.hits.hits.length; i++) {
if (response.hits.hits[i]._source) {
if (response.hits.hits[i]._source.latitude && response.hits.hits[i]._source.longitude) {
if (citysearched == response.hits.hits[i]._source.city)
continue;
var default_arr = helper.getMapArray(response.hits.hits[i]._source);
var specific_arr = [
'src/assets/img/yellow_marker.png'