Month: November 2017
Open SSH
First Install CURL by typing sudo apt-get install curl
Then Restart Apache by typing sudo service apache2 restart
Then Install PHP5 CURL by typing sudo apt-get install php5-curl
如果您使用的是7.0版块,可以尝试 sudo apt-get install php7.0-curl
Then Restart Apache by typing sudo service apache2 restart
Done!
更多可以参考:https://stackoverflow.com/ques…
Read More
VM建立固定IP
建立VM后, VM会得到外部IP,这一组IP不是固定的, VM 重开后会不一样,以下步骤能设定VM固定外部IP
点选Compute Engine
点选VM执行个体
点选VM
点选编辑
点选网路介面
点选建立IP位址
输入这组静态IP的名称, 按下预约, 选定的VM就可以预约到固定的静态IP
查询/管理IP
点选VPC网路
点选外部IP位址
这里可以看到所有申请的IP,如果有静态IP未分配,会有额外的费用
详细费用参考: 这里
本文:Google Cloud Platform(GCP) VM 固定,静态,外部IP设定…
Read More
虽然把WordPress网站架在Google Cloud Platform (GCP)上了,但其实对GCP 这个平台还是相当的陌生…有时候需要进去WordPress 机器里执行一些指令操作,都只能从Google Cloud 网页上,选择SSH 的功能:
这会开启一个浏览器的视窗,里面就是SSH 连到VM 后的画面,操作起来和一般的SSH 没什么不同,不过毕竟不是自己执行的SSH,所以也不晓得要怎么利用它传档案到VM 上去:
今天稍微瞄了一下文件,把Google Cloud SDK 装起来了,之后就可以直接用gcloud 指令SSH 到VM 上,快速许多~
1. 安装Google Cloud SDK
参考文件…
Read More
In order to add a redirect function to your WordPress template, you should perform the following:
Log into your Dashboard and go to Appearance -> Editor, select Home Page Page Template (page-home.php):
If you don’t have the Home Page page template in your theme folder, you should copy it there. To do that, you need to copy the file page-home…
Read More
sudo vi /etc/apache2/apache2.conf (没有的话,可以尝试sudo vi /etc/apache2/sites-available/000-default.conf)打开apache配置文件
<Directory /var/www/> #实际目录根据网站根目录而定
Options Indexes FollowSymLinks
AllowOverride None #改为All
Require all granted
</Directory>
执行命令:sudo a2enmod rewrite
在网站的根目录下建立…
Read More
经过一天的努力和摸索,终于完成了 Shadowsocks 的搭建并优化提速,遗憾的是没有找到突破 netflix 封锁的办法,希望大神指点迷津。
以下内容分四步
一、Google Cloud Platform虚拟机部署
二、升级VPS内核开启BBR
三、搭建Shadowsocks server
四、设置Shadowsocks server开机启动
本人不是码农,基本算是零基础,相信你照着我下面的步骤也会成功的。
操作平台:PC-win10-64bit
需要工具:能访问Google的网络、VISA信用卡
一、Google Cloud Platform虚拟机部署
1.申请试用GCP
谷歌云平台可让您构建和主机应用程序和网站,存储数据,并分…
Read More
Apache Commons包含了很多开源的工具,用于解决平时编程经常会遇到的问题,减少重复劳动。下面是我这几年做开发过程中自己用过的工具类做简单介绍。
组件
功能介绍
BeanUtils
提供了对于JavaBean进行各种操作,克隆对象,属性等等.
Betwixt
XML与Java对象之间相互转换.
Codec
处理常用的编码方法的工具类包 例如DES、SHA1、MD5、Base64等.
Collections
java集合框架操作.
Compress
java提供文件打包 压缩类库.
Configuration
一个java应用程序的配置管理类库.
DBCP
提供数据库连接池服务.
DbUtils
提供对jdbc 的…
Read More
public class TestThread extends Thread
{
public void run()
{
System.out.println(this.getName() + "子线程开始");
try
{
// 子线程休眠五秒
Thread.sleep(5000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println(this.getName() + "子线程结束");
}
}
首先是一个线程,它执行完成需要5秒。
1、主线程等待一个子线程
public class Main
{
public static void main(Strin…
Read More
1、ExecutorService:
是一个接口,继承了Executor:
public interface ExecutorService extends Executor {
}
2、Executor:
而Executor亦是一个接口,该接口只包含了一个方法:
void execute(Runnable command);
3、Executors:
该类是一个辅助类,此包中所定义的 Executor、ExecutorService、ScheduledExecutorService、ThreadFactory 和 Callable 类的工厂和实用方法。
此类支持以下各种方法:
• 创建并返回设置有常用配置字符串的 ExecutorSer…
Read More
概要:
数组,就是相同数据类型的元素按一定顺序排列的集合,就是把有限个类型相同的变量用一个名字命名,然后用编号区分他们的变量的集合,这个名字称为数组名,编号称为下标。
组成数组的各个变量称为数组的分量,也称为数组的元素,有时也称为下标变量。
数组是在程序设计中,为了处理方便, 把具有相同类型的若干变量按有序的形式组织起来的一种形式。这些按序排列的同类数据元素的集合称为数组。
初始化数组
动态初始化
int array = new int[3];
// 两种方式都可以
// int array = new int[3];
array[0] = 1;
array[1] = 2;
array[2] = 3;
Syst…
Read More
public class PrettyPrintingMap<K, V> {
private Map<K, V> map;
public PrettyPrintingMap(Map<K, V> map) {
this.map = map;
}
public String toString() {
StringBuilder sb = new StringBuilder();
一:遍历JsonArray
// 一个未转化的字符串
String str = "[{name:'a',value:'aa'},{name:'b',value:'bb'},{name:'c',value:'cc'},{name:'d',value:'dd'}]" ;
// 首先把字符串转成 JSONArray 对象
JSONArray json = JSONArray.fromObject(str );
if(json.size()>0){
for(int i=0;i<json.size();i++){
// 遍历 jsonarray 数组,把每一个对象转成 json 对象
JSONObject job = j…
Read More
第一种方法 – 使用DecimalFormat类
举个例子,假如我们需要保留两位小数,我们可以这样写
DecimalFormat df = new DecimalFormat("0.00");
测试如下:
double d = 0.200;
DecimalFormat df = new DecimalFormat("0.00");
System.out.println(df.format(d));
输出结果为:
0.20
若double d=0.000;输出结果为0.00;
若double d=0;输出结果为0.00;
若double d=41.2345;输出结果为41.23;
经测试,不管double d的值为多少,最后结果都是正常的两…
Read More
In this tutorial, we will show you how to get the current date time from the classic Date and Calendar APIs, and also the new Java 8 date and time APIs – LocalDateTime and LocalDate
1. Code Snippets
For java.util.Date, just create a new Date()
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
System.out.println(…
Read