Skip to content

Instantly share code, notes, and snippets.

View siddharthlatest's full-sized avatar
👨‍💻
Focusing

Siddharth Kothari siddharthlatest

👨‍💻
Focusing
View GitHub Profile
@siddharthlatest
siddharthlatest / ninemorris_bot.py
Last active September 11, 2018 20:46
A Nine Men's Morris bot written for the codertrophy challenge - https://www.hackerrank.com/codertrophy/challenges/morrisnine/. Uses alpha-beta pruning over minimax tree till depth 5 (time limit constraints!) and uses an estimator function based on http://www.dasconference.ro/papers/2008/B7.pdf. I tweaked few co-efficients based on the contest pe…
import sys
import math
sys.setrecursionlimit(100000) # Set recursion depth to 10^5
POSMAP = {1:(0,0), 2:(0,3), 3:(0,6), 4:(1,1), 5:(1,3), 6:(1,5), 7:(2,2), 8:(2,3), 9:(2,4),
10:(3,0), 11:(3,1), 12:(3,2), 13:(3,4), 14:(3,5), 15:(3,6), 16:(4,2), 17:(4,3), 18:(4,4),
19:(5,1), 20:(5,3), 21:(5,5), 22:(6,0), 23:(6,3), 24:(6,6)}
POINTMAP = {(0,0):1, (0,3):2, (0,6):3, (1,1):4, (1,3):5, (1,5):6, (2,2):7, (2,3):8, (2,4):9,
(3,0):10, (3,1):11, (3,2):12, (3,4):13, (3,5):14, (3,6):15, (4,2):16, (4,3):17, (4,4):18,
(5,1):19, (5,3):20, (5,5):21, (6,0):22, (6,3):23, (6,6):24}
@siddharthlatest
siddharthlatest / twitter-appbase
Created August 23, 2014 07:57
AngularJS code for twitter built using Appbase
/* In this app $rootScope is mostly used for
* changing the route and managing visibly of navigation bar.
*/
Appbase.credentials("twitter", "2cac84749bc429ad7017bb1685eafaf4");
angular.module('twitter',['ngRoute','ngAppbase'])
.run(function($rootScope,userSession,$location) {
$rootScope.exit = function() {
userSession.exit()
$location.path('/global')
}
@siddharthlatest
siddharthlatest / dejavu-post.md
Last active October 19, 2020 06:53
DejaVu - An ElasticSearch databrowser built with ReactJS

The unmet need

We wanted a lightweight ElasticSearch data browser to include within the Appbase.io dashboard. We started out with evaluating existing browsers to see if we could repurpose them for our needs.

We were primarily looking for -

  1. Client-side rendering: Introducing either server-side code or database coupling would introduce performance hits and make hosting more prone to more failure scenarios; we felt strongly about client-side rendering.
  2. Déjà vu: While a polished UI is starting to become the norm in modern apps, we found that some data browsers have yet to match up in this regards.

We evaluated the most popular data browsers and found them lacking with either their client-side rendering capabilities or their UI / Ux sensibilities.

@siddharthlatest
siddharthlatest / appbaseio-recipes.md
Last active October 16, 2015 23:08
Create delicious recipes for appbase.io
<hack/> and write cool swag much impact
Build an app with appbase.io. Earn upto $200 in cash. Publish under an open-source license.
Write about it. Get some awesome swag - appbase.io credits, t-shirt, and stickers. Become a founding member and join appbase.io's hall of fame.
@siddharthlatest
siddharthlatest / post.md
Created October 23, 2015 07:54
How we built Now?

History of foursquare and swarmapp. Use of foursquare.

We built an app for showing live foursquare check-ins.

Key Ingredients

The now recipe can be broken into two key pieces: the backend worker and the user interface.

  1. Backend Worker: (How do we fetch data from Twitter and Foursquare?)
@siddharthlatest
siddharthlatest / appbaseio-use-cases.md
Created November 2, 2015 15:45
Top 10 Use-cases Of a Streaming Database

Top 10 Use-cases Of a Streaming Database

Appbase.io, 2015

Data Streams vs Data Set

Data Streams represent data in the flow. Data Set in contrast represents data in a base or data in a file. All database queries operate on a data set, i.e. even when the data set is being updated continuously - a query result once returned is never updated.

Data Set APIs work on a pull-based paradigm vs Data Streams APIs which operate on a push-based paradigm.

@siddharthlatest
siddharthlatest / webhooks.md
Last active November 24, 2015 17:21 — forked from yashshah/webhooks.md
Appbase Webhooks + Sendgrid

##Appbase + Sendgrid Webhooks Usecase

Basically in all the cases when you want to send transactional mail (i.e based on some activity), it is perfect fit to use Appbase and Sendgrid together.

  • When you want to notify users if their account information has been changed
  • Mails related to order confirmation, send an email when new entry comes in
  • Welcome mail to the users as soon as they sign up
  • Alert mails

You won't need to run your server to handle the mails. It is advisable to run the webhooks through the backend as you will be passing your API key in the request.

@siddharthlatest
siddharthlatest / geodragdatastream.js
Last active January 8, 2016 08:55
geolocation search query returned via data streams
this.getDragData = function(lat, lng) {
return appbaseRef.search({
type: 'city',
body: {
query: {
filter: {
geo_distance: {
distance: "2000km",
location: [lat, lng]
}
@siddharthlatest
siddharthlatest / citysuggest-search.js
Created January 4, 2016 12:20
city suggestion search query
appbaseRef.search({
body: {
suggest: {
mysuggester: {
text: text,
completion: {
field: 'city_suggest'
}
}
}
{
"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",
"username": "Kathy",