How to load a remote page into a cordova Android app and able to access cordova plugins

I use Ionic Framework to develop a mobile app. This project needs loads a page (JavaScript application) into its main webView from a remote server, but also maintain access to the cordova/phonegap plugins. After many test, i finally make it works. Here is the solution Edit config.xml Running to build Copying cordova.js, cordova_plugins.js files, the plugins and lib directory to the remote server from the cordova projects platforms\android\assets\www direcory Add following sc...

Example to add item into wordpress navigation menu

依赖注入(DI) 和 控制反转(IoC)

首先依赖注入和控制反转说的是同一个东西,是一种设计模式,这种设计模式用来减少程序间的耦合,下面就以php的角度来描述一下依赖注入这个概念。 先假设我们这里有一个类,类里面需要用到数据库连接,按照最最原始的办法,我们可能是这样写这个类的: 过程: 在构造函数里先将数据库类文件include进来; 然后又通过new Db并传入数据库连接信息实例化db类; 之后getList方法就可以通过$this->_db来调用数据库类,实现数据库操作。 看上去我们实现了想要的功能,但是这是一个噩梦的开始,以后example1,example2,example3....越来越多的类需要用到db组件,如果都这么写的话,万一有一天数据库密码改了或者db类发生变化了,岂不是要回头修改所有类文件? ok,为了解决这个问题,工厂模式出现了,我们创建了一个Factory方法,并通过Factory::getDb()方法来获得db组件的实例: sample类变成: 这样就完美了吗?再次想想一下以后example1,example2,example3.......
affiliate_link

关于IOC 控制反转

1. IoC理论的背景 我们都知道,在采用面向对象方法设计的软件系统中,它的底层实现都是由N个对象组成的,所有的对象通过彼此的合作,最终实现系统的业务逻辑。 图1:软件系统中耦合的对象 如果我们打开机械式手表的后盖,就会看到与上面类似的情形,各个齿轮分别带动时针、分针和秒针顺时针旋转,从而在表盘上产生正确的时间。图1中描述的就是这样的一个齿轮组,它拥有多个独立的齿轮,这些齿轮相互啮合在一起,协同工作,共同完成某项任务。我们可以看到,在这样的齿轮组中,如果有一个齿轮出了问题,就可能会影响到整个齿轮组的正常运转。 齿轮组中齿轮之间的啮合关系,与软件系统中对象之间的耦合关系非常相似。对象之间的耦合关系是无法避免的,也是必要的,这是协同工作的基础。现在,伴随着工业级应用的规模越来越庞大,对象之间的依赖关系也越来越复杂,经常会出现对象之间的多重依赖性关系,因此,架构师和设计师对于系统的分析和设计,将面临更大的挑战。对象之间耦合度过高的系统,必然会出现牵一发而动全身的情形。 图2:对象之间复杂的依赖关系 耦合关系不仅会出现在对象与对象之间,也会出现在...

How to disable SSH timeout

Inactive or idle SSH connections are normally disconnected by the server after a certain period of time. This depends on how the SSH server is configured, and upon disconnection the SSH client will be prompted with a message similar to the following; This could be avoided by changing the SSH server's configuration, or tricking the server from the client's end. SSH Client This is probably the easiest method as it doesn't require root or administrator access to the server and it cou...

Simplest solution to fix ssh host key has changed

Here is the simplest solution to fix this issue. This will update the offending of your host from the known_hosts.

Leave Page Alert When Form Field Changes

This demo will show you how to monitor the form field changes, and display a message box when user try to leave the page before the submit form.

Fix Opencart Fedex Shipping Error

I'm using Opencart 1.5.6.4 and the default FedEx module doesn't display any shipping options during checkout. I changed code and get response message: After contact with FedEx technical support, i found the problem is caused by StateOrProvinceCode. The script use Zone Name as value, but it need to use Zone Code. For example, after we change 'Ontario' to 'ON', the FedEx shipping options can success list during checkout. All you need to do is open file 'catalog/model/shippin...

Linux系统下PHP发送邮件失败的解决办法

是否安装Sendmail 检查下php.ini设置是否正确 cat /etc/php.ini | grep sendmail_path 正确的结果应该类似这样 sendmail_path = sendmail -t -i 检查下sendmail是否安装 which sendmail 正常的结果应该类似这样 /usr/sbin/sendmail 如果上面的路径没有找到sendmail 检查下是否安装了包 yum list installed | grep sendmail 这时的情况又分为二种: 如果安装了这个包,就给卸载了重新装一遍。 如果没装,直接装上。 sendmail---stat=Service unavailable 今天尝试着想要在linux终端上直接用mail命令(e.g: echo "hello" | mail -s "hello test" xxx@139.com)给我139.com的邮箱发邮件时,139.com邮箱根本收不到,但是总是可以在/var/mail/root下面找到我刚才发的邮件,其实这是因为发送失败了,从而被sen...

JQuery Check if Window is in iFrame

Simple JavaScript code snippet to check whether or not a window is in an iFrame. Very useful for some functions that may make use of the URL in the address bar of the page.