分类目录归档:移动

HTML转图片利器:wkhtmltox

关于wkhtmltox,是一个可以把HTML转换为图片和pdf的工具。

不多介绍了,详见官网 https://wkhtmltopdf.org/

安装步骤

  1. 下载下来是tar.xz文件,首先解压:
    tar -vxf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
  2. 解压得到一个目录wkhtmltox,把wkhtmltoimage和wkhtmltopdf复制到/usr/bin目录,更改所有者,并增加可执行属性
sudo cp wkhtmltox/bin/wkhtmltopdf /usr/bin/
sudo cp wkhtmltox/bin/wkhtmltoimage /usr/bin/
sudo chown root:root /usr/bin/wkhtmltopdf
sudo chown root:root /usr/bin/wkhtmltoimage
sudo chmod +x /usr/bin/wkhtmltopdf
sudo chmod +x /usr/bin/wkhtmltoimage
  1. 注意事项

有时候为了让程序可以执行这个命令,可能需要配置环境变量
– 编辑配置文件 vi .bashrc
– 添加环境变量 export PATH=$PATH:/opt/wkhtmltox/bin
– 让修改生效 source .bashrc让修改生效

如果网页上的中文,转成图片后变成乱码方块,请安装相关字体 :)

关于使用

执行wkhtmltoimage www.bing.com bing.png,就会在当前目录下生成了一张png图片。

这个命令还可以增加一些参数,比如常用的设置宽高,图片质量等参数
执行wkhtmltoimage --crop-w 410 --width 410 --quality 50 www.bing.com bing2.png看看

说明:
--crop-w 410:截图宽度410px
--width 410:浏览器模拟宽度410px
--quality 50:图片质量(这个值越大,图片质量越高,当然文件也会比较大)

还有更多参数用法,请 wkhtmltoimage -h查看。
HTML转pdf同理,wkhtmltopdf -h

Exposing Spinnaker to End Users

One of the things we are commonly asked in the Spinnaker chat room is “How do I open Spinnaker up to end users?”

The answer depends on how you deploy Spinnaker — with a Local or Distributed environment.

This post focuses on a Local environment. To prevent inadvertently exposing your cloud infrastructure to the whole world, Halyard installs Spinnaker in its most locked-down form. This means all services only bind to localhost , which only accepts connections from inside the same server.

On the other hand, Distributed environment services bind to 0.0.0.0 , which allows them to receive requests from services running on different hosts. This is essential to scaling Spinnaker to large enterprise deployments as a high-availability service. The diagram below outlines Spinnaker’s micro-service architecture.

All Spinnaker micro-services can run on a single host in a Local environment, or each on its own host in a Distributed environment.

Starting Point

Because we’re focusing on the Local environment, we must first have a VM with all of Spinnaker installed. The “Halyard on GCE Quickstart” guide is a great way to get a Halyard-enabled instance up and running.

(Semi-Optional) Load Balancer and DNS Entries

It is generally a good practice to front a service with its own load balancer, so that you can change the backing implementation (say, when a new version of Spinnaker is released) without changing the way clients connect to it. A load balancer will have a (usually static) IP address that we can bind to a DNS name. More details on configuring static IPs and connecting them to DNS can be found here.

This step is only semi-optional because most users are going to want to hook up an authentication mechanism like OAuth 2.0, which doesn’t work with raw IP addresses on some OAuth providers.

Opening Gate and Deck

With DNS entries configured, we can now open Gate and Deck for external access. To do this for a Local environment, we need to hook into the custom service settings feature of Halyard.

We’ll specify the 0.0.0.0 host in both gate.yml and deck.yml in our default Halyard deployment with this command:

echo "host: 0.0.0.0" | tee \
    ~/.hal/default/service-settings/gate.yml \
    ~/.hal/default/service-settings/deck.yml
sudo hal deploy apply

You can test this out by navigating to the instance’s public IP address on port 9000 in your browser.

Note: You may need to take further action by editing your Security Groups in order to access your instance. For example, a Google Compute Engine instance needs a firewall rule that allows ports 8084 and 9000 through. You can create these with the following commands:

INSTANCE= # put your instance's name here
TAGNAME=blogpost
gcloud compute firewall-rules create $TAGNAME-1 \
    --allow=tcp:8084,tcp:9000 \
    --target-tags $TAGNAME
gcloud compute instances add-tags $INSTANCE --tags=$TAGNAME

Map to your DNS address

Gate and Deck are now listening for all connections, and the security groups are permitting access to ports 8084 and 9000. The last thing is configuring Gate and Deck to talk to each other over their DNS names instead of IP address. This is accomplished with the following commands:

hal config security ui edit \
    --override-base-url http://spinnaker.mydomain.org:9000

hal config security api edit \
    --override-base-url http://spinnaker.mydomain.org:8084
hal deploy apply

Test it out

Your Spinnaker instance should now be available and mapped to your DNS entry:

Now that Spinnaker is exposed for your end users, you should explore our different authentication and authorization mechanisms in the Securitydocumentation.

ionic 基本调用

ionic简介

ionic是一个专注于用WEB开发技术,基于HTML5创建类似于手机平台原生应用的一个开发框架。目前绑定的与angularJS和SASS。这个框架的目的是从web的角度开发手机应用,基于PhoneGap的编译平台,可以实现编译成各个平台的应用程序。

ionic安装

首先需要安装cordova和android环境。这个参考我的另一篇文章:phoneGap之Android环境搭建,上面写的很详细,还有常见的错误及解决办法。
然后安装ionic:

1
npm install -g ionic

安装完成之后,就可以使用ionic创建项目了。

1
ionic start myApp tabs   //创建带有top栏和bottom栏的示例项目
ionic start myApp sidemenu  //创建带有左侧带有menu栏的示例项目
ionic start myApp blank   //创建空白项目

具体效果,可以查看官网: http://ionicframework.com/getting-started/
然后可以使用:

1
ionic serve

该命令会自动启动流浏览器,查看当前效果。

添加Android平台

执行下面的命令,

1
cd myApp
ionic platform add android //这行可能会报错
ionic build android
ionic emulate android

其实上面的使用方法和cordova差不多,添加android的时候可能会报错,如下:

1
The error is:
=======================================
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:1000:11)
at Process.ChildProcess._handle.onexit (child_process.js:791:34)

解决的方法很简单,将ionic换成cordova即可,经测试works fine。

1
cd myApp
cordova platform add android //这行可能会报错
cordova build android
cordova emulate android

其他常见错误

  1. 生成项目(ionic start myApp tabs)时可能会报错,如下:
    1
    Error: command failed:fatal:could not create work tree dir:'C:\Users/ADMINI~1\AppData\Local\Temp\plugman\git\1402853493773'.:No such file or directory

解决办法:进入上面对应的目录,建立对应的文件。比如在temp目录下建立plugman目录,在plugman目录下建立git目录,然后再git下建立1402853493773目录。即可,经测试有效。

css组件