Skip to content

Instantly share code, notes, and snippets.

View NashLegend's full-sized avatar
🤑
I may be slow to respond.

NashLegend NashLegend

🤑
I may be slow to respond.
View GitHub Profile
@NashLegend
NashLegend / cloudSettings
Last active November 2, 2020 06:04
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-11-02T06:04:48.458Z","extensionVersion":"v3.4.3"}
@NashLegend
NashLegend / explanation.md
Created May 25, 2017 10:33 — forked from masak/explanation.md
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <jnthn@jnthn.net>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@NashLegend
NashLegend / AssetsCompiler.Java
Created February 27, 2017 14:34
AssetsCompiler
public class AssetsCompiler {
public static void main(String[] args) {
rReact("drawable-xhdpi");
}
public static void rReact(String path) {
File source = new File(path);
File dest = new File("out/d.txt");
@NashLegend
NashLegend / Cleaner.Java
Last active March 7, 2017 03:06
Clean DPI
public class Cleaner {
public static void main(String[] args) {
ArrayList<File> includes = new ArrayList<>();
ArrayList<File> excludes = new ArrayList<>();
excludes.add(new File("drawable-hdpi"));
excludes.add(new File("drawable-mdpi"));
excludes.add(new File("drawable-xhdpi"));
try {
Factory2 factory2 = getLayoutInflater().getFactory2();
if (factory2 != null) {
Factory2Wrapper wrapper = new Factory2Wrapper(factory2);
Field fieldFactory2 = LayoutInflater.class.getDeclaredField("mFactory2");
fieldFactory2.setAccessible(true);
fieldFactory2.set(getLayoutInflater(), wrapper);
}
} catch (Exception e) {
@NashLegend
NashLegend / CountingFileRequestBody.java
Created November 1, 2016 10:11 — forked from eduardb/CountingFileRequestBody.java
Uploading a file with a progress displayed using OkHttp
public class CountingFileRequestBody extends RequestBody {
private static final int SEGMENT_SIZE = 2048; // okio.Segment.SIZE
private final File file;
private final ProgressListener listener;
private final String contentType;
public CountingFileRequestBody(File file, String contentType, ProgressListener listener) {
this.file = file;
@NashLegend
NashLegend / Cleaner.java
Last active January 22, 2016 02:46
用于清除AndroidUnusedResources.jar检测到的无用资源导出的文件,使用方法:先执行java -jar AndroidUnusedResources.jar -del.txt,再执行 java -jar -Cleaner.jar del.txt,不清除id资源
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* Copyright 2014 Chris Banes
*
* 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
@NashLegend
NashLegend / SlideActivity.java
Last active August 29, 2015 14:07
像知乎那样滑动Activity
package com.example.swipe2finish;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.Animator.AnimatorListener;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
@NashLegend
NashLegend / loadStrequent.java
Created August 12, 2014 05:55
加载最近联系人
public static void loadStrequent() {
ArrayList<Contact> StrequentContacts = new ArrayList<Contact>();
String[] projection = { Contacts._ID, Contacts.DISPLAY_NAME,
Contacts.LOOKUP_KEY, Contacts.PHOTO_THUMBNAIL_URI,
Contacts.TIMES_CONTACTED, Contacts.LAST_TIME_CONTACTED,
Contacts.STARRED, Contacts.PHOTO_ID };
ContentResolver resolver = AppApplication.globalApplication
.getContentResolver();
// 显示最近联系人和收藏的联系人
Cursor cursor = resolver.query(Contacts.CONTENT_STREQUENT_URI,