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
#!/usr/bin/python3 | |
from pymongo import MongoClient | |
from datetime import datetime, timedelta | |
from pprint import pprint | |
mongo_parameters = { | |
'source_mongo': '', | |
'db' : '', | |
'dest_mongo' : '' | |
} |
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
import subprocess | |
def execute_binary(args): | |
popen = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
stdout,stderr = popen.communicate() | |
if popen.returncode != 0: | |
print("Process exited non zero: {0}".format(popen.returncode)) | |
return False | |
return True |
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
#!/usr/bin/python3 | |
import boto3 | |
def get_s3_object(key, keyid, bucket, s3_file_location, local_file): | |
client = boto3.client('s3',aws_access_key_id=keyid,aws_secret_access_key=key) | |
client.download_file(bucket, s3_file_location, local_file) | |
return |
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
// Based on - https://stackoverflow.com/a/53878/437894 | |
#include <vector> | |
#include <string> | |
using namespace std; | |
vector<string> stringTokenizer(string input, char delimiter){ | |
vector<string> result; | |
if(!input.length()) | |
return 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
/** | |
* 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 { |
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
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
// 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
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
/* | |
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) |
OlderNewer