Skip to content

Instantly share code, notes, and snippets.

@denis-ismailaj
denis-ismailaj / LabelledCheckBox.kt
Last active November 13, 2024 19:38
LabelledCheckBox in Jetpack Compose
@Composable
fun LabelledCheckBox(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit),
label: String,
modifier: Modifier = Modifier
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
@hector6872
hector6872 / FixedColumnsHorizontalGridLayoutManager.kt
Created January 27, 2021 18:32
Android FixedColumnsHorizontalGridLayoutManager
class FixedColumnsHorizontalGridLayoutManager(context: Context?, spanCountVertical: Int, private var columns: Int, orientation: Int, reverseLayout: Boolean) :
GridLayoutManager(context, spanCountVertical, orientation, reverseLayout) {
private val safeWidth: Int
get() = width - paddingRight - paddingLeft
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams = spanLayoutSize(super.generateDefaultLayoutParams())
override fun generateLayoutParams(context: Context, attrs: AttributeSet): RecyclerView.LayoutParams = spanLayoutSize(super.generateLayoutParams(context, attrs))
override fun generateLayoutParams(layoutParams: ViewGroup.LayoutParams): RecyclerView.LayoutParams = spanLayoutSize(super.generateLayoutParams(layoutParams))
@hector6872
hector6872 / Modules.kt
Last active April 23, 2025 12:23
Yet another Koin killer :)
/*
* Copyright (c) 2022. Héctor de Isidro - hector6872
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@nikgalushko
nikgalushko / git-stats.sh
Created August 12, 2020 06:44
git-stats
for name in $(git log --pretty="%ae%n%cn" | sort | uniq); do
git log \
--author "$name" \
--pretty=tformat: --numstat |
awk -v name="$name" '{
add += $1; subs += $2; loc += $1 - $2
} END {
if (loc != 0)
printf "[%s] Lines: +\033[32m%s\033[0m -\033[31m%s\033[0m; Total: %s\n", name, add, subs, loc
}'
@DRSchlaubi
DRSchlaubi / zip.kt
Last active April 16, 2022 17:33
Kotlin zip utils
/*
* Copyright 2020 Michael Rittmeister
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@javierguzman
javierguzman / TermsAndConditions.tsx
Created July 19, 2020 13:40
Example of terms and conditions in different languages using markdown and dynamic import
import React, { useEffect, useState } from 'react';
import i18next from 'i18next';
import { getCurrentLanguage } from '@Utils/language';
import ReactMarkdown from 'react-markdown';
import Loader from '@Loader';
type MarkdownContent = string | undefined;
const TermsAndConditions = (): JSX.Element => {
const currentLanguage = getCurrentLanguage(i18next.languages); // it returns i18next.languages[0] -> 'es', 'fr', 'en' etc.
const [getTermsAndConditions, setTermsAndConditions] = useState<MarkdownContent>(undefined);
@danieldogeanu
danieldogeanu / RenameGitBranch.md
Last active March 1, 2025 12:41
How to rename your Git master branch to main.

To rename your Git master branch to main, you must do the following steps:

  1. Navigate to your repository in the command line and issue the following commands: - git branch -m master main - git push -u origin main

  2. Change your default branch on GitHub by going to your GitHub repository in your browser, and navigate to Settings > Branches and click on the dropdown and switch from master to main and click Update (this will only show if you have two or more branches). The main branch is now your default branch.

  3. Update the tracking of the branch from your command line with the following command: - git branch -u origin/main main

@seunggabi
seunggabi / semantic-branch-names.md
Last active May 9, 2025 03:03
Semantic Branch Names

Semantic Branch Names

See how a minor change to your branch name style can make you a better programmer.

Format: <type>/#<issueNumber>-<alias>

Example

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class AbsolutefitLayourManager extends GridLayoutManager {
@Mun0n
Mun0n / CircleEdgeTreatment
Created March 20, 2020 17:16
Custom edge treatment to create a circle edge in a shape
import com.google.android.material.shape.EdgeTreatment
import com.google.android.material.shape.ShapePath
import kotlin.math.atan
import kotlin.math.sqrt
class CircleEdgeTreatment
(
private val radius: Float,
private val cradleRoundedCornerRadius: Float
) :