Skip to content

Instantly share code, notes, and snippets.

@bennyhuo
bennyhuo / init.gradle.kts
Last active April 29, 2024 15:53
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)
}
}
}
@jaredsburrows
jaredsburrows / RxBus1.java
Last active March 16, 2023 10:44
RxBus for RxJava 1 and RxJava 2
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@lazee
lazee / UriDecodeDirective.java
Created August 18, 2015 19:26
A Freemarker directive that does url decoding
package freemarker;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import java.io.IOException;
@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* Copyright (C) 2014 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
@stormzhang
stormzhang / adbwifi.sh
Created August 28, 2014 00:52
shell script for adb wifi
#!/bin/bash
#Modify this with your IP range
MY_IP_RANGE="192\.168\.1"
#You usually wouldn't have to modify this
PORT_BASE=5555
#List the devices on the screen for your viewing pleasure
adb devices
@yidongnan
yidongnan / TestClassLoader.java
Last active August 29, 2015 14:05
自定义Tomcat的ClassLoader
/**
* User: Michael Chen
* Email: yidongnan@gmail.com
* Date: 2014/8/12
* Time: 16:33
*/
public class TestClassLoader extends org.apache.catalina.loader.WebappClassLoader {
public TestClassLoader(ClassLoader parent) {
this.setParentClassLoader(parent);
@wangjiezhe
wangjiezhe / unzip3_gbk.py
Last active February 17, 2021 14:00
解决zip文件中文乱码问题
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
unzip3_gbk.py: Deal with zip files using encoding GB2312/GBK/GB18030
"""
import os
# import sys
import argparse
import zipfile
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing