Skip to content

Instantly share code, notes, and snippets.

View Assassinss's full-sized avatar
🎯
Focusing

ShangjingZhu Assassinss

🎯
Focusing
View GitHub Profile
@bennyhuo
bennyhuo / init.gradle.kts
Last active April 10, 2024 11:15
How to config mirrors for repositories in Gradle without changing the source code of your project?
fun RepositoryHandler.enableMirror() {
all {
if (this is MavenArtifactRepository) {
val originalUrl = this.url.toString().removeSuffix("/")
urlMappings[originalUrl]?.let {
logger.lifecycle("Repository[$url] is mirrored to $it")
this.setUrl(it)
}
}
}
@sindresorhus
sindresorhus / esm-package.md
Last active April 24, 2024 09:47
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
/*
* Copyright (C) 2018 Square, 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
@uilianries
uilianries / serial_port.c
Created January 22, 2018 00:33
Read Serial port on Windows
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
const char reboot = 'R';
const char ack = 6;
HANDLE hSerial = NULL;
DCB dcbSerialParams = {0};
COMMTIMEOUTS timeouts = {0};
@Pulimet
Pulimet / AdbCommands
Last active April 24, 2024 07:17
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@nickbutcher
nickbutcher / MainActivity.java
Last active August 20, 2021 16:15
A quick sample of the new physics-based animation library added in Support Library 25.3.0 docs: https://developer.android.com/reference/android/support/animation/package-summary.html output: https://twitter.com/crafty/status/842055117323026432
/*
* 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
@TWiStErRob
TWiStErRob / OkHttpProgressGlideModule.java
Last active January 31, 2024 13:37
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@flyingzl
flyingzl / android_naviator_react-native.js
Last active September 26, 2017 06:32
Use Navigator component in react-native
'use strict';
var React = require('react-native');
var {
AppRegistry,
View,
Navigator,
Text,
BackAndroid,
StyleSheet
@jcdom
jcdom / ReboundInterpolator.java
Last active January 10, 2017 05:00
An interpolator where the rate of change starts out quickly, decelerates and then bounces at the end.
import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Interpolator;
/**
* An interpolator where the rate of change starts out quickly,
* decelerates and then bounces at the end.
*
* Created by jcdom on 02/04/15.
*/
@waylife
waylife / LauncherUtil
Created March 14, 2015 09:42
ShortcutUtil
import java.util.List;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.text.TextUtils;
/**