Skip to content

Instantly share code, notes, and snippets.

View indyfromoz's full-sized avatar
🏠
Working from home

Indrajit Chakrabarty indyfromoz

🏠
Working from home
View GitHub Profile
@ardakazanci
ardakazanci / CircularMainMenuGroup.kt
Created January 13, 2024 05:54
Circular Menu Group for jetpack compose
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
CircularMenuGroupTheme {
MainMenuCanvas()
}
}
}
@khalidx
khalidx / node-typescript-esm.md
Last active April 22, 2024 15:40
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@maulikhirani
maulikhirani / BoxShadow.kt
Created July 15, 2023 13:25
Helper extension to use drop shadow in Jetpack Compose
import android.graphics.BlurMaskFilter
import android.graphics.ColorMatrix
import android.graphics.ColorMatrixColorFilter
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.ClipOp
@hrules6872
hrules6872 / DragDropLazyColum.kt
Last active April 3, 2024 01:24
LazyColum Drag&Drop implementation in Jetpack Compose
/*
* Copyright (c) 2023. Héctor de Isidro - hrules6872
*
* 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
@chiragthummar
chiragthummar / BouncyClickable.kt
Created June 25, 2023 07:25
Increase user experience with bouncy click on any component of jetpack compose.
@OptIn(ExperimentalFoundationApi::class)
fun Modifier.bounceClickable(
dampingRatio: Float = 0.85f,
enabled: Boolean = true,
onClick: () -> Unit = {},
onDoubleClick: (() -> Unit)? = null,
onLongClick: (() -> Unit)? = null,
shape: Shape = RectangleShape,
useHapticFeedback: Boolean = true,
) = composed {
@oussama-dz
oussama-dz / ImagePicker.kt
Created June 20, 2023 08:16
basic image picker using kotlin and jetpack compose
@Composable
fun ImagePicker() {
var imageUri: Uri? by remember {
mutableStateOf(null)
}
val launcher =
rememberLauncherForActivityResult(contract = ActivityResultContracts.OpenDocument()) {
it?.let { uri ->
imageUri = uri
}
@johnkueh
johnkueh / helpers.ts
Last active June 19, 2023 04:22
openai-function-calling
import { ChatOpenAI } from 'langchain/chat_models/openai';
import { HumanChatMessage } from 'langchain/schema';
import { ZodSchema, z } from 'zod';
import zodToJsonSchema from 'zod-to-json-schema';
import { winstonLogger } from '../winston';
const logger = winstonLogger.child({ service: 'AIService' });
const chatOpenAIModel = new ChatOpenAI({
temperature: 0,
@rock3r
rock3r / EqualWidthComponentsRow.kt
Last active July 5, 2023 14:40
Compose Custom Layout: row of components, all made as wide as the widest one
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Sebastiano Poggi wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Seb
* ----------------------------------------------------------------------------
*/
package dev.sebastiano.bundel
@kfox
kfox / README.md
Last active December 4, 2023 11:08
TCP echo server for Node.js

TCP echo server for Node.js

Usage

  1. Make sure you have a modern-ish version of Node.js installed.
  2. Type npx https://gist.github.com/kfox/1280c2f0ee8324067dba15300e0f2fd3
  3. Connect to it from a client, e.g. netcat or similar: nc localhost 9000
import android.graphics.Matrix
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween