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 / cloudSettings
Last active November 2, 2020 06:04
Visual Studio Code Settings Sync Gist
NashLegend /
Created May 25, 2017 10:33 — forked from masak/
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 <>
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 / AssetsCompiler.Java
Created February 27, 2017 14:34
public class AssetsCompiler {
public static void main(String[] args) {
public static void rReact(String path) {
File source = new File(path);
File dest = new File("out/d.txt");
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.set(getLayoutInflater(), wrapper);
} catch (Exception e) {
NashLegend /
Created November 1, 2016 10:11 — forked from eduardb/
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 /
Last active January 22, 2016 02:46
用于清除AndroidUnusedResources.jar检测到的无用资源导出的文件,使用方法:先执行java -jar AndroidUnusedResources.jar -del.txt,再执行 java -jar -Cleaner.jar del.txt,不清除id资源
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
* Unless required by applicable law or agreed to in writing, software
NashLegend /
Last active August 29, 2015 14:07
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.content.Context;
NashLegend /
Created August 12, 2014 05:55
public static void loadStrequent() {
ArrayList<Contact> StrequentContacts = new ArrayList<Contact>();
String[] projection = { Contacts._ID, Contacts.DISPLAY_NAME,
Contacts.STARRED, Contacts.PHOTO_ID };
ContentResolver resolver = AppApplication.globalApplication
// 显示最近联系人和收藏的联系人
Cursor cursor = resolver.query(Contacts.CONTENT_STREQUENT_URI,