Skip to content

Instantly share code, notes, and snippets.

View amrro's full-sized avatar
🏍️

Amr Elghobary amrro

🏍️
  • 11:52 (UTC +03:00)
View GitHub Profile
@amrro
amrro / postgresql-install-maocs.md
Last active August 9, 2022 19:37
Install Postress on Macos

postgresql

  • If you want specefic version, append @<version-number> to postgresql. e.g: postgresql@13

  • Install postgresql using command line: brew install postgresql Note: look through installation caveat for more tips. More details below.

  • brew will automatically run initdb after installation. initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@

  • If you need to have postgresql@ first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/postgresql/bin:$PATH"' &gt;&gt; ~/.zshrc

@amrro
amrro / PickContactContract.java
Last active March 31, 2020 18:54
Pick contact ctonract from the official docs.
/**
* An {@link ActivityResultContract} to request the user to pick a contact from the contacts
* app.
* <p>
* The result is a {@code content:} {@link Uri}.
*
* @see ContactsContract
*/
public static final class PickContact extends ActivityResultContract<Void, Uri> {
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
@amrro
amrro / ConnectivityMonitor.java
Created August 16, 2017 21:44
Network monitoring class using Android architecture components
package xyz.android.amrro.example;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.OnLifecycleEvent;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
@amrro
amrro / Load.java
Last active March 7, 2016 15:33
Two switches within android activity, and button to click to get the final result.
package com.weathers.amro.tests;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;