Skip to content

Instantly share code, notes, and snippets.

@antirez
antirez / twitter_logo_nn.c
Created January 29, 2025 21:40
A small program producing an approximated ASCII art of the Twitter logo via a tiny NN
#include <stdio.h>
#include <math.h>
#define F float
F f[]={-.1,-.1,1.7,.8,-.11,-6,.4,-.6,.15,-.3,.22,-3.1,-.1,-.06,3.2,.57,-1.1,19,-176,-4.8,-7.2,43,-86,40,48,65,34,803,39,9.65,-17,-33,-33,16,1167,63,-23,41,-22,9,.56,-.08,4.76,-8,-.28,.63,-1182,-7.27,26.6,-1213,198,5.3,-8.25,38.4,.22,-.78,-903,-7.4,-.26,.42,47.5,33.7,36.5,-184,14.5,-90,3};F o[15];F R(F A,F U){o[0]=A;o[1]=U;F a=0;int k=2,m=3,n=0,z=0,l=1;for(int j=0;j<67;j++){if(j==18)n=2,z=3,m=7,l=-17;if(j==60)n=8,l=-59;if((j+l)%m){a+=f[j]*o[n+(j+z)%m];}else{o[k++]=(F)1/(1+exp(-(a+f[j])));a=0;}}return o[14];}int main(){for(int i=0;i<2201;i++){putchar(R(i%55,i/55-5)>.5?58:32);if(!(i%55))putchar(10);}}
<style name="TopSheet_DialogAnimation">
  <item name="android:windowEnterAnimation">@anim/slide_out_from_top</item>
  <item name="android:windowExitAnimation">@anim/slide_back_to_top</item>
</style>

slide_out_from_top

@gotev
gotev / NavigationBottomBarSectionsStateKeeperWorkaround.kt
Last active June 12, 2023 16:08
JetPack Bottom Bar Navigation with Sections State
package jetpack.navigation.workaround
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.navigation.NavController
import androidx.navigation.ui.setupActionBarWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.lang.ref.WeakReference
@Jthomas54
Jthomas54 / okhttp3.WebviewCookieHandler.java
Last active May 29, 2019 04:59
Cookie jar that handles syncing okhttp cookies with Webview cookie manager
import android.webkit.CookieManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@yanngx
yanngx / FragmentArgumentDelegate.kt
Last active January 19, 2023 09:26
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
package /* YOUR PROJECT PACKAGE */.utils;
import android.support.annotation.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
@josh-burton
josh-burton / androidmanifest.xml
Created May 3, 2017 02:07
Prevent TouchWiz from surrounding your app icon in a frame
<!-- Prevents TouchWiz from surrounding your app icon in a frame -->
<!-- Add to your manifest inside the application tag -->
<meta-data
android:name="com.samsung.android.icon_container.has_icon_container"
android:value="true"/>
@Robyer
Robyer / maven-publish-helper-usage.gradle
Last active February 20, 2025 14:37
Gradle script for publishing Android library with sources and javadoc to Maven repository using maven-publish plugin.
// You can use maven-publish-helper.gradle script without changes and even share it between multiple
// modules. Just place the maven-publish-helper.gradle file in the root directory of your project,
// then apply it at the bottom of your module's build.gradle file like this:
// ...content of module's build.gradle file...
apply from: '../maven-publish-helper.gradle'
publishing {
publications {
@FrancoisBlavoet
FrancoisBlavoet / GammaEvaluator.java
Last active November 17, 2020 07:03
Correct color interpolation
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import static java.lang.Math.pow;
public class GammaEvaluator implements TypeEvaluator {
private static final GammaEvaluator instance = new GammaEvaluator();
/**