Skip to content

Instantly share code, notes, and snippets.

Avatar

Hosein Hamedi hoseinit

  • Munich
View GitHub Profile
@hoseinit
hoseinit / PersianNumber
Created Nov 19, 2017
Persian Number Convertor
View PersianNumber
public class PersianNumbers {
private static String[] persianNumbers = new String[]{ "۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹" };
public static String toPersianNumber(String text) {
if (text.length() == 0)
return "";
String out = "";
int length = text.length();
@hoseinit
hoseinit / BaseFragmet.java
Created Nov 15, 2017 — forked from philandrews100/BaseFragmet.java
Fragment Implementation
View BaseFragmet.java
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.retrofitrealm.controllers.MainActivityInterface;
@hoseinit
hoseinit / fade_in.xml
Created Nov 1, 2017
Animation list of Android
View fade_in.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" >
</alpha>
@hoseinit
hoseinit / Git clean deleted Branches
Last active Feb 12, 2018
Remove Merged Branches from Local Git
View Git clean deleted Branches
// Gitlab projects
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
//or on Github projects:
git branch --merged | grep -v '*' | xargs git branch -d
@hoseinit
hoseinit / RoundImageView.Java
Created Oct 15, 2017 — forked from ManzzBaria/RoundImageView.Java
Make ImageView as circle view
View RoundImageView.Java
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
@hoseinit
hoseinit / CircleTransform.java
Created Oct 14, 2017
This class is used to display the profile image in circular fashion.
View CircleTransform.java
//https://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
public class CircleTransform extends BitmapTransformation {
public CircleTransform(Context context) {
super(context);
}
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return circleCrop(pool, toTransform);
}
@hoseinit
hoseinit / View SharedPrefs
Created Sep 26, 2017
view android sharedpreferences from SHELL
View View SharedPrefs
adb shell
run-as your.app.id
chmod 777 shared_prefs/your.app.id_preferences.xml
exit # return to default user
cp /data/data/your.app.id/shared_prefs/your.app.id_preferences.xml /sdcard
@hoseinit
hoseinit / rerun.py
Created Jun 16, 2017
Rerun python script
View rerun.py
import subprocess
import time
while True:
print("Launching process..")
p = subprocess.Popen("python3 script.py", shell=True)
p.wait()
print("Process crashed. Restarting in 2 seconds..")
time.sleep(2)
@hoseinit
hoseinit / install-and-configure-shadowsocks-server.sh
Created Apr 16, 2017 — forked from euyuil/install-and-configure-shadowsocks-server.sh
Shadowsocks: Server installation and configuration on Ubuntu 14.04.
View install-and-configure-shadowsocks-server.sh
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install -y python-gevent python-pip python-m2crypto supervisor
sudo pip install shadowsocks
sudo mkdir -p touch /etc/shadowsocks
@hoseinit
hoseinit / DialogFragmentCallback.md
Created Nov 16, 2015 — forked from Joev-/DialogFragmentCallback.md
Getting results from DialogFragment to calling Fragment using Callbacks
View DialogFragmentCallback.md

##Getting results from DialogFragments to another Fragment.

When setting up the DialogFragment make a call to Fragment.setTargetFragment()
Then from DialogFragment you can access the main fragment with Fragment.getTargetFragment()
Use interfaces to provide the required actions to the calling Fragment.

##Example code.

###AddFriendDialogFragment - Calls back to calling fragment.

You can’t perform that action at this time.