S3 upload object

#!/bin/bash

# AWS S3 bucket and object information
S3_BUCKET_NAME="your-bucket-name"
S3_OBJECT_KEY="backup/largefile.zip"
UPLOAD_ID="your-upload-id" # Replace with the actual upload ID

# List the parts uploaded for the given upload ID
parts_list=$(aws s3api list-parts --bucket "${S3_BUCKET_NAME}" --key "${S3_OBJECT_KEY}" --upload-id "${UPLOAD_ID}")

# Extract the ETags and part numbers from the parts list
ETAGS=($(echo "${parts_list}" | jq -r '.Parts[].ETag'))
PART_NUMBERS=($(echo "${parts_list}" | jq -r '.Parts[].PartNumber'))

# Create a JSON file containing the completed parts information
json_file=$(mktemp /tmp/completed_parts.XXXXXX.json)
echo '{"Parts": [' > "${json_file}"

for ((i = 0; i < ${#ETAGS[@]}; i++)); do
echo "{\"PartNumber\": ${PART_NUMBERS[$i]}, \"ETag\": \"${ETAGS[$i]}\"}," >> "${json_file}"
done

# Remove the trailing comma and close the JSON array
sed -i '$ s/,$//' "${json_file}"
echo ']}' >> "${json_file}"

# Complete the multipart upload
aws s3api complete-multipart-upload \
--bucket "${S3_BUCKET_NAME}" \
--key "${S3_OBJECT_KEY}" \
--upload-id "${UPLOAD_ID}" \
--multipart-upload "file://${json_file}"

# Clean up temporary JSON file
rm "${json_file}"

echo "Multi-part upload completed."

Multipart upload

#!/bin/bash

# AWS S3 bucket and object information
S3_BUCKET_NAME="your-bucket-name"
LOCAL_FILE_PATH="/path/to/your/largefile.zip"
S3_OBJECT_KEY="backup/largefile.zip"

# AWS CLI command to initiate a multi-part upload and retrieve the upload ID
upload_id=$(aws s3api create-multipart-upload --bucket "${S3_BUCKET_NAME}" --key "${S3_OBJECT_KEY}" --query 'UploadId' --output text)

if [ -z "${upload_id}" ]; then
echo "Failed to initiate multi-part upload."
exit 1
fi

echo "Multi-part upload initiated. Upload ID: ${upload_id}"

# Set up variables for part number and part size
part_number=1
part_size=5 # Specify the part size in megabytes (adjust as needed)

# Split the local file into parts and upload each part
split -b "${part_size}M" "${LOCAL_FILE_PATH}" "${LOCAL_FILE_PATH}.part"

for part_file in "${LOCAL_FILE_PATH}.part"*; do
echo "Uploading part ${part_number}..."
aws s3api upload-part --bucket "${S3_BUCKET_NAME}" --key "${S3_OBJECT_KEY}" --upload-id "${upload_id}" --part-number "${part_number}" --body "${part_file}" --output json
((part_number++))
done

# Complete the multi-part upload
aws s3api complete-multipart-upload --bucket "${S3_BUCKET_NAME}" --key "${S3_OBJECT_KEY}" --upload-id "${upload_id}" --multipart-upload '{"Parts": [{'$(for i in $(seq 1 $((part_number-1))); do echo -n "{\"PartNumber\":$i,\"ETag\":\"$(aws s3api list-parts --bucket "${S3_BUCKET_NAME}" --key "${S3_OBJECT_KEY}" --upload-id "${upload_id}" --query "Parts[?PartNumber==\`$i\`].ETag" --output text)\"},"; done)']}]}' --output json

# Clean up temporary part files
rm "${LOCAL_FILE_PATH}.part"*

echo "Multi-part upload complete."

Resources R, Shiny, rmarkdown, htmlwidgets, plots and dashboard

Deployment of R Applications
http://predictiveecology.org/2015/12/08/R-Web-App-Development-Deployment-Distribution.html
http://www.jenunderwood.com/2015/01/12/part-1-integrating-r/
http://shiny.rstudio.com/articles/shinyapps.html

R studio learning resources
https://www.rstudio.com/online-learning/

R Markdown
http://rmarkdown.rstudio.com/lesson-1.html

Shiny
http://rstudio.github.io/shiny/tutorial/
http://shiny.rstudio.com/
https://shiny.rstudio.com/tutorial/

Shiny Gallery
http://shiny.rstudio.com/gallery/

Building Shiny Apps
http://deanattali.com/blog/building-shiny-apps-tutorial/

R for Data Science
http://r4ds.had.co.nz/

Embedding Maps in R using Leaflet library
https://rstudio.github.io/leaflet/map_widget.html
http://leafletjs.com/reference.html

HTML Widgets
http://www.htmlwidgets.org/

ggplot
http://www.statmethods.net/advgraphs/ggplot2.html

Click to access ggplot2-cheatsheet.pdf

https://plot.ly/ggplot2/
https://www.datacamp.com/courses/data-visualization-with-ggplot2-1

Plotly
https://plot.ly/r/

Using Plotly plots in Shiny App
https://plot.ly/r/shiny-tutorial/

Network Graphs
https://cran.r-project.org/web/packages/data.tree/vignettes/data.tree.html
https://christophergandrud.github.io/networkD3/#radial

Collapsible Tree
https://adeelk93.github.io/collapsibleTree/

Layouts in D3
http://chimera.labs.oreilly.com/books/1230000000345/ch11.html

Flexdashboard
http://rmarkdown.rstudio.com/flexdashboard/

ShinyDashboard
https://rstudio.github.io/shinydashboard/index.html

Knitr
https://yihui.name/knitr/

Visualization Samples
https://moderndata.plot.ly/interactive-r-visualizations-with-d3-ggplot2-rstudio/

Shiny Dashboard Samples
https://www.showmeshiny.com/
https://www.rstudio.com/products/shiny/shiny-user-showcase/


Integrating D3.js into Shiny

http://myinspirationinformation.com/visualisation/d3-js/integrating-d3-js-into-r-shiny/

Cricket

Cricket Data Retrieval
https://www.quora.com/Where-can-I-get-Raw-data-of-international-cricket

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=get+cricket+data+regarding+teams

Twitter

Twitter Trends Sample
https://www.trendsmap.com/

Twitter API Tutorial
http://socialmedia-class.org/twittertutorial.html

Download for Twitter python lib:
https://pypi.python.org/pypi/twitter#downloads

Twitter API
https://dev.twitter.com/rest/reference/get/trends/place

Twitter App Management
https://apps.twitter.com/

R Markdown

Learning Resources from RStudio

https://www.rstudio.com/online-learning/

R Markdown Learning Resource:
http://rmarkdown.rstudio.com/lesson-1.html

Parameters can be passed to an R markdown document
Parameters can be passed to R document

Insertion of Table in R Markdown:

Tables can be made easily with knitr’s ‘kable’ function.

mydata = read.csv(“../../data/opposition_vs_runs.csv”)
kable(mydata, caption = ‘Runs Scored Against Countries’)

Cheat Sheet for R markdown: Contains various formatting options for R.
rmarkdown-cheatsheet-2.0


Formatting of Text in R Markdown

italics
bold
code
links

Insert a hyperlink ==> elephant

 

Knitting to pdf:

for page end: \newpage or \pagebreak

D3.js

https://square.github.io/intro-to-d3/
https://d3js.org/

https://github.com/d3/d3/wiki/Tutorials
https://github.com/d3/d3/wiki/Gallery

Mike Bostock
https://bost.ocks.org/mike/


d3 API reference

https://github.com/d3/d3/blob/master/API.md

d3 Gallery
https://github.com/d3/d3/wiki/Gallery

Selection, enter(), exit() tutorial
https://bost.ocks.org/mike/join/
http://bl.ocks.org/alansmithy/e984477a741bc56db5a5

d3 scales
View at Medium.com
https://github.com/d3/d3-scale

Events
Transitions
Easing:  .ease(‘elastic’)

Sorting of data in d3
bardata.sort( function compareNumbers(a, b) {
return a-b;
});

Grouping of svg elements
Use the <g> tag

SVG Axis
var vAxis = d3.svg.axis()

d3 Margins
https://bl.ocks.org/mbostock/3019563

Reading data from files
http://learnjsdata.com/read_data.html

d3 Layouts
http://chimera.labs.oreilly.com/books/1230000000345/ch11.html#_force_layout

To get predefined color combinations
d3.scale.category20c()

Layouts
Pie Layout
Force Layout