Skip to content

Instantly share code, notes, and snippets.

View rafayali's full-sized avatar
🚀

Rafay Ali rafayali

🚀
View GitHub Profile
@manuelvicnt
manuelvicnt / ProvideViewModels.kt
Last active June 7, 2024 22:31
Scope ViewModels to Composables
// PLEASE, READ
//
// This is a way to scope ViewModels to the Composition.
// However, this doesn't survive configuration changes or procress death on its own.
// You can handle all config changes in compose by making the activity handle those in the Manifest file
// e.g. android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode">
//
// This is just an exploration to see what's possible in Compose. We don't encourage developers to copy-paste
// this code if they don't fully understand the implications of it and if this actually solves the use case to solve.
import 'package:flutter/material.dart';
import '../extensions/extensions.dart';
typedef AnimatedGridBuilder<T> = Widget Function(
BuildContext, T item, AnimatedGridDetails details);
class AnimatedGrid<T> extends StatelessWidget {
/// An animated grid the animates when the items change sort.
const AnimatedGrid({
@nicoplv
nicoplv / ReimportAsset.cs
Last active May 18, 2018 10:06
Automatize the reimportation of working file from a folder ended with '~' (a demo video is available here https://youtu.be/S-yyK3Fzw3c)
using UnityEngine;
using UnityEditor;
using System.Text.RegularExpressions;
using System.IO;
public class ReimportAsset : MonoBehaviour
{
#region MenuItem Methods
[MenuItem("Assets/Reimport from ~ &R", false, priority = 40)]
@nickbutcher
nickbutcher / IconView.kt
Last active July 30, 2023 22:05
A prototype implementation of a shadow effect inspired by the Google Play Games app (https://play.google.com/store/apps/details?id=com.google.android.play.games).
/*
* Copyright 2017 Google Inc.
*
* 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 distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@alan-rodriguez
alan-rodriguez / CodeJam.md
Created October 18, 2017 22:31
Kotlin Code Jam Exercise

Kotlin Code Jam

If you're familiar with Material Design, you've probably seen Chris Banes's Cheesesquare sample app. It illustrates the implementation of basic Material Design concepts using Material Components for Android (formerly known as the Design Support Library).

Convert Cheesesquare to Kotlin

Download Android Studio 3.0 and use the wizard to create a new Android project. Be sure to select "Include Kotlin Support"! Then try to port the Cheesesquare app to Kotlin. I suggest trying to do so from scratch on your own, but you can use Android Studio to convert Java code to Kotlin. It does not always result in the most idiomatic Kotlin, so check the output and try to make it more idiomatic.

Bonus: Use Bottom Navigation

Get rid of the Navigation Drawer and use BottomNavigationView to handle the navigation in MainActivity.

@nielsutrecht
nielsutrecht / RsaExample.java
Created December 28, 2016 14:13
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
@sandcastle
sandcastle / GeoData.cs
Created May 4, 2016 14:30
A Unity 3D behaviour for Geo location lookup via IP address
using UnityEngine;
using System.Collections;
using Newtonsoft.Json;
/// <summary>
/// The Geo data for a user.
///
/// http://ip-api.com/docs/api:json
///
@parmentf
parmentf / GitCommitEmoji.md
Last active June 28, 2024 10:47
Git Commit message Emoji
@lmarkus
lmarkus / README.MD
Last active June 6, 2024 17:15
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...

@robertwahler
robertwahler / DynamicLayoutGroup.cs
Last active January 20, 2022 00:41
Unity 3D layout group switches orientation automatically between landscape and portrait layouts so it either acts like a VerticalLayoutGroup or a HorizontalLayoutGroup.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
using System.Collections.Generic;
namespace SDD.UI {
/// <summary>
/// Layout group switches orientation automatically between landscape and