text Android的应用如何跳转到应用市场详情页面

Android
Android应用如何跳转到应用市场详情页面
1
2016.09.03 12:11:00
字数 662
阅读 14335
转载请注明出处,谢谢
 个人博客地址:https://xiuxiuing.gitee.io/blog
Android应用开发过程中,可能会有需求,比如:推广时跳转到应用市场下载应用,跳转到应用市场给自己的应用打分,跳转到应用市场更新自己的应用。那如何跳转到应用市场呢?

可能跳转的方法大家都是知道的,方法如下:

public static void goToMarket(Context context, String packageName) {
    Uri uri = Uri.parse("market://details?id=" + packageName);
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    try {
        context.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
此方法支持应用宝、360手机助手、豌豆荚、小米商店等主流的应用市场,当手机上面装有多个应用市场时,则会弹出菜单让用户选择调转到哪个市场。那么,问题来了,如果这么简单就结束了,怎么还会有这篇文章呢?
 在红米Note2上测试时发现,调用此方法默认是直接调转到小米市场,那如果在小米手机上,想要跳转到应用宝或者其他的应用市场怎么办呢,方法自然是有的,如下:

public static void goToMarket(Context context, String packageName) {
    Uri uri = Uri.parse("market://details?id=" + packageName);
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    try {
        goToMarket.setClassName("com.tencent.android.qqdownloader", "com.tencent.pangu.link.LinkProxyActivity");
        context.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
看起来好像和第一个方法没什么区别,是的,只需要给多调用goToMarket.setClassName()方法,设置指定的应用去处理这个Intent事件,这样就可以在小米手机上跳转到应用宝的应用详情页面,而且,上一个方法如果在手机上装有多个应用市场时,会弹出菜单让用户选择,如果已经确定好要跳转到哪个应用市场时,也可使用此方法,直接跳转,省去中间用户选择的环节。
 但是上面方法的思路似乎并不能对所有的应用市场有效,哪天产品经理提出要跳转到三星的应用市场,毕竟三星手机在国内的占有率还是排前几位的,再使用上面的方法,发现懵逼了,三星市场竟然不支持这种方式,难怪三星手机在国内市场节节败退。不过再笔者的努力下终于找到了如下方法:

public static void goToSamsungappsMarket(Context context, String packageName) {
    Uri uri = Uri.parse("http://www.samsungapps.com/appquery/appDetail.as?appId=" + packageName);
    Intent goToMarket = new Intent();
    goToMarket.setClassName("com.sec.android.app.samsungapps", "com.sec.android.app.samsungapps.Main");
    goToMarket.setData(uri);
    try {
        context.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
不过,后来发现在乐视手机上面,乐视的应用市场也是不支持goToMarket()方法的,所以又专门调研了跳转乐视应用市场的方法,方法如下:

void goToLeTVStoreDetail(Context context, String packageName) {
        Intent intent = new Intent();
        intent.setClassName("com.letv.app.appstore", "com.letv.app.appstore.appmodule.details.DetailsActivity");
        intent.setAction("com.letv.app.appstore.appdetailactivity");
        intent.putExtra("packageName", packageName);
        context.startActivity(intent);
    }
以上方法,希望能帮助到有需要的人。

文章内容如有什么问题,欢迎指正。

text python脚本的Web前端

dd
https://github.com/wooey/Wooey
https://netdevops.me/2016/04/building-web-front-end-for-python-scripts-with-flask/

text AWS cli s3

aa
- Make bucket
aws s3 mb s3://mybucket
- Copy file
aws s3 cp Downloads/linux_v_dei.pdf s3://vadossam
- Rsync 
aws s3 sync Downloads s3://vadossam
- Grant perms
aws s3api put-object-acl --bucket vadossam --key linux_v_dei.pdf --acl public-read
aws s3api put-object-acl --bucket vadossam --key linux_v_dei.pdf --acl private
- Remove files
aws s3 rm s3://mybucket --recursive

text 服务器Webmin的设置,CentOS的

在服务器中设置新的webmin接口时要休闲的步骤

server-webmin-setup-centos
Follow this link : https://www.rosehosting.com/blog/how-to-install-webmin-on-centos-7/

STEP1: download webmin 
	# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.831-1.noarch.rpm

STEP2: install all dependencies
	# yum -y install perl perl-Net-SSLeay openssl perl-IO-Tty

STEp3: Once the dependencies are installed, you can install Webmin using the following command:
	# rpm -U webmin-1.831-1.noarch.rpm

STEP4: Install Webmin using the YUM repository
	# nano /etc/yum.repos.d/webmin.repo

STEP5: Add the following content to the file and save it.
	[Webmin]
	name=Webmin Distribution Neutral
	#baseurl=http://download.webmin.com/download/yum
	mirrorlist=http://download.webmin.com/download/yum/mirrorlist
	enabled=1

STEP6: Then, fetch and install the GPG key which is used to sign the Webmin packages:
	# wget http://www.webmin.com/jcameron-key.asc
	# rpm --import jcameron-key.asc

STEP7: Finally, install Webmin and all the dependencies using the following command
	# yum install webmin

STEP8: To start Webmin, you can use the following command:
	# service webmin start

STEP9: To enable Webmin on system boot use the following command:
	# chkconfig webmin on
STEP10: Open up the default port of webmin 
	#  firewall-cmd --zone=public --add-port=10000/tcp --permanent

STEP11: Reoload the firewall
	# firewall-cmd --reload

STEP12: check it the port no '10000' is open or not
	# firewall-cmd --list-all 

STEP13: To access Webmin, open your favorite web browser, enter HTTPS as protocol, enter your server IP address and use 10000 as a port number.
	# https://YOUR-IP-ADDRESS:10000

text Wallhaven下载器

从Wallhaven.cc下载壁纸<br/>所有信用额转到原作者<br/> <br/>由@Fleshwounded重新包装

README.md
Wallhaven Downloader
---
- Repackages and Curated By: @Fleshounded
- Date: 1560816338


This script downloads wallpapers from <a href="http://wallhaven.cc" target="_blank">wallhaven.cc</a>, the script offers various filter options to download only wallpapers to your liking.

You can configure it directly inside the script or per command line arguments (command line arguments will override settings made directly in the script)
check `./wallhaven.sh -h` for details

<h3>This Script is written for GNU Linux, it should work under Mac OS</h3>

Dependencies:
- bash
- wget
- sed
- jq
- gnu parallel (if you wish to use it)
wallhaven.sh
#!/bin/bash
#
# This script gets the beautiful wallpapers from http://wallhaven.cc
# This script is brought to you by MacEarl and is based on the
# script for wallbase.cc (https://github.com/sevensins/Wallbase-Downloader)
#
# This Script is written for GNU Linux, it should work under Mac OS

REVISION=0.2.3

#####################################
###   Needed for NSFW/Favorites   ###
#####################################
# Enter your API key
# you can get it here: https://wallhaven.cc/settings/account
APIKEY="0VI32vSp5VUD7NUv8VBdLXvZXI8KM2pJ"
#####################################
### End needed for NSFW/Favorites ###
#####################################

#####################################
###     Configuration Options     ###
#####################################
# Where should the Wallpapers be stored?
LOCATION="$HOME/Pictures/Wallhaven.cc"
# How many Wallpapers should be downloaded, should be multiples of the
# value in the THUMBS Variable
WPNUMBER=64
# What page to start downloading at, default and minimum of 1.
STARTPAGE=10
# Type standard (newest, oldest, random, hits, mostfav), search, favorites
# (for now only the default collection), useruploads (if selected, only
# FILTER variable will change the outcome)
TYPE=standard
# From which Categories should Wallpapers be downloaded, first number is
# for General, second for Anime, third for People, 1 to enable category,
# 0 to disable it
CATEGORIES=100
# filter wallpapers before downloading, first number is for sfw content,
# second for sketchy content, third for nsfw content, 1 to enable,
# 0 to disable
FILTER=111
# Which Resolutions should be downloaded, leave empty for all (most common
# resolutions possible, for details see wallhaven site), separate multiple
# resolutions with , eg. 1920x1080,1920x1200
RESOLUTION=
# alternatively specify a minimum resolution, please note that specifying
# both resolutions and a minimum resolution will result in the desired
# resolutions being ignored, to avoid unwanted behavior only set one of the
# two options and leave the other blank
ATLEAST=1920x1080
# Which aspectratios should be downloaded, leave empty for all (possible
# values: 4x3, 5x4, 16x9, 16x10, 21x9, 32x9, 48x9, 9x16, 10x16), separate mutliple ratios
# with , eg. 4x3,16x9
ASPECTRATIO=
# Which Type should be displayed (relevance, random, date_added, views,
# favorites, toplist)
MODE=random
# if MODE is set to toplist show the toplist for the given timeframe
# possible values: 1d (last day), 3d (last 3 days), 1w (last week),
# 1M (last month), 3M (last 3 months), 6M (last 6 months), 1y (last year)
TOPRANGE=3M
# How should the wallpapers be ordered (desc, asc)
ORDER=desc
# ! currently broken, might be removed
# favorites collections, only used if TYPE = favorites
# specify the name of the favorites collection you want to download
# Default is the default collection name on wallhaven
FAVCOLLECTION="Default"
# Searchterm, only used if TYPE = search
# you can also search by tags, use id:TAGID
# to get the tag id take a look at: https://wallhaven.cc/tags/
# for example: to search for nature related wallpapers via the nature tag
# instead of the keyword use QUERY="id:37"
QUERY="nature"
# Search images containing color
# values are RGB (000000 = black, ffffff = white, ff0000 = red, ...)
COLOR="8B1A89"
# Should the search results be saved to a separate subfolder?
# 0 for no separate folder, 1 for separate subfolder
SUBFOLDER=0
# User from which wallpapers should be downloaded (only used for
# TYPE=useruploads)
USR=AksumkA
# use gnu parallel to speed up the download (0, 1), if set to 1 make sure
# you have gnuparallel installed, see normal.vs.parallel.txt for
# speed improvements
PARALLEL=1
# custom thumbnails per page
# changeable here: https://wallhaven.cc/settings/browsing
# valid values: 24, 32, 64
# if set to 32 or 64 you need to provide an api key
THUMBS=64
#####################################
###   End Configuration Options   ###
#####################################

function checkDependencies {
    printf "Checking dependencies..."
    dependencies=(wget jq sed)
    [[ $PARALLEL == 1 ]] && dependencies+=(parallel)

    for name in ${dependencies[@]}
    do
        [[ $(which $name 2>/dev/null) ]] ||
        { printf "\n$name needs to be installed. Use your package manager to do so, e.g. 'sudo apt install $name'";deps=1; }
    done
    [[ $deps -ne 1 ]] && printf "OK\n" || { printf "\nInstall the above and rerun this script\n";exit 1; }
} # /checkDependencies

#
# sets the authentication header/API key to give the user more functionality
# requires 1 arguments:
# arg1: API key
#
function setAPIkeyHeader {
    # checking parameters -> if not ok print error and exit script
    if [ $# -lt 1 ] || [ "$1" == '' ]
    then
        printf "Please make sure to enter a valid API key,\n"
        printf "it is needed for NSFW Content and downloading \n"
        printf "your Favorites also make sure your Thumbnails per\n"
        printf "Page Setting matches the THUMBS Variable\n\n"
        printf "Press any key to exit\n"
        read -r
        exit
    fi

    # everythings ok --> set api key header
    httpHeader="X-API-Key: $APIKEY"
} # /setAPIkeyHeader

#
# get favorites page to extract id number later
#
function getFavs {
    WGET --referer="https://wallhaven.cc" -O favtmp \
        "https://wallhaven.cc/favorites"
} # /getFavs

#
# downloads Page with Thumbnails
#
function getPage {
    # checking parameters -> if not ok print error and exit script
    if [ $# -lt 1 ]
    then
        printf "getPage expects at least 1 argument\\n"
        printf "arg1:\\tparameters for the wget -q command\\n\\n"
        printf "press any key to exit\\n"
        read -r
        exit
    fi

    # parameters ok --> get page
    WGET -O tmp "https://wallhaven.cc/api/v1/$1"
} # /getPage

#
# downloads all the wallpaper from a wallpaperfile
# arg1: the file containing the wallpapers
#
function downloadWallpapers {
    for ((i=0; i<$THUMBS; i++))
    do
        imgURL=$(jq -r ".data[$i].path" tmp)

        filename=$(echo "$imgURL"| sed "s/.*\///" )
        if grep -w "$filename" downloaded.txt >/dev/null
        then
            printf "\\tWallpaper %s already downloaded!\\n" "$imgURL"
        elif [ $PARALLEL == 1 ]
        then
            echo "$imgURL" >> download.txt
        else
            downloadWallpaper "$imgURL"
            # check if downloadWallpaper was successful
            if [ $? == 0 ]
            then
                echo "$filename" >> downloaded.txt
            fi
        fi
    done

    if [ $PARALLEL == 1 ] && [ -f ./download.txt ]
    then
        # export wget wrapper and download function to make it
        # available for parallel
        export -f WGET downloadWallpaper
        SHELL=$(type -p bash) parallel --gnu --no-notice \
            'imgURL={} && downloadWallpaper $imgURL && echo "$imgURL"| sed "s/.*\///" >> downloaded.txt' < download.txt
            rm tmp download.txt
        else
            rm tmp
    fi
} # /downloadWallpapers

#
# downloads a single Wallpaper by guessing its extension, this eliminates
# the need to download each wallpaper page, now only the thumbnail page
# needs to be downloaded
#
function downloadWallpaper {
    if [[ "$1" != null ]]
    then
        WGET "$1"
    else
        return 1
    fi
} # /downloadWallpaper

#
# wrapper for wget with some default arguments
# arg0: additional arguments for wget (optional)
# arg1: file to download
#
function WGET {
    # checking parameters -> if not ok print error and exit script
    if [ $# -lt 1 ]
    then
        printf "WGET expects at least 1 argument\\n"
        printf "arg0:\\tadditional arguments for wget (optional)\\n"
        printf "arg1:\\tfile to download\\n\\n"
        printf "press any key to exit\\n"
        read -r
        exit
    fi

    # default wget command
    wget -q --header="$httpHeader" "$@"
} # /WGET

#
# displays help text (valid command line arguments)
#
function helpText {
    printf "Usage: ./wallhaven.sh [OPTIONS]\\n"
    printf "Download wallpapers from wallhaven.cc\\n\\n"
    printf "If no options are specified, default values from within the "
    printf "script will be used\\n\\n"
    printf " -l, --location\\t\\tlocation where the wallpapers will be "
    printf "stored\\n"
    printf " -n, --number\\t\\tNumber of Wallpapers to download\\n"
    printf " -s, --startpage\\tpage to start downloading from\\n"
    printf " -t, --type\\t\\tType of download Operation: standard, search, "
    printf "\\n\\t\\t\\tfavorites, useruploads\\n"
    printf " -c, --categories\\tcategories to download from, eg. 111 for "
    printf "General,\\n\\t\\t\\tAnime and People, 1 to include, 0 to exclude\\n"
    printf " -f, --filter\\t\\tfilter out content based on purity rating, "
    printf "eg. 111 \\n\\t\\t\\tfor SFW, sketchy and NSFW content, 1 to "
    printf "include, \\n\\t\\t\\t0 to exclude\\n"
    printf " -r, --resolution\\tresolutions to download, separate mutliple"
    printf " \\n\\t\\t\\tresolutions by ,\\n"
    printf " -g, --atleast\\t\\tminimum resolution, show all images with a"
    printf "\\n\\t\\t\\tresolution greater than the specified value"
    printf "\\n\\t\\t\\tdo not use in combination with -r (--resolution)\\n"
    printf " -a, --aspectratio\\tonly download wallpaper with given "
    printf "aspectratios, \\n\\t\\t\\tseparate multiple aspectratios by ,\\n"
    printf " -m, --mode\\t\\tsorting mode for wallpapers: relevance, random"
    printf ",\\n\\t\\t\\tdate_added, views, favorites \\n"
    printf " -o, --order\\t\\torder ascending (asc) or descending "
    printf "(desc)\\n"
    printf " -b, --favcollection\\tname of the favorite collections to download\\n"
    printf " -q, --query\\t\\tsearch query, eg. 'mario', single "
    printf "quotes needed,\\n\\t\\t\\tfor searching exact phrases use double "
    printf "quotes \\n\\t\\t\\tinside single quotes, eg. '\"super mario\"'"
    printf "\\n"
    printf " -d, --dye, --color\\tsearch for wallpapers containing the "
    printf "given color,\\n"
    printf "\\t\\t\\tcolor values are RGB without a leading #\\n"
    printf " -u, --user\\t\\tdownload wallpapers from given user\\n"
    printf " -p, --parallel\\t\\tmake use of gnu parallel (1 to enable, 0 "
    printf "to disable)\\n"
    printf " -v, --version\\t\\tshow current version\\n"
    printf " -h, --help\\t\\tshow this help text and exit\\n\\n"
    printf "Examples:\\n"
    printf "./wallhaven.sh\\t-l ~/wp/ -n 48 -s 1 -t standard -c 101 -f 111"
    printf " -r 1920x1080 \\n\\t\\t-a 16x9 -m random -o desc -p 1\\n\\n"
    printf "Download 48 random wallpapers with a resolution of 1920x1080 "
    printf "and \\nan aspectratio of 16x9 to ~/wp/ starting with page 1 "
    printf "from the \\ncategories general and people including SFW, sketchy"
    printf " and NSWF Content\\nwhile utilizing gnu parallel\\n\\n"
    printf "./wallhaven.sh\\t-l ~/wp/ -n 48 -s 1 -t search -c 111 -f 100 -r "
    printf "1920x1080 -a 16x9\\n\\t\\t-m relevance -o desc -q "
    printf "'\"super mario\"' -d cc0000 -p 1\\n\\n"
    printf "Download 48 wallpapers related to the search query "
    printf "\"super mario\" containing \\nthe color #cc0000 with a resolution"
    printf " of 1920x1080 and an aspectratio of 16x9\\nto ~/wp/ starting "
    printf "with page 1 from the categories general, anime and people,\\n"
    printf "including SFW Content and excluding sketchy and NSWF Content "
    printf "while utilizing\\ngnu parallel\\n\\n\\n"
    printf "latest version available at: "
    printf "<https://github.com/macearl/Wallhaven-Downloader>\\n"
} # /helptext

# Command line Arguments
while [[ $# -ge 1 ]]
    do
    key="$1"

    case $key in
        -l|--location)
            LOCATION="$2"
            shift;;
        -n|--number)
            WPNUMBER="$2"
            shift;;
        -s|--startpage)
            STARTPAGE="$2"
            shift;;
        -t|--type)
            TYPE="$2"
            shift;;
        -c|--categories)
            CATEGORIES="$2"
            shift;;
        -f|--filter)
            FILTER="$2"
            shift;;
        -r|--resolution)
            RESOLUTION="$2"
            shift;;
        -g|--atleast)
            ATLEAST="$2"
            shift;;
        -a|--aspectratio)
            ASPECTRATIO="$2"
            shift;;
        -m|--mode)
            MODE="$2"
            shift;;
        -o|--order)
            ORDER="$2"
            shift;;
        -b|--favcollection)
            FAVCOLLECTION="$2"
            shift;;
        -q|--query)
            QUERY=${2//\'/}
            shift;;
        -d|--dye|--color)
            COLOR="$2"
            shift;;
        -u|--user)
            USR="$2"
            shift;;
        -p|--parallel)
            PARALLEL="$2"
            shift;;
        -h|--help)
            helpText
            exit
            ;;
        -v|--version)
            printf "Wallhaven Downloader %s\\n" "$REVISION"
            exit
            ;;
        *)
            printf "unknown option: %s\\n" "$1"
            helpText
            exit
            ;;
    esac
    shift # past argument or value
    done

