Skip to content

Instantly share code, notes, and snippets.

@rsudip90
rsudip90 / main.go
Created August 10, 2017 17:26 — forked from kevburnsjr/main.go
Easy Middleware in Go
package main
import (
"net/http"
"time"
"log"
)
func main() {
dh := DispatchHandler{}
@rsudip90
rsudip90 / valuer.go
Created November 23, 2017 13:23 — forked from jmoiron/valuer.go
Example uses of sql.Scanner and driver.Valuer
package main
import (
"bytes"
"compress/gzip"
"database/sql/driver"
"errors"
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
@rsudip90
rsudip90 / translate.go
Created February 8, 2018 12:15 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@rsudip90
rsudip90 / extract-attachments.py
Created October 4, 2018 17:13 — forked from stefansundin/extract-attachments.py
Extract attachments from emails that Gmail doesn't allow you to download. This is dumb. Please use Python >= 3.4.
#!/usr/bin/env python3
# Get your files that Gmail block. Warning message:
# "Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled."
# Based on: https://spapas.github.io/2014/10/23/retrieve-gmail-blocked-attachments/
# Instructions:
# Go to your emails, click the arrow button in the top right, "Show original", then "Download Original".
# Move the files to the same directory as this program, then run it.
import email
@rsudip90
rsudip90 / mysql57_yum.sh
Last active November 2, 2018 07:13
Automated mysql57 community server installation for yum-based linux distro - bash script
#!/bin/bash
# This script will download mysql version as specified in `MYSQL_RELEASE`
# Aim to install latest image of mysql release on machine of amazon linux AMI.
# Guidance: https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
MYSQL_RELEASE=mysql57-community-release-el6-11.noarch.rpm
MYSQL_RELEASE_URL="https://dev.mysql.com/get/${MYSQL_RELEASE}"
MYSQL_SERVICE=mysqld
MYSQL_LOG_FILE=/var/log/${MYSQL_SERVICE}.log
@rsudip90
rsudip90 / GPicker.vue
Last active February 28, 2019 12:28
Google Picker dialog vue component
<template lang="pug">
div
button.pronto-btn.add(disabled="true" ref="gAPIAuthBtn") Authenticate
div(ref="gAPIResult")
</template>
<script>
export default {
data() {
return {
@rsudip90
rsudip90 / mixins.py
Last active May 7, 2019 18:27
get serializer classes dynamically based on viewset actions
class GetSerializerClassMixin(object):
def get_serializer_class(self):
"""
under class which inhertis this mixins should have variable
`serializer_action_classes`.
Look for serializer class in self.serializer_action_classes, which
should be a dict mapping action name (key) to serializer class (value),
i.e.:
@rsudip90
rsudip90 / cypress_AMI_dependencies_install.sh
Last active August 14, 2019 00:56
latest system update
#!/bin/bash
# This script installs the dependencies required by cypress.io tool
# on amazon linux AMI as the required dependencies are not easily available.
# path of dynamic executable of cypress
# for ex. /home/ec2-user/.cache/Cypress/3.0.1/Cypress/
CYPRESS_EXECUTABLE_FOLDER="/home/ec2-user/.cache/Cypress/<version>/Cypress"
exitError() {