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 jenkins.model.* | |
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.common.* | |
import com.cloudbees.plugins.credentials.domains.* | |
import com.cloudbees.plugins.credentials.impl.* | |
import org.jenkinsci.plugins.plaincredentials.* | |
import org.jenkinsci.plugins.plaincredentials.impl.* | |
import hudson.util.Secret | |
def changeAwsKeys = { cred_id, access_key, secret_key -> | |
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( |
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
with open('myfile.txt') as f: | |
lines = [ line.rstrip() for line in f ] |
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
score = np.array([70, 60, 50, 10, 90, 40, 80]) | |
name = np.array(['Ada', 'Ben', 'Charlie', 'Danny', 'Eden', 'Fanny', 'George']) | |
sorted_name = name[np.argsort(score)] # an array of names in ascending order of their scores | |
print(sorted_name) # ['Danny' 'Fanny' 'Charlie' 'Ben' 'Ada' 'George' 'Eden'] | |
original_name = sorted_name[np.argsort(np.argsort(score))] | |
print(original_name) # ['Ada' 'Ben' 'Charlie' 'Danny' 'Eden' 'Fanny' 'George'] | |
%timeit name[np.argsort(score)] |
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 math | |
def is_prime(n): | |
assert n > 1, 'Input must be larger than 1' | |
if n % 2 == 0 and n > 2: | |
return False | |
return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2)) | |
arr = np.array(range(2,100)) | |
non_prime_mask = [not is_prime(n) for n in a] | |
prime_arr = np.ma.MaskedArray(data=arr, mask=non_prime_mask) |
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
arr = np.array(range(1000)).reshape(2,5,2,10,-1) | |
print(arr[:,:,:,3,2] == arr[...,3,2]) | |
# [[[ True, True], | |
# [ True, True], | |
# [ True, True], | |
# [ True, True], | |
# [ True, True]], | |
# [[ True, True], | |
# [ True, True], | |
# [ True, True], |
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
python3 -m site |
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
# app.py | |
# Defining a class named Sum | |
class Sum: | |
# defining a function sumoftwo | |
# this function will be called in a static method | |
# Creating static method here only | |
@staticmethod | |
def sumoftwo(a, b): |
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 +x | |
dscacheutil -flushcache | |
sudo killall -HUP mDNSResponder |
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
Host $NAME | |
Hostname $EC2_IP | |
User $EC2_USERNAME | |
ForwardAgent yes | |
ProxyCommand ssh <internal ip> nc %h %p 2> /dev/null | |
IdentityFile $LOCATION_OF_AWS_PEM_KEY | |
access jenkins | |
ssh -f <internal ip> -L 8443:<external ip>:443 -N |
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 re | |
def replace(string, substitutions): | |
substrings = sorted(substitutions, key=len, reverse=True) | |
regex = re.compile('|'.join(map(re.escape, substrings))) | |
return regex.sub(lambda match: substitutions[match.group(0)], string) |