Skip to content

Instantly share code, notes, and snippets.

View LeonDevLifeLog's full-sized avatar
:octocat:
Focusing

Leon LeonDevLifeLog

:octocat:
Focusing
  • nanjing,jiangsu China
View GitHub Profile
@vganin
vganin / FlexRow.kt
Last active April 28, 2024 06:08
Jetpack Compose simple flex-wrap container
@Composable
fun FlowRow(
horizontalGap: Dp = 0.dp,
verticalGap: Dp = 0.dp,
alignment: Alignment.Horizontal = Alignment.Start,
content: @Composable () -> Unit,
) = Layout(content = content) { measurables, constraints ->
val horizontalGapPx = horizontalGap.toPx().roundToInt()
val verticalGapPx = verticalGap.toPx().roundToInt()
@dockerlead
dockerlead / Tutorial.md
Created November 16, 2020 05:04
Wireguard on CentOS 7/8

Set Up Your Own WireGuard VPN Server on CentOS

This tutorial is going to show you how to set up your own WireGuard VPN server on CentOS. WireGuard is made specifically for the Linux kernel. It runs inside the Linux kernel and allows you to create fast, modern, and secure VPN tunnel. TL;DR

Prerequisites

This tutorial assumes that the VPN server and VPN client are both running CentOS operating system.

Step 1: Install WireGuard on CentOS Server and Desktop

Log into your CentOS server, then run the following commands to install WireGuard.

# CentOS 8
@liuguangw
liuguangw / make_cert.md
Last active May 13, 2024 14:35
使用openssl制作自定义CA、自签名ssl证书

自签名ssl证书生成

生成CA私钥

# 创建文件夹 ca 保存Ca相关
mkdir ca
cd ca
#创建私钥 (建议设置密码)
openssl genrsa -des3 -out myCA.key 2048
@kevin-barrientos
kevin-barrientos / CheckBoxTriStates.java
Last active March 30, 2023 19:06
Android custom checkbox that displays three states (unchecked, undefined, checked)
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.CheckBox;
import android.widget.CompoundButton;
/**
* Base on https://stackoverflow.com/a/40939367/3950497 answer.
@bmaupin
bmaupin / open-source-sso.md
Last active April 11, 2024 09:36
Comparison of some open-source SSO implementations

ⓘ This list is not meant to be exhaustive and is not guaranteed to be maintained. See the comments for updates and alternative options.

(Items in bold indicate possible concerns)

Keycloak WSO2 Identity Server Gluu CAS OpenAM Shibboleth IdP
OpenID Connect/OAuth support yes yes yes yes yes yes
Multi-factor authentication yes yes yes yes yes yes
Admin UI yes yes yes yes yes no
OpenJDK support yes yes partial² yes
@rharter
rharter / SharedPreferenceLiveData.kt
Last active March 19, 2023 08:15
Creates LiveData objects that observe a value in SharedPreferences while they have active listeners.
import android.arch.lifecycle.LiveData
import android.content.SharedPreferences
abstract class SharedPreferenceLiveData<T>(val sharedPrefs: SharedPreferences,
val key: String,
val defValue: T) : LiveData<T>() {
private val preferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == this.key) {
value = getValueFromPreferences(key, defValue)
@nblair
nblair / nexus-repo-manager-privilege-example.groovy
Last active November 13, 2023 17:54
A groovy script to create Content Selectors, privileges, and roles programmatically via the Nexus Repository Manager 3 Scripting API.
import org.sonatype.nexus.common.entity.*
import org.sonatype.nexus.security.*
import org.sonatype.nexus.security.authz.*
import org.sonatype.nexus.selector.*
import com.google.common.collect.ImmutableMap
// use container.lookup to fetch internal APIs we need to use
def selectorManager = container.lookup(SelectorManager.class.name)
def securitySystem = container.lookup(SecuritySystem.class.name)
@harv
harv / cross_and_static_compile_shadowsocks-libev.sh
Last active February 18, 2024 12:05
cross & static compile shadowsocks-libev
#!/bin/sh
# cross & static compile shadowsocks-libev
PCRE_VER=8.41
PCRE_FILE="http://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$PCRE_VER.tar.gz"
MBEDTLS_VER=2.6.0
MBEDTLS_FILE="https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz"
@Robyer
Robyer / maven-publish-helper-usage.gradle
Last active May 14, 2024 05:41
Gradle script for publishing Android library with sources and javadoc to Maven repository using maven-publish plugin.
// You can use maven-publish-helper.gradle script without changes and even share it between multiple
// modules. Just place the maven-publish-helper.gradle file in the root directory of your project,
// then apply it at the bottom of your module's build.gradle file like this:
// ...content of module's build.gradle file...
apply from: '../maven-publish-helper.gradle'
publishing {
publications {
@alexmiragall
alexmiragall / NestedScrollWebView.java
Last active March 1, 2024 01:45
NestedWebView compatible with CoordinatorLayout
package com.tuenti.nestedwebscrollview;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.NestedScrollingChildHelper;
import android.support.v4.view.NestedScrollingParent;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ScrollerCompat;