Skip to content

Instantly share code, notes, and snippets.

View bthnorhan's full-sized avatar
🏠
Working from home

Batuhan Orhan bthnorhan

🏠
Working from home
  • Konya
View GitHub Profile
@bthnorhan
bthnorhan / AuthyToOtherAuthenticator.md
Created April 23, 2023 21:58 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My guess is that Brian used the

@bthnorhan
bthnorhan / clean_code.md
Created April 29, 2021 08:15 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@bthnorhan
bthnorhan / node_nginx_ssl.md
Created February 29, 2020 08:05 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@bthnorhan
bthnorhan / Fragment.java
Last active July 25, 2019 14:40
SnapHelper for recyclerview
SnapHelper startSnapHelper = new StartSnapHelper();
startSnapHelper.attachToRecyclerView(yourRecyclerView);
@bthnorhan
bthnorhan / PermissionHelper.java
Last active May 15, 2019 12:06
Permission Helper
public class PermissionHelper {
private static final int PERMISSION_REQUEST = 195;
public static void checkPermissions( Context context ) {
if (ActivityCompat.checkSelfPermission( context, permission.WRITE_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED
|| ActivityCompat.checkSelfPermission( context, permission.CAMERA ) != PackageManager.PERMISSION_GRANTED
|| ActivityCompat.checkSelfPermission( context, permission.ACCESS_WIFI_STATE ) != PackageManager.PERMISSION_GRANTED
|| ActivityCompat.checkSelfPermission( context, permission.ACCESS_NETWORK_STATE ) != PackageManager.PERMISSION_GRANTED ) {
ActivityCompat.requestPermissions( (Activity) context,
@bthnorhan
bthnorhan / AESUtil.java
Created May 15, 2019 11:47
Aes Encryption Technique
final class AESUtil {
private static final String TAG = "AESCrypt";
private static final String AES_MODE = "AES/CBC/PKCS7Padding";
private static final String CHARSET = "UTF-8";
private static final String HASH_ALGORITHM = "SHA-256";
private static final byte[] ivBytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
private AESUtil( ) { }
private static SecretKeySpec generateKey( final String password ) throws NoSuchAlgorithmException, UnsupportedEncodingException {
@bthnorhan
bthnorhan / NotificationHelper.java
Created September 21, 2018 08:25
NotificationHelper
public class NotificationHelper {
private Context context;
private NotificationManager notificationManager;
private NotificationCompat.Builder builder;
private static final String NOTIFICATION_CHANNEL_ID = "48752";
private static final int REQUEST_CODE = 546;
public NotificationHelper(Context context) {
context = context;
@bthnorhan
bthnorhan / BaseFragment.java
Last active February 21, 2020 11:38
Fragment Structure
public abstract class BaseFragment extends Fragment {
protected FragmentListener listener;
protected abstract int getFragmentId();
protected abstract void init();
protected abstract void handlers();
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
public class TypefaceUtil {
public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) throws Exception {
try {
final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);
final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
defaultFontTypefaceField.setAccessible(true);
defaultFontTypefaceField.set(null, customFontTypeface);
} catch (Exception e) {
throw new Exception("Bu fontu -> " + customFontFileNameInAssets + " bunun yerine -> " + defaultFontNameToOverride + " kullanamazsınız." );
}
@bthnorhan
bthnorhan / OkHttpAsyncTask.java
Last active September 14, 2018 19:59
OkHttpAsyncTask
public class OkHttpAsyncTask extends AsyncTask<Void, Void, String> {
private OkHttpAsyncTaskListener okHttpAsyncTaskListener;
private OkHttpClient okHttpClient;
private Request request;
public OkHttpAsyncTask(Request request, OkHttpAsyncTaskListener okHttpAsyncTaskListener) {
okHttpClient = new OkHttpClient();
this.request = request;
this.okHttpAsyncTaskListener = okHttpAsyncTaskListener;