Skip to content

Instantly share code, notes, and snippets.

View vdparikh's full-sized avatar

Vishal Parikh vdparikh

View GitHub Profile
@vdparikh
vdparikh / execute.go
Last active October 29, 2018 23:33
Execute scripts from /scripts folder inside a container
package main
import (
"fmt"
"log"
"os"
"github.com/ahmetalpbalkan/dexec"
"github.com/fsouza/go-dockerclient"
)
@vdparikh
vdparikh / server.py
Created July 25, 2018 17:00
CORS Simple HTTP Server in Python
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
None, in which case the caller has nothing further to do.
"""
@vdparikh
vdparikh / do_every.go
Created July 21, 2018 23:16
Execute a function at duration
package main
import (
"fmt"
"time"
)
func doEvery(d time.Duration, f func(time.Time)) {
for x := range time.Tick(d) {
f(x)
@vdparikh
vdparikh / invoke_lambda.go
Created July 21, 2018 23:07
Invoke Lambda Function from GO
package main
import (
"encoding/json"
"fmt"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/lambda"
@vdparikh
vdparikh / superset_install.sh
Created July 21, 2018 23:02
Userdata for installing apache superset on linux
#!/bin/bash
# Docker and Docker Compose are not needed for superset, but just for giggles
# Install Docker
yum install -y docker
service docker restart
# Install Docker Compose
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
@vdparikh
vdparikh / login.html
Last active July 21, 2018 22:56
Slack Sign In to get a permanent oauth token for the user
<html>
<head></head>
<body>
<h3>Sign In with Slack</h3>
<a id="slackURL" href="https://slack.com/oauth/authorize?scope=identity.basic,identity.email,identity.team,identity.avatar,chat:write:bot&client_id=<YOUR CLIENT ID HERE>"><img alt="Sign in with Slack" height="40" width="172" src="https://platform.slack-edge.com/img/sign_in_with_slack.png" srcset="https://platform.slack-edge.com/img/sign_in_with_slack.png 1x, https://platform.slack-edge.com/img/sign_in_with_slack@2x.png 2x" />
</a>
</body>
</html>
@vdparikh
vdparikh / server.py
Last active February 25, 2021 19:58
Python JSONRPC and HTTP with Flask
from flask import Flask, request, Response
from jsonrpcserver import methods
import os
app = Flask(__name__)
# JSON RPC Methods
@methods.add
def ping():
return 'pong'
@vdparikh
vdparikh / browser_pubsub.go
Last active July 16, 2018 01:59
Redis PubSub Example
package main
import (
"encoding/json"
"fmt"
"os"
"time"
"github.com/gin-gonic/contrib/static"
"github.com/gin-gonic/gin"
@vdparikh
vdparikh / README.md
Last active July 9, 2018 20:23
Presto On Mac

Installing Presto for Mac

Presto is a “Distributed SQL Query Engine for Big Data” that gives you the ability to join across data stores! 🎉

Server

The easiest way to install Presto is with Homebrew.

brew install presto
package utils
import (
"bytes"
"encoding/json"
"io"
)
// data, err := generateMap(StreamToByte(resp.Body))