Skip to content

Instantly share code, notes, and snippets.

View amir1376's full-sized avatar
💭
Programming

AmirHossein Abdolmotallebi amir1376

💭
Programming
View GitHub Profile
@amir1376
amir1376 / WindowsRegistry.kt
Created April 9, 2024 06:23
Read / Write to windows registry with Kotlin
object WindowsRegistry {
/**
* Set value in registry
*
* @param path full path including HKey and path
* @param key key name or `null` for default
*/
fun setValueInRegistry(
path: String,
@amir1376
amir1376 / CenterZoomLayoutManager.java
Created April 20, 2021 09:46
List Scaled Center Item
java```
public class CenterZoomLayoutManager extends LinearLayoutManager { private final float mShrinkAmount = 0.15f; private final float mShrinkDistance = 0.9f; public CenterZoomLayoutManager(Context context) { super(context); } public CenterZoomLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } @Override public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { int orientation = getOrientation(); if (orientation == VERTICAL) { int scrolled = super.scrollVerticallyBy(dy, recycler, state); float midpoint = getHeight() / 2.f; float d0 = 0.f; float d1 = mShrinkDistance * midpoint; float s0 = 1.f; float s1 = 1.f - mShrinkAmount; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); float childMidpoint = (getDecoratedBottom(child) + getDecoratedTop(child)) / 2.f; float d = Math.min(d1, Math.abs(midpoint - childMidpoint)); float scale = s0 + (s1 - s0) * (d - d0) / (d1 - d0); child.setScaleX
@amir1376
amir1376 / snake.js
Created December 28, 2020 21:12
snake js
var Snake = (function () {
const INITIAL_TAIL = 4;
var fixedTail = true;
var intervalID;
var tileCount = 10;
var gridSize = 400/tileCount;
@amir1376
amir1376 / Average.java
Created June 29, 2020 11:56
simpe average in java for beginners
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Average {
public static void main(String[] args) {
ArrayList<Student> students= new ArrayList<>();
Student amir = new Student(12.0, 12.5, 19.0, 20.0);
Student ali = new Student(15.5, 13.25, 14.0, 5.5);