Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View JoaquimLey's full-sized avatar
👨‍💻
Product oriented, software perfectionist and developer

Joaquim Ley JoaquimLey

👨‍💻
Product oriented, software perfectionist and developer
View GitHub Profile
@JoaquimLey
JoaquimLey / create_new_ssh_key.md
Last active April 4, 2024 11:07
Generating a new SSH key and adding it to the ssh-agent

Generating a new ssh-key

Open Terminal. Paste the text below, substituting in your GitHub email address.

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This creates a new ssh key, using the provided email as a label

Generating public/private rsa key pair.

@JoaquimLey
JoaquimLey / restart-ssh-gist.sh
Created August 10, 2016 23:02
Restart ssh-agent
killall ssh-agent; eval `ssh-agent`
@JoaquimLey
JoaquimLey / github_multiple-accounts.md
Last active April 30, 2023 22:17
How to Work with GitHub and Multiple Accounts

Step 1 - Create a New SSH Key

We need to generate a unique SSH key for our second GitHub account.

ssh-keygen -t rsa -C "your-email-address"

Be careful that you don't over-write your existing key for your personal account. Instead, when prompted, save the file as id_rsa_COMPANY. In my case, I've saved the file to ~/.ssh/id_rsa_work.

Step 2 - Attach the New Key

/************************************************
* Insets Section *
************************************************/
/*******************
* Utility methods *
*******************/
fun View.applySystemBarPaddingInsets() {
this.doOnApplyWindowInsets { view, insets, padding, _ ->
@JoaquimLey
JoaquimLey / IntroVideoView.java
Created April 12, 2017 16:02
A simple VideoView subclass that displays in full screen while keeping the aspect ration
/**
* Subclass of VideoView to enable video scaling
* CustomAttribute: "scaleType": "normal", "centerCrop", "fill"
* <p>
* Add this stylable:
* <declare-styleable name="IntroVideoView">
* <attr name="scaleType" format="integer">
* <flag name="normal" value="0" />
* <flag name="centerCrop" value="1" />
* <flag name="fill" value="2" />
@JoaquimLey
JoaquimLey / debug_over_wifi.md
Last active October 7, 2021 00:18
Debug over WIFI

How to Debug with your device over WIFI

  1. Connect the device via USB and make sure debugging is enabled.

  2. Run adb tcpip 5555

  3. Find the IP address

MACOS: adb shell ip route

import androidx.recyclerview.widget.ListAdapter
/**
* Creates a copy of itself if no new [data] is passed, this is used
* so [ListAdapter] correctly diffs and animates. :facepalms:
*/
fun <T> List<T>.refresh(data: List<T> = this): List<T> {
return mutableListOf<T>().apply { addAll(data) }.toList()
}
// Extension function
fun TabLayout.setupWithViewPager2(
viewPager: ViewPager2,
callback: (TabLayout.Tab, Int) -> Unit
) {
TabLayoutMediator(this, viewPager) { tab, position ->
callback.invoke(tab, position)
}.attach()
}
open class RecyclerViewMarginItemDecoration(
private val sizeInDp: Int = 16,
private val isTop: Boolean = false
) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
super.getItemOffsets(outRect, view, parent, state)
if (isTop) {
if (parent.getChildAdapterPosition(view) == 0) {
outRect.top = sizeInDp.toPx()
fun RecyclerView.applyToolbarNavigationViewWithFabInsets() {
applyVerticalInsets()
clipToPadding = false
addItemDecoration(RecyclerViewToolbarItemDecoration())
addItemDecoration(RecyclerViewBottomNavigationViewFabItemDecoration())
}