Skip to content

Instantly share code, notes, and snippets.

View MostafaGazar's full-sized avatar

Mostafa Gazar MostafaGazar

View GitHub Profile
import torch
from torch.nn import Module
from torch.nn import Sequential
from torch.nn import Conv2d, Dropout2d, MaxPool2d, ReLU, UpsamplingNearest2d
# Based on https://github.com/divamgupta/image-segmentation-keras/blob/master/keras_segmentation/models/unet.py#L19
class UNetMini(Module):
def __init__(self, num_classes):
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(
new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
private final Paint underlayPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG);
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@MostafaGazar
MostafaGazar / AutoSizeMVPDialogFragment.kt
Last active March 24, 2018 15:10
Build tablet friendly Android apps
abstract class AutoSizeMVPDialogFragment : DialogFragment() {
private val isLargeScreen
get() = resources.getBoolean(R.bool.device_wide_tall)
init {
this.setStyle(DialogFragment.STYLE_NO_TITLE, 0)
}
override fun getTheme() = if (isLargeScreen) R.style.ThemeOverlay_AppCompat_Dialog else R.style.Theme_AppCompat_Light_NoActionBar
@MostafaGazar
MostafaGazar / BaseHomeEnabledActivity.java
Created September 19, 2015 09:52
HomeEnabled Activity
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
/**
* @author Mostafa Gazar <mmegazar@gmail.com>
*/
@MostafaGazar
MostafaGazar / MaterialColorPalette.java
Last active December 25, 2016 10:37
MaterialColorPalette
/*
* Copyright 2014 Mostafa Gazar
*
* 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
@MostafaGazar
MostafaGazar / SvgMaskedImageView.java
Last active April 30, 2022 07:48
Based on https://github.com/MostafaGazar/CustomShapeImageView, Custom shape ImageView using PorterDuffXfermode and SVGs as masks
/*
* Copyright 2014 Mostafa Gazar
*
* 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