Skip to content

Instantly share code, notes, and snippets.

View eneim's full-sized avatar
😀
the simple, the best

Nam Nguyen eneim

😀
the simple, the best
View GitHub Profile
@eneim
eneim / themes.xml
Created November 19, 2014 08:57
official themes.xml from Android-21 API. I create a gist here for easily looking up Android theme's attribute names
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
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
@eneim
eneim / MyApplication.java
Created July 24, 2015 03:13
Sample Application class
package com.example.app;
import android.app.Application;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AndroidThreeTen.init(this); // init the lib here
@eneim
eneim / README.md
Created July 9, 2022 13:20 — forked from tuanchauict/README.md
Attach a stopwatch to Leetcode

This script attaches a stopwatch into the toolbar of Leetcode's problem page.

The feature is simple:

  • Start/Stop the stopwatch
  • Auto start after 2 mins remaining on the problem
  • Restore unstopped stopwatch for the next visit on the problem

Use this script with any browser extension allowing attaching JS to the page. (I use User JavaScript and CSS)

@eneim
eneim / BadgeTabLayout.java
Last active June 10, 2022 11:27
A custom TabLayout with badge support for Tabs
package im.ene.lab.android.widgets;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.util.AttributeSet;
@eneim
eneim / flowWithPrevious.kt
Created January 22, 2022 13:48
A Flow emits a pair of the original Flow's latest value and its previous value.
/**
* Given a Flow A, returns a [Flow] that emits a pair of the latest value emitted by A (as the
* second value of the pair), and the previous value emitted before (as the first value of the
* pair).
*
* Example
* ```
* val originalFlow = flowOf(1, 2, 3, 4)
* originalFlow.flowWithPrevious().collect { (l, r) ->
* println("Left: $l, Right: $r")
@eneim
eneim / README.md
Created March 2, 2021 06:37 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@eneim
eneim / ffmpeg_twitter.sh
Created May 26, 2019 12:15
ffmpeg script to encode video for Twitter
ffmpeg -i 'input' -vf scale=720:-1 -c:v libx264 -crf 18 -preset veryslow -c:a copy 'output'
@eneim
eneim / c-ss-arousel-pure-css-carousels.markdown
Created March 27, 2019 02:05
c(ss)arousel - pure CSS carousels 🎪🐎🎪🐎🎪🐎

c(ss)arousel - pure CSS carousels 🎪🐎🎪🐎🎪🐎

Pure CSS "carousel"(heavy emphasis on the quotes there)

Leveraging use of how elements behave in the DOM in combination with features of CSS makes implementing a pure CSS "carousel" relatively trivial.

Read more in a blog post here Enjoy!

A Pen by Jhey on CodePen.

@eneim
eneim / YourFragment.kt
Created February 27, 2019 10:55 — forked from rylexr/YourFragment.kt
Android navigation bar style with animation
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = DataBindingUtil.inflate(inflater, R.layout.your_fragment, container, false)
binding.homeAction.setOnClickListener { select(R.id.home_action) }
binding.likesAction.setOnClickListener { select(R.id.likes_action) }
binding.searchAction.setOnClickListener { select(R.id.search_action) }
binding.profileAction.setOnClickListener { select(R.id.profile_action) }
return binding.root
}
fun select(id: Int) {
@eneim
eneim / Java7LegacyVideoViewHelper.java
Created September 15, 2018 01:03
Java 7 compatible
/*
* Copyright (c) 2018 Nam Nguyen, nam@ene.im
*
* 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