Skip to content

Instantly share code, notes, and snippets.

@zinwalin
zinwalin / AndroidManifest.xml
Created January 27, 2023 00:47 — forked from bjoernQ/AndroidManifest.xml
Creating a System Overlay (Always on Top over all Apps) in Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.mobilej.overlay"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application android:label="SystemOverlay" >
<activity
@zinwalin
zinwalin / brightness-utils.java
Created July 14, 2022 02:33 — forked from rakkang/brightness-utils.java
【Android】修改系统亮度
/**
* 获取当前系统亮度
**/
public int getGlobalScrennBrightness(Context context) {
int nowBrightnessValue = -1;
ContentResolver resolver = context.getContentResolver();
try {
nowBrightnessValue = android.provider.Settings.System.getInt(resolver,
Settings.System.SCREEN_BRIGHTNESS);
} catch (Exception e) {
@zinwalin
zinwalin / 跨程序数据共享_ContentProvider.md
Created July 13, 2022 15:08 — forked from dearsq/跨程序数据共享_ContentProvider.md
[组件_ContentProvider] 跨程序数据共享 #Android

基本概念

用法两种:

  1. 使用现有的ContentProvider来读取和操作相应程序中的数据
  2. 创建自己的内容提供器给我们的程序的数据提供外部访问接口

ContentResolver 使用方法

ContentResolver resolver = Context.getContentResolver(); resolver.insert //增 resolver.delete //删

@zinwalin
zinwalin / SystemPropertiesProxy
Created June 30, 2022 02:22 — forked from crossle/SystemPropertiesProxy
Use the reflection invoke SystemProperites
import java.lang.reflect.Method;
public class SystemPropertiesProxy {
/**
* This class cannot be instantiated
*/
private SystemPropertiesProxy() {
}
@zinwalin
zinwalin / default nginx configuration file
Created June 12, 2022 04:34 — forked from xameeramir/default nginx configuration file
The default nginx configuration file inside /etc/nginx/sites-available/default
## Personal note: Muslims are not terrorists and I humbly request my engineering community to help end racism.
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@zinwalin
zinwalin / postman-pre-request.js
Created June 7, 2022 12:53 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@zinwalin
zinwalin / CRC32.swift
Created April 28, 2022 06:14 — forked from antfarm/CRC32.swift
CRC32 checksum generation in a few lines of Swift 5. https://en.wikipedia.org/wiki/Cyclic_redundancy_check#CRC-32_algorithm
class CRC32 {
static var table: [UInt32] = {
(0...255).map { i -> UInt32 in
(0..<8).reduce(UInt32(i), { c, _ in
(c % 2 == 0) ? (c >> 1) : (0xEDB88320 ^ (c >> 1))
})
}
}()
@zinwalin
zinwalin / crc32.swift
Created April 28, 2022 06:06 — forked from MaddTheSane/crc32.swift
crc32 implemented in Swift
//
// crc32.swift
// SuperSFV
//
// Created by C.W. Betts on 8/23/15.
//
//
/* crc32.swift -- compute the CRC-32 of a data stream
Copyright (C) 1995-1998 Mark Adler
Copyright (C) 2015 C.W. "Madd the Sane" Betts
@zinwalin
zinwalin / DataExtensions.swift
Created April 27, 2022 08:32 — forked from bpolania/DataExtensions.swift
Swift Extensions for Data, Int, UInt8, UInt16, and UInt32 types
// MIT License
// Copyright (c) 2018 Boris Polania
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@zinwalin
zinwalin / UInt_extension.swift
Created April 27, 2022 08:31 — forked from kimjj81/UInt_extension.swift
Convert UInt to UInt8(byte) Array in swift.
protocol UIntToBytesConvertable {
var toBytes: [UInt8] { get }
}
extension UIntToBytesConvertable {
func toByteArr<T: BinaryInteger>(endian: T, count: Int) -> [UInt8] {
var _endian = endian
let bytePtr = withUnsafePointer(to: &_endian) {
$0.withMemoryRebound(to: UInt8.self, capacity: count) {
UnsafeBufferPointer(start: $0, count: count)