checkDependencies

# optionally create a separate subfolder for each search query
# might download duplicates as each search query has its own list of
# downloaded wallpapers
if [ "$TYPE" == search ] && [ "$SUBFOLDER" == 1 ]
then
    LOCATION+=/$(echo "$QUERY" | sed -e "s/ /_/g" -e "s/+/_/g" -e  "s/\\//_/g")
fi

# creates Location folder if it does not exist
if [ ! -d "$LOCATION" ]
then
    mkdir -p "$LOCATION"
fi

cd "$LOCATION" || exit

# creates downloaded.txt if it does not exist
if [ ! -f ./downloaded.txt ]
then
    touch downloaded.txt
fi

# set auth header only when it is required ( for example to download favourites
# or nsfw content... )
if  [ "$FILTER" == 001 ] || [ "$FILTER" == 011 ] || [ "$FILTER" == 111 ] \
    || [ "$TYPE" == favorites ] || [ "$THUMBS" != 24 ]
then
    setAPIkeyHeader "$APIKEY"
fi

if [ "$TYPE" == standard ]
then
    for ((  count=0, page="$STARTPAGE";
            count< "$WPNUMBER";
            count=count+"$THUMBS", page=page+1 ));
    do
        printf "Download Page %s\\n" "$page"
        s1="search?page=$page&categories=$CATEGORIES&purity=$FILTER&"
        s1+="atleast=$ATLEAST&resolutions=$RESOLUTION&ratios=$ASPECTRATIO"
        s1+="&sorting=$MODE&order=$ORDER&topRange=$TOPRANGE&colors=$COLOR"
        getPage "$s1"
        printf "\\t- done!\\n"
        printf "Download Wallpapers from Page %s\\n" "$page"
        downloadWallpapers
        printf "\\t- done!\\n"
    done

