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
| curl --header 'Authorization: token INSERTACCESSTOKENHERE' \ | |
| --header 'Accept: application/vnd.github.v3.raw' \ | |
| --remote-name \ | |
| --location https://api.github.com/repos/owner/repo/contents/path | |
| # Example... | |
| TOKEN="INSERTACCESSTOKENHERE" | |
| OWNER="BBC-News" | |
| REPO="responsive-news" |
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 json,requests,pprint | |
| gh_url = "https://api.github.com" | |
| username = 'wehappyfew' | |
| # a token is needed for 2 Factor Auth, otherwise only Name/Pass | |
| custom_token = 'blablablablablablabla' # a custom personal token from GitHub | |
| repo_name = 'your_repo_name' | |
| new_default_branch = 'something' # this is going to change every time | |
| #encode to JSON |
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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "codedeploy:RegisterApplicationRevision", | |
| "codedeploy:GetApplicationRevision" | |
| ], | |
| "Resource": [ |
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
| def create_jenkins_xml_config(github_username =None, | |
| repo_name = None, | |
| juser = None, | |
| jpass = None, | |
| j_xml_url =None, | |
| filename = None, | |
| new_branch_name = None): | |
| """ | |
| The function reads the jenkins config.xml , saves it and changes the branch name. | |
| [Then, the file with the updated branch name is ready to be posted back.] |
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
| __author__ = 'wehappyfew' | |
| import requests | |
| def create_new_jenkins_job(j_url, j_port, new_job_name, j_user, j_pass): | |
| """ | |
| Create a new jenkins job | |
| :param j_url: eg http://mysite.com | |
| :param j_port: eg 8686 [8080 is jenkin's default] |
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
| def check_if_process_is_alive(process_name): | |
| """ | |
| Enter a process name and check if it is in the running processes on a UNIX system | |
| :param process_name: | |
| :return: | |
| """ | |
| import os | |
| from subprocess import check_output |
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
| __author__ = 'wehappyfew' | |
| # http://boto.readthedocs.org/en/latest/ref/rds.html#boto.rds.RDSConnection.create_dbinstance_read_replica | |
| from AWS_project import us_east_1 | |
| import boto.rds, os, sys | |
| if os.name == "nt": #if I run it on WIN | |
| from AWS_project import aws_secret_access_key, aws_access_key_id | |
| RDSconn = boto.rds.connect_to_region(us_east_1, |
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
| __author__ = 'wehappyfew' | |
| import sys,os,pprint | |
| # check the sys.path before I add my directory | |
| print("1: -- ",sys.path) | |
| if os.name == "posix": # check if the script runs on Linux | |
| # If I comment it out, it will throw ImportError | |
| # This path should always be appended on runtime, |
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
| def make_POST(live, arg1, arg2, variable_arg): | |
| """ | |
| """ | |
| import requests | |
| payload = { | |
| "arg1_key" : arg1, | |
| "arg2_key" : arg2 | |
| } |
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
| from my_AWS_credentials import aws_access_key_id,aws_secret_access_key | |
| import boto.route53 | |
| from boto.route53.record import ResourceRecordSets | |
| import boto.ec2 | |
| import itertools | |
| EC2conn = boto.ec2.connect_to_region(region_name = "us-east-1", | |
| aws_access_key_id = aws_access_key_id, | |
| aws_secret_access_key = aws_secret_access_key) | |
| def fetch_host_ips(EC2conn, tag, state): |