This file contains 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
# download service account key (this will require ServiceAccount Key Admin role) | |
gcloud iam service-accounts keys create ./key.json --iam-account <service_account> | |
# Set following env var to point to the service account key file | |
export GOOGLE_APPLICATION_CREDENTIALS=./key.json | |
# Keep in mind that changing gcloud auth by the below command, will not work as only "gcloud" commands use it, | |
# gcloud auth activate-service-account <service_account> --key-file=./key.json | |
# gcloud auth list |
This file contains 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
alias k='kubectl' | |
alias kx='kubectx' | |
alias khelp='echo n:nodes, p:pods, s:services, d: deployment, con:context, i:ingress, ns:namespace, map:configmaps, sec:secret, roll:rollout, kx=kubectx' | |
### Drop into an interactive terminal on a container | |
alias kexec='f() { kubectl exec -it "$@" -- bash; }; f' | |
### Pod management. | |
alias kp='kubectl get pods' | |
alias kpwatch='kubectl get pods --watch' | |
alias kpwide='kubectl get pods -o wide' |
This file contains 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
head -n 4096 /dev/urandom | openssl sha1 |
This file contains 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
// This function takes two params and returns a variable of type Immutable.Map<String, any>. | |
// Function is just for explaining the format of a function in typescript. Functionally this function does not do anything :) | |
// param1 : Type is Immutable.Map<String, any> | |
// param2 : Type is number | |
// returns a value of type Immutable.Map<Strin, any> | |
const functionVar = (param1: Immutable.Map<String, any>, param2: number): Immutable.Map<String, any> => { | |
return state; | |
}; |
This file contains 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
/* | |
arrOfObj = [{"name":"Ash"},{"name":"tim"},{"name":"david"}] | |
*/ | |
var result = arrOfObj.map(function(el) { | |
var o = Object.assign({}, el); | |
o.isActive = true; | |
return o; | |
}) | |
console.log(result) |
This file contains 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
dependency { | |
compile files ("../../x/y/z/libs/abs.jar") | |
} |
This file contains 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
// https://stackoverflow.com/a/41784667/437894 | |
apply plugin: 'project-report' |
This file contains 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
final JsonObject jsonObject = GSON.toJsonTree(<Object>).getAsJsonObject(); | |
for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { | |
System.out.println("Key = " + entry.getKey() + " Value = " + entry.getValue() ); | |
} |
This file contains 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
Gson gson = new GsonBuilder().setPrettyPrinting().create(); | |
JsonParser jp = new JsonParser(); | |
JsonElement je = jp.parse(GSON.toJson(<Object>)); | |
String prettyJsonString = gson.toJson(je); | |
System.out.println(prettyJsonString); |
This file contains 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
/** | |
* A common method for all enums since they can't have another base class | |
* @param <T> Enum type | |
* @param c enum type. All enums must be all caps. | |
* @param string case insensitive | |
* @return corresponding enum, or null | |
*/ | |
public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string) { | |
if( c != null && string != null ) { | |
try { |
NewerOlder