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 | |
| certs=`openssl s_client -servername $1 -host $1 -port 443 -showcerts </dev/null 2>/dev/null | sed -n '/Certificate chain/,/Server certificate/p'` | |
| rest=$certs | |
| while [[ "$rest" =~ '-----BEGIN CERTIFICATE-----' ]] | |
| do | |
| cert="${rest%%-----END CERTIFICATE-----*}-----END CERTIFICATE-----" | |
| rest=${rest#*-----END CERTIFICATE-----} | |
| echo `echo "$cert" | grep 's:' | sed 's/.*s:\(.*\)/\1/'` | |
| echo "$cert" | openssl x509 -pubkey -noout | | |
| openssl rsa -pubin -outform der 2>/dev/null | |
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 | |
| set -o pipefail -e | |
| usage=" | |
| $(basename "$0") [-h] [-e/d -p=\"password\" -f=\"path/to/file\"] | |
| where: | |
| -h --help show this help text |
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
| task getDeviceIp { | |
| doLast { | |
| new ByteArrayOutputStream().withStream { os -> | |
| exec { | |
| commandLine(android.getAdbExe()) | |
| args('shell', 'ip', 'addr', 'show', 'wlan0', ' | grep', '\'inet \'', '| cut -d\' \'', '-f6', '|cut -d/', '-f1') | |
| standardOutput = os | |
| } | |
| ext.deviceIp = os.toString().trim() | |
| } |
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
| package com.ivan.store | |
| import android.content.SharedPreferences | |
| import androidx.core.content.edit | |
| interface KeyValueStore { | |
| fun write(key: String, value: Any?) | |
| fun <T> read(key: String): T? |
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
| //Put this into buildSrc/src/android-applicaiton-convention.gradle.kts | |
| @file:Suppress("UnstableApiUsage") | |
| import com.android.build.api.dsl.ApplicationDefaultConfig | |
| plugins { | |
| id("com.android.application") | |
| id("org.gradle.android.cache-fix") | |
| kotlin("android") |
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
| // Where hierarchy tree looks like Animal->Dog->Husky | |
| public static void main(String[] args) { | |
| List<? super Dog> animals = new ArrayList<Animal>(); //Compatible type | |
| List<? super Dog> dogs = new ArrayList<Dog>(); //Compatible type | |
| List<? super Dog> huskies = new ArrayList<Husky>(); //Incompatible type | |
| contravariance(new ArrayList<Animal>()); //Ok | |
| contravariance(new ArrayList<Dog>()); //OK | |
| contravariance(new ArrayList<Husky>()); //Compiler error | |
| } |