elif [ "$TYPE" == search ] || [ "$TYPE" == useruploads ]
then
    for ((  count=0, page="$STARTPAGE";
            count< "$WPNUMBER";
            count=count+"$THUMBS", page=page+1 ));
    do
        printf "Download Page %s\\n" "$page"
        s1="search?page=$page&categories=$CATEGORIES&purity=$FILTER&"
        s1+="atleast=$ATLEAST&resolutions=$RESOLUTION&ratios=$ASPECTRATIO"
        s1+="&sorting=$MODE&order=desc&topRange=$TOPRANGE&colors=$COLOR"
        if [ "$TYPE" == search ]
        then
            s1+="&q=$QUERY"
        elif [ "$TYPE" == useruploads ]
        then
            s1+="&q=@$USR"
        fi

        getPage "$s1"
        printf "\\t- done!\\n"
        printf "Download Wallpapers from Page %s\\n" "$page"
        downloadWallpapers
        printf "\\t- done!\\n"
    done

elif [ "$TYPE" == favorites ]
then
    getFavs

    favnumber="$(grep -o "<small>[0-9]*</small>$FAVCOLLECTION" favtmp | \
                sed 's/[^0-9]*//g')"

    favlistval=$(grep -Eo "https://wallhaven.cc/favorites/[0-9]+[^.]*small>$FAVCOLLECTION" \
                favtmp | sed -r 's/([^0-9]*)([0-9]+)(".*)/\2/')

    if [ -z "$favnumber" ] || [ -z "$favlistval" ]
    then
        printf "Please check the value specified for FAVCOLLECTION\\n"
        printf "it seems that a collection with the name \"%s\" does not exist\\n\\n" \
                "$FAVCOLLECTION"
        printf "Press any key to exit\\n"
        read -r
        exit
    fi

    for ((  count=0, page="$STARTPAGE";
            count< "$WPNUMBER" && count< "$favnumber";
            count=count+"$THUMBS", page=page+1 ));
    do
        printf "Download Page %s\\n" "$page"
        getPage "favorites/$favlistval?page=$page"
        printf "\\t- done!\\n"
        printf "Download Wallpapers from Page %s\\n" "$page"
        downloadWallpapers
        printf "\\t- done!\\n"
    done

