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/local/bin/bash | |
echo 'Enter service name (default is common):' | |
read SERVICE_NAME || exit 1 | |
if test -z "$SERVICE_NAME"; then | |
SERVICE_NAME='common'; fi | |
echo 'Enter account name:' | |
read ACCOUNT_NAME || exit 1 |
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
KEYCHAIN='keychain_baz' | |
# https://www.unix.com/man-page/osx/1/security/ | |
security delete-keychain "$KEYCHAIN" | |
security create-keychain -P "$KEYCHAIN" | |
if test $? -ne 0; then | |
echo 'Create keychain error!'; exit 1; fi | |
SERVICE_NAME='service_foo' |
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
SERVICE_NAME='service_foo' | |
ACCOUNT_NAME='account_bar' | |
PASSWORD_VALUE='password_bar' | |
security delete-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" &> /dev/null | |
# Add a generic password item to the default keychain. | |
security add-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" -w "$PASSWORD_VALUE" -T '' | |
if test $? -ne 0; then |
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
SERVICE_NAME='service_foo' | |
ACCOUNT_NAME='account_bar' | |
PASSWORD_VALUE='password_bar' | |
security delete-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" &> /dev/null | |
# Add a generic password item to the default keychain without warning. | |
security add-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" -w "$PASSWORD_VALUE" | |
if test $? -ne 0; then |
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
sealed interface ExtraType<T : Any> | |
object Str : ExtraType<String> | |
object Int32 : ExtraType<Int> | |
object Int64 : ExtraType<Long> | |
private fun <T : Any> Bundle.getOrNull(type: ExtraType<T>, key: String): T? { | |
if (!containsKey(key)) return null | |
return when (type) { | |
Str -> getString(key, null) as T? | |
Int64 -> getLong(key, -1) as T |
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/local/bin/bash | |
if test $# -ne 2; then | |
echo "Script needs 2 arguments: ENCRYPTED, KEY. But actual is $#!"; exit 1; fi | |
ENCRYPTED="$1" | |
KEY="$2" | |
for it in ENCRYPTED KEY; do | |
if test -z "${!it}"; then echo "Argument \"$it\" is empty!"; exit 1; fi; done |
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/local/bin/bash | |
if test $# -ne 2; then | |
echo "Script needs 2 arguments: ENCRYPTED, KEY. But actual is $#!"; exit 1; fi | |
ENCRYPTED="$1" | |
KEY="$2" | |
for it in ENCRYPTED KEY; do | |
if test -z "${!it}"; then echo "Argument \"$it\" is empty!"; exit 1; fi; done |
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/local/bin/bash | |
if test $# -ne 4; then | |
echo "Script needs 4 arguments: ISSUER, KEYSTORE, KEYSTORE_PASSWORD KEY_ALIAS. But actual is $#!"; exit 1; fi | |
KEYSTORE_TYPE='pkcs12' | |
ISSUER="$1" | |
KEYSTORE="$2" | |
KEYSTORE_PASSWORD="$3" | |
KEY_ALIAS="$4" |
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
#!/bin/bash | |
VARIANT='snapshot' | |
gradle clean && \ | |
gradle "lib:assemble${VARIANT}MavenMetadata" && \ | |
gradle "lib:assemble${VARIANT}Jar" && \ | |
gradle "lib:assemble${VARIANT}Pom" | |
if test $? -ne 0; then |
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
// https://en.wikipedia.org/wiki/Geometric_series | |
/** | |
* @param a is coefficient | |
* @param r is the common ratio | |
* @return sum of a*r.pow(n) + a*r.pow(n - 1) + ... + a*r.pow(m - 1) + a*r.pow(m) | |
*/ | |
fun getSumOfGeometricSeries( | |
a: Int = 1, | |
r: Double = 10.0, |
NewerOlder