Skip to content

Instantly share code, notes, and snippets.

View kyze8439690's full-sized avatar
📱
Working

Yang Hui kyze8439690

📱
Working
View GitHub Profile
@yaraki
yaraki / EdgeToEdge.kt
Last active March 29, 2024 07:49
Edge-to-edge setup for Android app in a backward-compatible manner.
/*
* Copyright (C) 2022 The Android Open Source Project
*
* 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
@sunnyyoung
sunnyyoung / echo.py
Created August 13, 2022 05:15
Minimal UDP echo tool.
#! /usr/bin/env python
# Client and server for udp (datagram) echo.
#
# Usage: udpecho -s [port] (to start a server)
# or: udpecho -c host [port] <file (client)
import sys
from socket import *
@wuyisheng
wuyisheng / FileDownloadUtil.java
Last active March 4, 2019 03:02
A HttpURLConnection download example for android
package org.yeshen.download;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.annotation.WorkerThread;
import android.util.Log;
@BurningAXE
BurningAXE / HtmlTextEditor
Last active August 8, 2021 09:42
An Android component that allows to show AND edit text in HTML format using a WebView
import android.content.Context;
import android.util.AttributeSet;
import android.util.Xml;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class HtmlTextEditor extends WebView {
class JsObject {
@zhanghai
zhanghai / NaturalOrderComparator.java
Created June 16, 2018 09:57
Java Comparator for Natural Sort Order
/*
* Copyright (c) 2018 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
*
* 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
@n1lesh
n1lesh / LinearGradientDrawable.java
Last active January 30, 2022 03:57
Android Gradient Toolbar and Statusbar
RelativeLayout layout = (RelativeLayout) findViewById(R.id.rel);
GradientDrawable drawable = new GradientDrawable();
drawable.setColors(new int[] {
Color.parseColor("#FFF6B7"),
Color.parseColor("#F6416C")
});
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
drawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT);
@jhansche
jhansche / watch-fds.sh
Created October 28, 2016 20:39
Simple script to monitor the number open file descriptors for an Android application.
#!/bin/sh
# Usage: ./watch-fds.sh <application_id> [delay_secs = 5]
APP_ID=${1:?missing application id}
DELAY=$(( ${2:-5} ))
DEVICE_LIMIT=$(( $(adb shell ulimit -n) ))
WARN_THRESHOLD=$(( ${DEVICE_LIMIT} / 3 ))
echo "Will warn at ${WARN_THRESHOLD}"
@fffaraz
fffaraz / dns.c
Created May 29, 2016 05:58
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon (m00n.silv3r@gmail.com)
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
@harrane
harrane / RatingBarVectorFix.java
Created April 8, 2016 08:54
A temp fix for using vector drawable with RatingBar Raw
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;

最终实现效果:

  1. 无版本概念,任何本地文件均可增量升级到最新.服务器不用管理多版本
  2. 内存小,100M文件升级时只占用500KB内存.

使用流程:

  1. 制作新版本,上传HTTP File Server.
  2. Client自动计算差异,下载差异,合并差异.
  3. done!

#0.起源