elif [ "$TYPE" == useruploads ]
then
    # UPLOADS FROM SPECIFIC USER
    for ((  count=0, page="$STARTPAGE";
            count< "$WPNUMBER";
            count=count+"$THUMBS", page=page+1 ));
    do
        printf "Download Page %s\\n" "$page"
        getPage "user/$USR/uploads?page=$page&purity=$FILTER"
        printf "\\t- done!\\n"
        printf "Download Wallpapers from Page %s\\n" "$page"
        downloadWallpapers
        printf "\\t- done!\\n"
    done

else
    printf "error in TYPE please check Variable\\n"
fi

rm -f favtmp
normal.vs.parallel.txt
Differences between normal version and parallel version.
running on i7 2600k with 100mbit Internet connection
---------------------------------------------------------
19:37 $ time ./wallhaven_parallel.sh
Download Page 1                    - done!
Download Wallpapers from Page 1    - done!
Download Page 2                    - done!
Download Wallpapers from Page 2    - done!

real    0m56.460s
user    0m3.363s
sys     0m2.233s
---------------------------------------------------------
19:40 $ time ./wallhaven.sh
Download Page 1                    - done!
Download Wallpapers from Page 1    - done!
Download Page 2                    - done!
Download Wallpapers from Page 2    - done!

real    5m6.761s
user    0m2.033s
sys     0m2.303s
changelog
Changelog
 Revision 0.2.3
 1. fixed search function
 2. removed continue from wget, can cause problems with the downloaded json

 Revision 0.2.2
 1. fixed error in parallel download logging

 Revision 0.2.1
 1. fixed error which prevented parallel downloading

 Revision 0.2
 1. switched to newly introduced API
 2. jq is now a dependency
 3. favorites are currently broken as there is no API endpoint,
    currently undecided if the feature will be removed or if i'll
    readd scraping and login just for this

 Revision 0.1.9
 1. added option to download non default favorite collections
    thanks to xorb0ss for the pull request

 Revision 0.1.8.1
 1. fixed possible values for Toplist Month

 Revision 0.1.8
 1. added option to download wallpapers containing a specific color
 2. added documentation on how to search by a tag id
 3. modified examples in help text

 Revision 0.1.7.5
 1. added option to show the toplist for a given timeframe

 Revision 0.1.7.4
 1. added option to only search for wallpapers with an resolution that is
    at least the one specified

 Revision 0.1.7.3
 1. only add wallpaper id to downloaded after successful download

 Revision 0.1.7.2
 1. urlencode password to accomodate special characters

 Revision 0.1.7.1
 1. added option to create subfolders for each search query

 Revision 0.1.7
 1. fixed Favorites download
 2. get wallpaper URL from thumbnail page
        no need to download every wallpaper page anymore
 3. added custom Thumbnail per Page option
 4. refactoring

 Revision 0.1.6.10
 1. removed substring with negative length for backwards compatibility

 Revision 0.1.6.9
 1. some refactoring

 Revision 0.1.6.8
 1. quickfix to make downloading possible again (rather ugly)

 Revision 0.1.6.7
 1. replaced http with https

 Revision 0.1.6.6
 1. fixed issue with downloading favorites

 Revision 0.1.6.5
 1. added command line options/switches (-l / --location, ...)
 2. added help text
 2. moved changelog to separate file

 Revision 0.1.6.4
 1. added a starting page number (by ry167)

 Revision 0.1.6.3
 1. added -m 1 option to grep command to prevent downloading every wallpaper twice

 Revision 0.1.6.2
 1. MODE variable now affects search results, thanks to munhyunsu for pointing it out

 Revision 0.1.6.1
 1. added http prefix to referer

 Revision 0.1.6
 1. fixed issue with login token
 2. added useragent to wget to fix "403 forbidden" error

 Revision 0.1.5
 1. fixed issue if all wallpapers on a page where already downloaded

 Revision 0.1.4
 1. fixed parallel mode

 Revision 0.1.3
 1. added check if downloaded.txt file exists
 2. added "--gnu" option to parallel
        (for some older Distributions which set the default mode to tollef)
        For some older Versions of parallel remove the "--no-notice" option if you get an error like this:
        "parallel: Error: Command (--no-notice) starts with '-'. Is this a wrong option?"
 3. fixed issue where wget would not automatically add a "http://" prefix

 Revision 0.1.2
 1. fixed urls to work with latest wallhaven update
 2. added some comments
 3. fixed login issue when downloading favorites
 4. merged normal and parallel version

 Revision 0.1.1
 1. updated and tested parts of the script to work with
    newest wallhaven site (not all features tested)

 Revision 0.1
 1. first Version of script, most features from the wallbase
    script are implemented

