Skip to content

Instantly share code, notes, and snippets.

View alisade's full-sized avatar

Ali Ardestani alisade

  • Los Angeles, CA
View GitHub Profile
@alisade
alisade / multi_part_copy.py
Created November 21, 2022 19:15
merge existing files on s3 without downloading them first using multi part copy
# Using s3 copy with multipart uploads for efficient file merging
# limitation: min part size is 5MB
import boto3
from datetime import datetime
client = boto3.client('s3')
now = datetime.now()
timestamp = now.strftime("%Y%m%d_%H%M%S")
bucket = "bucket-testing-dev"
@alisade
alisade / gist:1da1ae25399e9bfffb558645330a50c9
Last active October 27, 2021 15:22
simple https server
echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\n<h1>hello world from $(hostname) on $(date)</h1>" | sudo ncat -vl --ssl 443
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
License: Apache-2.0
Description: '@Author: Sanjay Garje. AWS CloudFormation Sample Template SageMaker NotebookInstance: This template demonstrates
the creation of a SageMaker NotebookInstance with encryption. You will be billed for the AWS resources used if you create a stack from
this template.'
Parameters:
NotebookInstanceName:
AllowedPattern: '[A-Za-z0-9-]{1,63}'
ConstraintDescription: Maximum of 63 alphanumeric characters. Can include hyphens
@alisade
alisade / gist:42c681998d2e5d7867e80be645b6913f
Created April 1, 2021 15:07
jenkins parallel build agent
// Job == agent-build_pipeline
// build agent for linux/windows
currentBuild.description = env.TAG
def WORKER='worker-large'
def OS = [ 'redhat', 'debian' ]
def ARCH = [ '64' ]
def pipeline_branches = [:]
def JB='./jenkins/build'
def jbuild = { sh "bash ${JB}/build.sh" }
def provision = { sh "bash ${JB}/provision.sh" }
source ~/ssh-agent.sh
sshagent_init
#!/usr/bin/env python3
import boto3
import json
import uuid
import sys
from time import sleep
import backoff
from botocore import exceptions
if len(sys.argv) < 2 :
@alisade
alisade / amazon-eks-nodegroup-role.yaml
Last active November 24, 2019 02:39
instance profile for eks worker nodes
AWSTemplateFormatVersion: "2010-09-09"
Description: Amazon EKS - Node Group Role
Resources:
NodeInstanceRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
@alisade
alisade / sns-to-slack.js
Created March 28, 2018 00:35 — forked from benyanke/sns-to-slack.js
AWS Lambda function for forwarding SNS notifications to Slack
// By Ben Yanke
// Based on https://gist.github.com/benyanke/862e446e5a816551928d8acc2d98b752
// Handles CloudWatch alerts via SNS as Slack Attachments, instead of plaintext.
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...'; // put your webhook URL here// Added by Ben Yanke
@alisade
alisade / ec2_cloud.groovy
Last active March 29, 2018 00:01 — forked from halfb00t/ec2_cloud.groovy
Jenkins EC2 Plugin Configuration via Groovy
/*
* Configure the Jenkins EC2 Plugin via Groovy Script
* EC2 Plugin URL: https://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin
*/
import com.amazonaws.services.ec2.AmazonEC2
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder
import com.amazonaws.services.ec2.model.CreateKeyPairRequest
import com.amazonaws.services.ec2.model.CreateKeyPairResult
import com.amazonaws.services.ec2.model.KeyPair
import com.amazonaws.services.ec2.model.DeleteKeyPairRequest
@alisade
alisade / ec2_cloud.groovy
Created December 13, 2017 19:26 — forked from vrivellino/ec2_cloud.groovy
Jenkins EC2 Plugin Configuration via Groovy
/*
* Configure the Jenkins EC2 Plugin via Groovy Script
* EC2 Plugin URL: https://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin
*/
import hudson.model.*
import jenkins.model.*
import hudson.plugins.ec2.*
import com.amazonaws.services.ec2.model.InstanceType