Thursday, January 10, 2019

AWS S3 Static Website Hosting Error saving new Read Policy


I started an AWS tutorial in which first step is setting up a bucket to host a static website. I was trying to apply a policy to enable read access to all contents of bucket but was getting this error saving it: Error Access Denied. Not a very detailed message.


I found that there is an option to "Block new public bucket policies" set in true by default.

I set it to false and problem solved. I guess AWS wants to make sure no one enables full read access of the entire bucket by mistake.

Tuesday, August 14, 2018

Oracle Materialized View Notes

Check all the mviews:

SELECT * FROM all_mviews;

Refresh an mview:

execute dbms_mview.refresh('my_cool_mview','f');

Tuesday, August 1, 2017

Java Lambdas Tips

Creating a lookup method for an Enum



Without lambdas:

public enum Type {
     
     INFO,
     WARNING,
     ERROR;

     final static Map<String, Type> lookup = new HashMap<String, Type>();
     
     static {
      for(Type type : Type.values()) {
       lookup.put(type.name().toLowerCase(), type);
      }
     }

       
     public static Type of(String value){
         Type val = lookup.get(value == null ? null : value.toLowerCase());
         if(val == null){
             val = ERROR;
         }
         return val;
     }
}

With lambda:


public enum Type {
     INFO,
     WARNING,
     ERROR;

     final static Map<String, Type> lookup = Arrays.stream(Type.values())
          .collect(Collectors.toMap(t -> t.name().toLowerCase(), Function.identity()));

     public static Type of(String value){
         Type val = lookup.get(value == null ? null : value.toLowerCase());
         if(val == null){
            val = ERROR;
         }
         return val;
     }
}

Wednesday, January 11, 2017

Switching DNS in Ubuntu Linux

One approach to switch among different development environments (QA, Integration, Stage, etc) is to have different DNS configs for routing one domain.

In Ubuntu you can setup different network connections with different DNS servers and be able to switch from network top menu,

1. Simply add a new network connection (may need two, one for Ethernet and one for WiFi)


2. Configure DNS settings


3. Switch to new connection from top menu


4. Test with nslookup command

Friday, March 11, 2016

Curl tips

Get response headers sending headers and cookies

curl --header "BB-App:androidNativeStore, 1.0.1" --cookie "lc=US|en" -I http://bitwise-api2.dev:8080/store-api/preferences/store-flag?store=us

HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
BB-Host: bitwise-api2.dev
Location: https://store.bbcomcdn.com/deploy/images/common/flags/flag_us.jpg
Content-Length: 0
Date: Fri, 11 Mar 2016 16:41:41 GMT