jq will sort (-S
) the whole file (.
) and compare STDOUT (<()
) with diff
diff <(jq -S . A.json) <(jq -S . B.json)
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) |
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)] |
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli | |
KEY_ID=alias/my-key | |
SECRET_BLOB_PATH=fileb://my-secret-blob | |
SECRET_TEXT="my secret text" | |
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob | |
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target | |
encrypt-text: |
Tags: | |
- Key: Name | |
Value: | |
!Join ['_', [ ec2, "Fn::ImportValue" : {"Fn::Sub":'${BaseStackName}-Environment'}, test2]] | |
#This will create a name tag with value: ec2_<yourValueFromOtherStack>_test2 |
jq will sort (-S
) the whole file (.
) and compare STDOUT (<()
) with diff
diff <(jq -S . A.json) <(jq -S . B.json)
# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions. | |
def find(key, dictionary): | |
for k, v in dictionary.iteritems(): | |
if k == key: | |
yield v | |
elif isinstance(v, dict): | |
for result in find(key, v): | |
yield result | |
elif isinstance(v, list): |
#!/usr/bin/env python3 | |
''' | |
Program: s3_full_delete.py | |
Author: https://github.com/vsx-gh | |
Created: 20170920 | |
Program finds S3 objects with delete markers and deletes all versions | |
of those objects. |
If you use Amazon AWS for nearly anything, then you are probably familiar with KMS, the Amazon Key Management Service.
KMS is a service which allows API-level access to cryptographic primitives without the expense and complexity of a full-fledged HSM or CloudHSM implementation. There are trade-offs in that the key material does reside on servers rather than tamper-proof devices, but these risks should be acceptable to a wide range of customers based on the care Amazon has put into the product. You should perform your own diligence on whether KMS is appropriate for your environment. If the security profile is not adequate, you should consider a stronger product such as CloudHSM or managing your own HSM solutions.
The goal here is to provide some introductory code on how to perform envelope encrypt a message using the AWS KMS API.
KMS allows you to encrypt messages of up to 4kb in size directly using the encrypt()/decrypt() API. To exceed these limitations, you must use a technique called "envelope encryptio
Simple collection of Groovy scripts to help me maintain some Jenkins systems.
See also https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
So, it has been an interesting journey, but time to remove git-lfs. Here follows a summary of the approach I used to safely remove git-lfs,
git lfs uninstall
git lfs ls-files
git rm --cached
for each file