This file contains 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
(function (paramsMap) { | |
function loadScript(url, callback) { | |
var script = document.createElement("script") | |
script.type = "text/javascript"; | |
if (script.readyState) { //IE | |
script.onreadystatechange = function () { | |
if (script.readyState == "loaded" || script.readyState == "complete") { |
This file contains 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
#!/usr/bin/env bash | |
# usage: $(assume_role <role_arn>) | |
assume_role(){ | |
local role=$1 | |
local session_name=${2:-"$(date +'%Y%m%d%h%H%M%S')"} | |
aws sts assume-role --role-arn "$role" --role-session-name "$session_name" \ | |
--query 'Credentials.{AWS_ACCESS_KEY_ID:AccessKeyId, AWS_SECRET_ACCESS_KEY:SecretAccessKey, AWS_SESSION_TOKEN:SessionToken}' \ | |
| jq -r 'to_entries[]|("export "+.key+"="+.value)' | |
} |
This file contains 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
#!/usr/bin/env bash | |
aws_region=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/[a-z]$//') | |
aws configure set default.region $aws_region | |
aws configure set default.output json | |
describe_instances(){ | |
local filter=$1 | |
local region=${2:-$aws_region} | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$filter" "Name=instance-state-name,Values=running" \ |
This file contains 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
# Retry a command up to a specific numer of times until it exits successfully, | |
# with exponential back off. | |
# | |
# $ retry 5 echo Hello | |
# Hello | |
# | |
# $ retry 5 false | |
# Retry 1/5 exited 1, retrying in 1 seconds... | |
# Retry 2/5 exited 1, retrying in 2 seconds... | |
# Retry 3/5 exited 1, retrying in 4 seconds... |
This file contains 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 org.apache.activemq.ActiveMQConnection; | |
import org.apache.activemq.ActiveMQConnectionFactory; | |
import org.apache.activemq.ActiveMQMessageProducer; | |
import org.apache.activemq.ActiveMQSession; | |
import org.apache.activemq.command.ActiveMQMessage; | |
import org.apache.activemq.command.ActiveMQQueue; | |
import org.apache.activemq.util.IdGenerator; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; |
This file contains 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 static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | |
import java.io.IOException; | |
import java.net.MalformedURLException; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import java.net.URL; | |
import java.nio.file.FileSystem; | |
import java.nio.file.FileSystems; | |
import java.nio.file.Files; |
This file contains 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 com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.core.type.TypeReference; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.time.Duration; | |
import java.time.LocalDate; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import java.util.List; |
This file contains 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
{"schemaVersion": 1, "label": "Runtime", "message": "13.3 ms ±", "color": "blue"} |
This file contains 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 decimal | |
import textwrap | |
# demo division 1/998001 | |
decimal.setcontext(decimal.Context(prec=9999)) | |
one = decimal.Decimal(1) | |
denom = decimal.Decimal(998001) | |
res = str(one/denom) | |
print(textwrap.fill(res, 100)) | |
nums = textwrap.wrap(res[4:], 3) |
This file contains 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 | |
import subprocess | |
if __name__ == '__main__': | |
# located in project folder .idea/dataSources.xml | |
with open('dataSources.xml', 'r') as f: | |
data = f.read() | |
data_sources = sorted(re.findall(r".*data-source.*name=\"(.*?)\".*uuid=\"(.*?)\".*", data)) | |
for name, uuid in data_sources: | |
command = f'security find-generic-password -l "IntelliJ Platform DB — {uuid}" -w' |