Skip to content

Instantly share code, notes, and snippets.

View johnwatsondev's full-sized avatar
😐

JohnWatsonDev johnwatsondev

😐
  • 工厂
  • Hangzhou
View GitHub Profile
@johnwatsondev
johnwatsondev / README.md
Created May 7, 2021 09:58 — forked from maboloshi/README.md
[Mac下配置Aria2] #macOS #aria2

Mac下配置Aria2

安装和设置 Aria2

# 使用 Homebrew 安装 aria2
brew install aria2

# 创建配置文件aria2.conf和空对话文件aria2.session
mkdir ~/.aria2 && cd ~/.aria2
touch aria2.conf

Ref: https://gist.github.com/vertexclique/9839383

Important Note

Please use built-in Terminal.app (of Mac OS X) to type and rune the command, do not use another tool (like iTerm2).

Common step after enter run the patch command:

  • After run the commands, start new Sublime Text app, go to Main Menu > Help > Enter License. On the popup type in any text (example "a") and click Use Licence .
@johnwatsondev
johnwatsondev / README.md
Created March 15, 2019 07:16 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@johnwatsondev
johnwatsondev / build.gradle
Created April 11, 2018 13:45 — forked from jpardogo/build.gradle
Gradle DependecyResolution
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
boolean isMultidex = details.requested.name.contains('multidex')
if (details.requested.group == 'com.android.support' && !isMultidex){
details.useVersion lib_versions.support
}else if(isMultidex){
details.useVersion lib_versions.multidex
}
}
@johnwatsondev
johnwatsondev / EqualSpacingItemDecoration.java
Created December 26, 2017 14:11 — forked from alexfu/EqualSpacingItemDecoration.java
Add equal spacing to RecyclerView items automatically. Can handle horizontal, vertical, and grid display modes
import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class EqualSpacingItemDecoration extends RecyclerView.ItemDecoration {
private final int spacing;
private int displayMode;
public static final int HORIZONTAL = 0;
@johnwatsondev
johnwatsondev / SpanningGridLayoutManager.java
Created December 26, 2017 14:10 — forked from heinrichreimer/SpanningGridLayoutManager.java
GridLayoutManager implementation that stretches to fit all grid items on screen and disables scrolling. Useful for dashboards etc.
package com.example;
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.ViewGroup;
public class SpanningGridLayoutManager extends GridLayoutManager {
@johnwatsondev
johnwatsondev / SpanningLinearLayoutManager.java
Created December 26, 2017 14:10 — forked from heinrichreimer/LICENSE
LinearLayoutManager implementation that stretches to fit all list items on screen and disables scrolling. Useful for dashboards etc.
package de.wilhelmgym.quiz.recyclerview;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.ViewGroup;
public class SpanningLinearLayoutManager extends LinearLayoutManager {
@johnwatsondev
johnwatsondev / ReactNativeJson.java
Created June 19, 2017 14:31 — forked from viperwarp/ReactNativeJson.java
React-Native Module, ReadableMap/Array to Java JSON objects
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
@johnwatsondev
johnwatsondev / xcode-downloader.rb
Created May 2, 2017 04:13 — forked from iandundas/xcode-downloader.rb
Script for reliably downloading binaries (e.g. Xcode) from Apple's CDN
#!/usr/bin/env ruby
print "What is the URL of your Apple Downloads resource?\nURL:"
url = gets.strip
print "What is the ADCDownloadAuth cookie token:\nADCDownloadAuth: "
token = gets.strip
command = "aria2c --header \"Host: adcdownload.apple.com\" --header \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" --header \"Upgrade-Insecure-Requests: 1\" --header \"Cookie: ADCDownloadAuth=#{token}\" --header \"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B72 Safari/602.1\" --header \"Accept-Language: en-us\" -x 16 -s 16 #{url} -d ~/Downloads"
@johnwatsondev
johnwatsondev / README.md
Created November 21, 2016 10:22 — forked from hofmannsven/README.md
My simply Git Cheatsheet