Instantly share code, notes, and snippets.
Full Stack Developer | AWS Certified Solutions Architect & Developer | Google Certified Mobile Web Specialist
- Singapore
rambabusaravanan /cache-manager.js
CreatedNovember 8, 2022 23:18
Toggle caching with "in-memory" / "redis" like h2 database for mysql This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| const{ caching}=require('cache-manager'); | |
| const{ redisStore}=require('cache-manager-redis-yet'); | |
| const{ redisInsStore}=require('cache-manager-redis-yet'); | |
| const{ createClient}=require('redis'); | |
| constttl=5*1000; | |
| process.env.ENABLE_REDIS=true; | |
| asyncfunctionmain(){ |
rambabusaravanan /serverless.s3-website.yml
Last activeJanuary 29, 2019 22:31
Serverless Framework CloudFormation Templates This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| resources: | |
| Resources: | |
| TestOneBucket: | |
| Type:AWS::S3::Bucket | |
| Properties: | |
| BucketName:${self:service}-${self:provider.region}-test-one | |
| CorsConfiguration: | |
| CorsRules: | |
| -AllowedOrigins:['*'] | |
| AllowedHeaders:['*'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // source: https://gist.github.com/chinchang/8106a82c56ad007e27b1#file-xmltojson-js | |
| functionxmlToJson(xml){ | |
| if(typeofxml==='string'){ | |
| parser=newDOMParser(); | |
| xml=parser.parseFromString(xml,'text/xml'); | |
| } | |
| // Create the return object | |
| varobj={}; |
rambabusaravanan /schema-validation.js
CreatedJune 15, 2018 06:59
jsonschema validation with custom display name This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| constvalidate=require('jsonschema').validate; | |
| letschema={ | |
| "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' | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # 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 /detect-react-object.js
CreatedMarch 12, 2018 07:42
Detect React Objects - Components and Elements This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| functionisClassComponent(component){ | |
| returntypeofcomponent==='function' | |
| &&!!component.prototype.isReactComponent | |
| } | |
| functionisFunctionComponent(component){ | |
| returntypeofcomponent==='function' | |
| // && !!String(component).includes('return React.createElement') // may fails | |
| &&React.isValidElement(Component()) | |
| } |
rambabusaravanan /image-bucket.hosting-redirection-rules.xml
CreatedJanuary 14, 2018 05:03
S3 Bucket image on-demand compression and conversion using AWS Lambda This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| <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 /client.py
CreatedNovember 13, 2017 14:20
Simple TCP Streaming Server Client in Python This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # Streaming Client | |
| importsocket | |
| HOST='localhost' | |
| PORT=50007 | |
| s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) | |
| s.connect((HOST,PORT)) | |
| whileTrue: |
NewerOlder