Title

Retrofit 相关

更上一层楼-Android研发工程师高级进阶
Retrofit 解析 JSON 数据
Retrofit 2.0: The biggest update yet on the best HTTP Client Library for Android
Retrofit 2 — Upgrade Guide from 1.9
Retrofit 开发示例

使用 Retrofit Post发送一个对象

Retrofit — Send Objects in Request Body
method POST must have a request body
Retrofit: API Integration Made Easy
问题分析总结

出现错误

java.lang.IllegalArgumentException: Unable to create call adapter for rx.Observable<java.util.List<com.coam.model.test.GithubUser>>

需要将rxjava结合到retrofit,在构建请求客户端的地方加上 .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 如下:

Retrofit retrofit = new Retrofit.Builder().baseUrl(ENDPOINT)
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .build();

//mService = retrofit.create(GithubAPIInterface.class);
return new GithubService(retrofit.create(GithubAPIInterface.class));

并在dependencies中引入

compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'

Title

Php 开发笔记相关


参考 PHP高效率写法(详解原因)

PHP读取软件接ln 的相对父路径问题

PHP读取软连接下的PHP程序使用 DIR 获取的相对路径,获取的父级目录是源文件的父级目录,若想获取软连接的父级目录,应使用 $_SERVER[“SCRIPT_FILENAME”]来获取当前脚本文件绝句路径再拼接

详见 PHP魔术常量FILE无法识别符号链接问题解决


关于 CGI, FastCGI, PHP-FPM, SPAWN-FCGI, Nginx 它们之间的关系

CGI, FastCGI, PHP-FPM, SPAWN-FCGI, Nginx 它们之间的关系
php fpm和fast-CGI有啥关系?而且还有一个疑问,就是PHP以CGI方式运行,请问以CGI方式运行到底是啥意思??

Title

Java数组

声明一个数组(Declare an array)

String[] aArray = new String[5];
String[] bArray = {"a","b","c", "d", "e"};
String[] cArray = new String[]{"a","b","c","d","e"};

在Java中输出一个数组(Print an array in Java)

int[] intArray = { 1, 2, 3, 4, 5 };
String intArrayString = Arrays.toString(intArray);

// print directly will print reference value
System.out.println(intArray);
// [I@7150bd4d

System.out.println(intArrayString);
// [1, 2, 3, 4, 5]

从数组中创建数组列表(Create an ArrayList from an array)

String[] stringArray = { "a", "b", "c", "d", "e" };
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray));
System.out.println(arrayList);
// [a, b, c, d, e]

检查数组中是否包含特定值(Check if an array contains a certain value)

String[] stringArray = { "a", "b", "c", "d", "e" };
boolean b = Arrays.asList(stringArray).contains("a");
System.out.println(b);
// true

连接两个数组( Concatenate two arrays)

int[] intArray = { 1, 2, 3, 4, 5 };
int[] intArray2 = { 6, 7, 8, 9, 10 };
// Apache Commons Lang library
int[] combinedIntArray = ArrayUtils.addAll(intArray, intArray2);

声明一个数组内链(Declare an array inline )

method(new String[]{"a", "b", "c", "d", "e"});

将数组元素加入到一个独立的字符串中(Joins the elements of the provided array into a single String)

// containing the provided list of elements
// Apache common lang
String j = StringUtils.join(new String[] { "a", "b", "c" }, ", ");
System.out.println(j);
// a, b, c

将数组列表转换成一个数组 (Covnert an ArrayList to an array)

String[] stringArray = { "a", "b", "c", "d", "e" };
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray));
String[] stringArr = new String[arrayList.size()];
arrayList.toArray(stringArr);
for (String s : stringArr)
    System.out.println(s);

将数组转换成一个集合(Convert an array to a set)

Set<String> set = new HashSet<String>(Arrays.asList(stringArray));
System.out.println(set);
//[d, e, b, c, a]

反向数组(Reverse an array)

int[] intArray = { 1, 2, 3, 4, 5 };
ArrayUtils.reverse(intArray);
System.out.println(Arrays.toString(intArray));
//[5, 4, 3, 2, 1]

删除数组元素(Remove element of an array)

int[] intArray = { 1, 2, 3, 4, 5 };
int[] removed = ArrayUtils.removeElement(intArray, 3);//create a new array
System.out.println(Arrays.toString(removed));
One more – convert int to byte array 
byte[] bytes = ByteBuffer.allocate(4).putInt(8).array();

for (byte t : bytes) {
   System.out.format("0x%x ", t);
}

Five (5) ways to Iterate Through Loop in Java

package crunchify.com.tutorial;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Crunchify.com
 */

public class CrunchifyIterateThroughList {

    public static void main(String[] argv) {

        // create list
        List<String> CrunchifyList = new ArrayList<String>();

        // add 4 different values to list
        CrunchifyList.add("eBay");
        CrunchifyList.add("Paypal");
        CrunchifyList.add("Google");
        CrunchifyList.add("Yahoo");

        // iterate via "for loop"
        System.out.println("==> For Loop Example.");
        for (int i = 0; i < CrunchifyList.size(); i++) {
            System.out.println(CrunchifyList.get(i));
        }

        // iterate via "New way to loop"
        System.out.println("\n==> Advance For Loop Example..");
        for (String temp : CrunchifyList) {
            System.out.println(temp);
        }

        // iterate via "iterator loop"
        System.out.println("\n==> Iterator Example...");
        Iterator<String> CrunchifyIterator = CrunchifyList.iterator();
        while (CrunchifyIterator.hasNext()) {
            System.out.println(CrunchifyIterator.next());
        }

        // iterate via "while loop"
        System.out.println("\n==> While Loop Example....");
        int i = 0;
        while (i < CrunchifyList.size()) {
            System.out.println(CrunchifyList.get(i));
            i++;
        }

        // collection stream() util: Returns a sequential Stream with this collection as its source
        System.out.println("\n==> collection stream() util....");
        CrunchifyList.forEach((temp) -> {
            System.out.println(temp);
        });
    }
}

参考

Java List For 循环 How to iterate through Java List? Five (5) ways to Iterate Through Loop in Java
Java程序员常犯的10个错误