Skip to content

Instantly share code, notes, and snippets.

View hoseinit's full-sized avatar

Hosein Hamedi hoseinit

  • PAYBACK GmbH
  • Munich
View GitHub Profile
@hoseinit
hoseinit / DialogFragmentCallback.md
Created November 16, 2015 12:46 — forked from Joev-/DialogFragmentCallback.md
Getting results from DialogFragment to calling Fragment using Callbacks

##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.

@hoseinit
hoseinit / install-and-configure-shadowsocks-server.sh
Created April 16, 2017 15:47 — forked from euyuil/install-and-configure-shadowsocks-server.sh
Shadowsocks: Server installation and configuration on Ubuntu 14.04.
#!/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 / rerun.py
Created June 16, 2017 19:42
Rerun python script
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 / View SharedPrefs
Created September 26, 2017 09:25
view android sharedpreferences from SHELL
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 / CircleTransform.java
Created October 14, 2017 06:02
This class is used to display the profile image in circular fashion.
//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 / RoundImageView.Java
Created October 15, 2017 09:31 — forked from ManzzBaria/RoundImageView.Java
Make ImageView as circle view
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 / Git clean deleted Branches
Last active February 12, 2018 08:31
Remove Merged Branches from Local Git
// 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 / fade_in.xml
Created November 1, 2017 09:17
Animation list of Android
<?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 / BaseFragmet.java
Created November 15, 2017 10:13 — forked from philandrews100/BaseFragmet.java
Fragment Implementation
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 / PersianNumber
Created November 19, 2017 14:34
Persian Number Convertor
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();