Skip to content

Instantly share code, notes, and snippets.

View namchuai's full-sized avatar

NamH namchuai

View GitHub Profile
@gohilbhagirath90
gohilbhagirath90 / circle.xml
Last active June 15, 2019 10:20
list item with left side half circle android
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<solid android:color="@android:color/white" />
<size
android:height="50dp"
android:width="50dp" />
</shape>
@bruno78
bruno78 / scrim.xml
Created October 22, 2018 02:01
A scrim view to be added to the drawable folder, giving visibility to texts on white screen images
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="-90"
android:startColor="#00000000"
android:centerColor="#00000000"
android:endColor="#4d000000"
android:type="linear" />
</shape>
@benwalio
benwalio / uuid.jinja
Created August 11, 2021 16:45
create a basic uuid using jinja2
{%- set ns = namespace(uuid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') %}
{%- set ns.new_uuid = '' %}
{%- for x in ns.uuid %}
{%- set ns.new_uuid = [ns.new_uuid,(x | replace('x', [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f'] | random ))] | join %}
{%- endfor %}
{{ ns.new_uuid }}
@aubricus
aubricus / License
Last active June 20, 2023 01:19
Python Progress Bar
Copyright 2020 Aubrey Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH
@nesquena
nesquena / SnappyRecyclerView.java
Last active June 21, 2023 23:04
Snap-to-Center RecyclerView Extension
// From: http://stackoverflow.com/a/37816976
public class SnappyRecyclerView extends RecyclerView {
// Use it with a horizontal LinearLayoutManager
// Based on http://stackoverflow.com/a/29171652/4034572
public SnappyRecyclerView(Context context) {
super(context);
}
@madhums
madhums / install-android-emulator-brew-macos.md
Last active September 14, 2023 07:07
installing android emulator using cli on a mac

In your command line

brew install android-sdk --cask
sdkmanager "emulator"
sdkmanager "platform-tools"
sdkmanager "system-images;android-26;google_apis;x86_64"
avdmanager create avd -n NAME -k "system-images;android-26;google_apis;x86_64" # the one that you use above
@n0m0r3pa1n
n0m0r3pa1n / BottomSheetExtensions.kt
Last active October 2, 2023 01:53
Bottom sheet dialog with expanding and fullscreen display
fun Fragment.showBottomSheetDialog(
@LayoutRes layout: Int,
@IdRes textViewToSet: Int? = null,
textToSet: String? = null,
fullScreen: Boolean = true,
expand: Boolean = true
) {
val dialog = BottomSheetDialog(context!!)
dialog.setOnShowListener {
val bottomSheet: FrameLayout = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet) ?: return@setOnShowListener
@ftvs
ftvs / PhonecallReceiver.java
Last active October 11, 2023 10:05
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@alkavan
alkavan / hardhat-openzeppelin-project.md
Created December 12, 2020 10:37
Hardhat and OpenZeppelin project bootstrap for Ethereum contract development

Install Instructions

Install Hardhat

npm install --save-dev hardhat

Initiate a new Hardhat project (in empty directory)

npx hardhat
@slightfoot
slightfoot / MovingBgTextureView.java
Last active December 13, 2023 09:42
Playing around with SurfaceView/TextureView. See edit history.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.text.TextPaint;
import android.util.AttributeSet;