Skip to content

Instantly share code, notes, and snippets.

View rambabusaravanan's full-sized avatar

Andro Babu rambabusaravanan

  • Singapore
View GitHub Profile
@rambabusaravanan
rambabusaravanan / cache-manager.js
Created November 8, 2022 23:18
Toggle caching with "in-memory" / "redis" like h2 database for mysql
const { caching } = require('cache-manager');
const { redisStore } = require('cache-manager-redis-yet');
const { redisInsStore } = require('cache-manager-redis-yet');
const { createClient } = require('redis');
const ttl = 5 * 1000;
process.env.ENABLE_REDIS = true;
async function main() {
@rambabusaravanan
rambabusaravanan / serverless.s3-website.yml
Last active January 29, 2019 22:31
Serverless Framework CloudFormation Templates
resources:
Resources:
TestOneBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:service}-${self:provider.region}-test-one
CorsConfiguration:
CorsRules:
- AllowedOrigins: ['*']
AllowedHeaders: ['*']
@rambabusaravanan
rambabusaravanan / directory-index.js
Last active May 9, 2020 20:22
get S3 Directory Index as JSON
// source: https://gist.github.com/chinchang/8106a82c56ad007e27b1#file-xmltojson-js
function xmlToJson(xml) {
if (typeof xml === 'string') {
parser = new DOMParser();
xml = parser.parseFromString(xml, 'text/xml');
}
// Create the return object
var obj = {};
@rambabusaravanan
rambabusaravanan / schema-validation.js
Created June 15, 2018 06:59
jsonschema validation with custom display name
const validate = require('jsonschema').validate;
let schema = {
"type": "object",
"properties": {
"x": {
"display": "X Coordinate", // This is some extra field that we give for our purpose
"type": "number",
"required": true // error says like 'is required'
},
@rambabusaravanan
rambabusaravanan / utils.sh
Last active October 26, 2018 19:04
Shell Utils
# Schema Spy
java -jar /usr/local/bin/schemaSpy_5.0.0.jar -dp /home/androbabu/softwares/jar/mysql-connector-java-5.1.28.jar -t mysql -host localhost -db $1 -u root -p password -o .schema
# Git Tree Log
git log --graph --all --pretty=format:"%C(auto)%h%d %s %C(dim)(%an) %aD"
git config --global alias.tree 'log --graph --all --pretty=format:"%C(auto)%h%d %s %C(dim)(%an) %aD"'
git tree
@rambabusaravanan
rambabusaravanan / readme.md
Created March 17, 2018 22:07
Upload Service

The various approach followed for upload service

@rambabusaravanan
rambabusaravanan / detect-react-object.js
Created March 12, 2018 07:42
Detect React Objects - Components and Elements
function isClassComponent(component) {
return typeof component === 'function'
&& !!component.prototype.isReactComponent
}
function isFunctionComponent(component) {
return typeof component === 'function'
// && !!String(component).includes('return React.createElement') // may fails
&& React.isValidElement(Component())
}
@rambabusaravanan
rambabusaravanan / image-bucket.hosting-redirection-rules.xml
Created January 14, 2018 05:03
S3 Bucket image on-demand compression and conversion using AWS Lambda
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals/>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<Protocol>https</Protocol>
<HostName>xxx1x11xxx.execute-api.us-east-1.amazonaws.com</HostName>
<ReplaceKeyPrefixWith>prod/convert?key=</ReplaceKeyPrefixWith>
@rambabusaravanan
rambabusaravanan / README.md
Last active March 6, 2021 13:37
GitLab CI Configuration YAML

Firebase Deployment

Step 1: Get Token

Generate the firebase token from your terminal using the command $ firebase login:ci

Waiting for authentication...

✔ Success! Use this token to login on a CI server:

1/VXXXXXXX--YOUR-FIREBASE-CI-TOKEN--XXXXXh92o

@rambabusaravanan
rambabusaravanan / client.py
Created November 13, 2017 14:20
Simple TCP Streaming Server Client in Python
# Streaming Client
import socket
HOST = 'localhost'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
while True: