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
# turns a port and an IP array into a string like: "127.0.0.1:4430,10.33.0.6:4430" | |
function ip_list_with_ports { | |
local port=$1 | |
shift 1 | |
local ips=("$@") | |
for ((i=0; i<${#ips[@]}; i++)); do | |
echo -n "${ips[$i]}:$port" | |
if [ $i != $(( ${#ips[@]} - 1 )) ]; then | |
echo -n "," | |
fi |
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 datetime | |
# Python date and datetime in ISO 8601 format | |
# Example local timezone is UTC+12 | |
isodate = datetime.datetime.now().date().isoformat() | |
print(isodate) # prints 2022-06-07 - Current timezone | |
isodateutc = datetime.datetime.utcnow().date().isoformat() | |
print(isodateutc) # prints 2022-06-06 - UTC timezone |
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
FROM debian:11 | |
# Add a user my-user (1001) to group my-group (gid 1001) | |
RUN addgroup --system --gid 1001 my-group && \ | |
adduser --system --gid 1001 --uid 1001 --disabled-password my-user | |
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
package io.github.ktchernov | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelProvider | |
import javax.inject.Provider | |
abstract class ViewModelFactory <VM : ViewModel> protected constructor( | |
private val provider: Provider<VM>) : ViewModelProvider.Factory { |
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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
setSupportActionBar(toolbar) | |
val packages | |
= packageManager.getInstalledApplications(PackageManager.GET_META_DATA) |
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/sh | |
./gradlew wrapper --gradle-version $1 --distribution-type all |
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 | |
#set -ex | |
branch_name=$(git symbolic-ref -q HEAD) | |
branch_name=${branch_name##refs/heads/} | |
branch_name=${branch_name:-HEAD} | |
if [[ $branch_name = "HEAD" ]]; then | |
echo "Cannot work with a detached head" |
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/sh | |
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d |
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
<!-- 0. Make sure you've got API level 25 sources | |
1. Open ~/Library/Preferences/AndroidStudioPreview3.0/options/jdk.table.xml (macOS path) | |
2. Find "API 26 Platform" section | |
3. Replace the <sourcePath> XML node in this section with the following (again, macOS path) --> | |
<sourcePath> | |
<root type="composite"> | |
<root type="simple" url="file://$USER_HOME$/Library/Android/sdk/sources/android-25" /> | |
</root> | |
</sourcePath> |
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
package io.github.ktchernov.play_aroundapp.views; | |
/** | |
* Copyright 2017 Konstantin Tchernov | |
* | |
* Adapted from: ControllableAppBarLayout by Bartosz Lipinski and | |
* Marcel Pintó Biescas | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. |
NewerOlder