import boto3
import os
import uuid
import pytz
import datetime
def make_athena_client():
athena_client = boto3.client('athena',
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
| #!/usr/bin/env groovy | |
| import groovy.json.JsonSlurper | |
| def nexus_server_base_url = 'http://nexus:8081/service/siesta/rest/beta/components' | |
| def repository = 'maven-public' | |
| def base_url = "${nexus_server_base_url}?repositoryId=${repository}" | |
| def jsonSlurper = new JsonSlurper() |
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
| #!/bin/bash | |
| # This script will update a new workspace created on Cloud9 IDE with the latest packages. | |
| # In order to use it, create a update_workspace.sh file in your C9 Workspace and then make it executable using the command | |
| # `touch update_workspace.sh && chmod +x update_workspace.sh`. | |
| # Now you can open the updata_workspace.sh file and copy/paste this full script, save and close. | |
| # Run the command `./update_workspace.sh` to execute the script. | |
| # | |
| # Alternatively you can use this command to download and make this script executable from github | |
| # wget -O update_workspace.sh https://gist.githubusercontent.com/aubort/836888f8aaeeeff75024c87e9c9199f0/raw && chmod +x update_workspace.sh |
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
| import argparse, datetime, logging | |
| import apache_beam as beam | |
| from apache_beam.options.pipeline_options import PipelineOptions | |
| from apache_beam.options.pipeline_options import SetupOptions | |
| class GetTimestampFn(beam.DoFn): | |
| """Prints element timestamp""" | |
| def process(self, element, timestamp=beam.DoFn.TimestampParam): |
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
| This gist includes hive ql scripts to create an external partitioned table for Syslog | |
| generated log files using regex serde; | |
| Usecase: Count the number of occurances of processes that got logged, by year, month, | |
| day and process. | |
| Includes: | |
| --------- | |
| Sample data and structure: 01-SampleDataAndStructure | |
| Data download: 02-DataDownload | |
| Data load commands: 03-DataLoadCommands |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
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
| #!/bin/bash -e | |
| # | |
| # Copyright 2014 Tony Burns | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # |
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
| // method1 | |
| val i = 1 to 10 toList | |
| i.flatMap(List.fill(2)(_)) | |
| // method 2 | |
| for { e <- i ; y <- 1 to 2} yield e | |
| // method 3 | |
| def f(num : Int, arr : List[Int]) : List[Int] = { |
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
| sudo add-apt-repository ppa:webupd8team/sublime-text-3; | |
| sudo apt-get update; | |
| sudo apt-get install sublime-text-installer; | |
| sudo ln -s /usr/lib/sublime-text-3/sublime_text /usr/local/bin/sublime; |
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
| val b = data.map(x =>(x._1,1)).reduceByKey(_+_).collect // Each customer how many times purchased | |
| val z = data.map(x=>( x._1,x._3)).mapValues(y => (y,1)).reduceByKey((a,b) => (a._1 + b._1,a._2+b._2)). | |
| | map{ x => | |
| | val temp = x._2 | |
| | val total = temp._1 | |
| | val count = temp._2 | |
| | (x._1,total,total/count) | |
| | }.collect //How much average money spent and how many times purchased |
NewerOlder