text 电源外壳

port_forward_wsl
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';

if( $found ){
  $remoteport = $matches[0];
} else{
  echo "The Script Exited, the ip address of WSL 2 cannot be found";
  exit;
}

#[Ports]

#All the ports you want to forward separated by coma
$ports=@(80,443,2222);


#[Static ip]
#You can change the addr to your ip config to listen to a specific address
$addr='0.0.0.0';
$ports_a = $ports -join ",";


#Remove Firewall Exception Rules
iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' ";

#adding Exception Rules for inbound and outbound Rules
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP";
iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP";

for( $i = 0; $i -lt $ports.length; $i++ ){
  $port = $ports[$i];
  iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr";
  iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport";
}
rsync-server
https://serverfault.com/questions/878887/rsync-server-using-windows-subsystem-for-linux

text 安全命令

seurity
lsod -i
w
who
last
ulimit -a
nmap

text 谷歌分析

bc-google-analytics


https://support.bigcommerce.com/s/article/Setting-Up-Google-Analytics

text 光滑滚动jquery

smooth scroll jquery
$(document).ready(function(){
  $('a').click(function(){
    $('html, body').animate({
      scrollTop: $( $.attr(this, 'href') ).offset().top
    }, 500);
    return false;
  });
});

text Git的命令:修改上一次提交的提交信息

git-commit-message
git commit --amend -m "New commit message"

这一步操作完之后要pull一次