Skip to content

Instantly share code, notes, and snippets.

View Anthonyeef's full-sized avatar
🎯
🐈

Yifen Wu Anthonyeef

🎯
🐈
View GitHub Profile
@waylybaye
waylybaye / Measure.swift
Last active March 12, 2024 14:09
SwiftUI view render performance Indicator
// Created by Baye Wayly on 2020/3/13.
// Copyright © 2020 Baye. All rights reserved.
import SwiftUI
struct Measure<Content: View>: View {
@State var cost: TimeInterval = 0
var content: Content
init(@ViewBuilder builder: () -> Content) {
<?php
define('BOT_TOKEN', 'XXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXX'); // place bot token of your bot here
function checkTelegramAuthorization($auth_data) {
$check_hash = $auth_data['hash'];
unset($auth_data['hash']);
$data_check_arr = [];
foreach ($auth_data as $key => $value) {
$data_check_arr[] = $key . '=' . $value;
@magneticflux-
magneticflux- / LiveDataUtils.kt
Last active February 3, 2023 19:08
Helpful Android-Kotlin LiveData utilities
//--------------------------------
// CHECK THE COMMENTS FOR UPDATES!
//--------------------------------
/*
* Copyright (C) 2017 Mitchell Skaggs, Keturah Gadson, Ethan Holtgrieve, Nathan Skelton, Pattonville School District
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@chrisbanes
chrisbanes / code.kt
Last active August 10, 2023 10:46
Night Mode inflater
/*
* Copyright 2017 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@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)
@brownsoo
brownsoo / android-architecture-components-proguard.txt
Created July 25, 2017 09:17
Proguard setting for Android Architecture Components
## Android architecture components: Lifecycle
# LifecycleObserver's empty constructor is considered to be unused by proguard
-keepclassmembers class * implements android.arch.lifecycle.LifecycleObserver {
<init>(...);
}
# ViewModel's empty constructor is considered to be unused by proguard
-keepclassmembers class * extends android.arch.lifecycle.ViewModel {
<init>(...);
}
# keep Lifecycle State and Event enums values
@ravibhure
ravibhure / git_rebase.md
Last active April 3, 2024 08:38
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

// 2018.5.11更新: 减少了swap
function qSort(compare) {
var swap = (p1, p2) => {
var tmp = this[p1];
this[p1] = this[p2];
this[p2] = tmp;
}
var sortRange = (start, end) => {
var midValue = this[start];
var p1 = start + 1, p2 = end - 1;
@nickbutcher
nickbutcher / avd_bundle.xml
Last active December 31, 2021 01:03
An example of the Android xml bundle format for creating an AnimatedVectorDrawable. See https://plus.google.com/+NickButcher/posts/A8KKxnJdg4r
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@mcxiaoke
mcxiaoke / SimpleLineLayout.java
Created August 27, 2015 07:47
SimpleLineLayout
package com.mcxiaoke.next.samples;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
public class SimpleLineLayout extends ViewGroup {
public static final String TAG = SimpleLineLayout.class.getSimpleName();