Skip to content

Instantly share code, notes, and snippets.

View vdparikh's full-sized avatar

Vishal Parikh vdparikh

View GitHub Profile
@vdparikh
vdparikh / api.go
Created March 17, 2019 19:26
Wrap GoLang Echo server in Lambda handler for API Gateway
package main
import(
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {
@vdparikh
vdparikh / snowflake.go
Created March 14, 2019 17:46
simple snowflake database query from Go and return results as JSON
package main
import (
"database/sql"
"encoding/json"
"log"
"reflect"
"time"
sf "github.com/snowflakedb/gosnowflake"
@vdparikh
vdparikh / enum.go
Created March 10, 2019 19:37 — forked from lummie/enum.go
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@vdparikh
vdparikh / template.yaml
Created March 2, 2019 18:12
AWS Glue SAM Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Lab Data Analytics.
Parameters:
StudentLabDataBucket:
Type: String
Globals:
Function:
Runtime: python3.6 # language used at runtime
@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/[email protected] 2x" />
</a>
</body>
</html>