Skip to content

Instantly share code, notes, and snippets.

// for
for (item in listOf(1, 2, 3)) print(item)
for (item: Int in ints) {
// ...
}
for (i in array.indices) {
print(array[i])
}
(0..10).forEach one@ {
(0..10).forEach two@ {
if (0 == 0) {
return@one
}
}
}
@whalemare
whalemare / report.sh
Last active October 13, 2020 09:43
Bash script for generate daily-report
#!/bin/bash
# Daily report bash script
# This generate daily-report file for project, where it .sh will be executed
# For use move it to your project folder and exec in terminal:
# +x ; ./report.sh
DEBUG=0
directoryName="reports"
getName() {
@whalemare
whalemare / commit-msg-redmine
Last active July 15, 2019 09:49
Add link to redmine ticket by working branch name
message=$(cat "$1")
currentBranch=$(git rev-parse --abbrev-ref HEAD)
currentBranch=$(echo "$currentBranch" | grep -o '[a-zA-Zа-яА-Я]\+-\d*')
echo "current ticket = $currentBranch"
countTrackerWords=$(echo "$message" | grep -w -c Tracker)
if [ $countTrackerWords == 0 ] && [ ! -z $currentBranch ]
then {
@whalemare
whalemare / RotationDelegate.java
Last active December 11, 2017 13:27
Rotation changes helper
package com.mgrmobi.kitwts.common.utils;
import android.app.Activity;
import android.content.Context;
import android.hardware.SensorManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.WindowManager;
@whalemare
whalemare / VerticalViewPager.kt
Created December 16, 2017 07:50
Vertical View Pager
package ru.werbary.tv1000play.mobile.view
import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
/**
private fun buildMultipartBody(filePaths: List<Uri>): MultipartBody.Builder {
val builder = MultipartBody.Builder().setType(MultipartBody.FORM)
filePaths.forEachIndexed { i, uri ->
val extension = "jpeg"
val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
crashlyticsLog(uri, extension, mimeType)
val file = getFileFromUri(uri)
@whalemare
whalemare / MarginItemDecoration.java
Created January 2, 2018 08:01
Margin Item Decoration for RecyclerView
package com.mgrsys.uberforwine.screen.base.recycler;
import android.content.res.Resources;
import android.graphics.Rect;
import android.support.annotation.DimenRes;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* Developed by Magora Team (magora-systems.com)
class TimberLinkingTree : Timber.Tree() {
private val CALL_STACK_INDEX = 4
private val ANONYMOUS_CLASS = Pattern.compile("(\\$\\d+)+$")
override fun log(priority: Int, tag: String, message: String, t: Throwable) {
val stackTrace = Throwable().stackTrace
if (stackTrace.size <= CALL_STACK_INDEX) {
throw IllegalStateException(
"Synthetic stacktrace didn't have enough elements: are you using proguard?")
}
@whalemare
whalemare / CalendarEventDelegate.kt
Created January 22, 2018 08:46
CalendarEventDelegate for create intent for pass it to app
/**
* Add event to calendars using pretty api
* @since 2018
* @author Anton Vlasov - whalemare
*/
class CalendarEventDelegate {
var title = ""
var description = ""
var startMillis = Long.MIN_VALUE