SAE未备案域名加速

众所周知,SAE对于未备案的域名比较的不仁慈,访问二级域名还好说,但对于大多数绑定顶级域名而又苦于备案的站长来说,不但得不到SAE的高速,反而变得更慢。虽然通过DNSPOD+加速乐/360DNS等免费资源可以实现双DNS加速,以及开启GZIP对网站改良的措施,对网站速度有了一定的改观,但毕竟使用的是海外代理,速度终究不理想。

网站的速度无论从SEO角度还是用户体验方面来说,都是一个网站不可忽视的要素,相信众多站长长期奔走于对此优化的道路上,由此也引出了一些极其优秀的缓存软件,诸如Hyper Cache、W3 Total Cache、Wp Super Cache这些插件在网站的优化上有着极其优秀的表现,然而对于驻扎在SAE上的用户来说,目录写入权限是不可改变的硬伤。所以这些所谓的加速神器也是爱莫能助了,加之SAE的优化方法少之又少,除了压缩和DNS外似乎别无他法。

本人也是经过长期致力于此,最终发现一个好方法,作为福利共享出来-SAE未备案域名加速插件:

这个插件的作用主要是用来加速SAE未备案域名的访问速度,用创新的方法实现加速:采用的策略是将资源文件通过SAE二级域名进行访问,而将网站主要文件通过主域名访问,进而加快了访问速度。这个插件最初是由SAE云商店用于加速wordpress的访问,当然在SAE上也是可以使用的,由于SAE和云商店环境的细微差异,所以在SAE只需要稍加修改即可使用,下面是已经修改的可以在SAE使用的插件源代码。

<?php
if(isset($_SERVER['HTTP_APPNAME'])){
add_filter('pre_option_siteurl','ysd_siteurl');
add_filter('pre_option_home','ysd_home');
add_filter('site_url','ysd_site_url',10,2);
add_filter('login_url','ysd_login_url');
add_filter('logout_url','ysd_logout_url');
add_filter('admin_url','ysd_admin_url');
add_action('wp_before_admin_bar_render','ysd_before_admin_bar_render');
add_action('wp_after_admin_bar_render','ysd_after_admin_bar_render');
}
function ysd_siteurl(){
return 'index.php'==basename($_SERVER['SCRIPT_FILENAME']) && false===strpos($_SERVER['SCRIPT_FILENAME'], 'wp-admin')?'http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com':'http://'.$_SERVER['HTTP_HOST'];
}
function ysd_home(){
return 'http://'.$_SERVER['HTTP_HOST'];
}
function ysd_site_url($url,$path){
if(in_array($path,array('wp-login.php?action=register','/wp-comments-post.php'))){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$url);
}else{
return $url;
}
}
function ysd_before_admin_bar_render(){
ob_start();
}
function ysd_after_admin_bar_render(){
echo str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],ob_get_clean());
}
function ysd_login_url($login_url){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$login_url);
}
function ysd_logout_url($logout_url){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$logout_url);
}
function ysd_admin_url($url){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$url);
}
?>

 

 

Welcome to Swift

Welcome to Swift

Swift is a new object-oriented programming language for iOS and OS X development. Swift is modern, powerful, and easy to use.

  • let people = ["Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25]
  • for (name, age) in people {
  • println("(name) is (age) years old.")
  • }

 


The Swift Programming Language

The complete guide and reference to the Swift programming language.

  • Take an interactive tour of language features that make app development easier, faster, and more reliable.

  • Learn Swift concepts, principles, and syntax through comprehensive descriptions and code examples.

  • Dive into the details of the language with a thorough discussion of its behavior, syntax, and grammar.

Using Swift with Cocoa and Objective-C

Tools and strategies for integrating Swift into the Cocoa app development process.

  • Learn how to interact with Cocoa frameworks in a Swift environment.

  • Take advantage of Swift language features to build on Objective-C APIs, and improve the way you write Cocoa apps.

  • Create a mixed-language app using Swift and Objective-C.

  • Explore strategies to migrate your app to Swift.

运行在SAE上的WordPress修改Storage地址的方法

找到wp-includes/functions.php在大约第1714行找到

1 $url 'http://' $_SERVER['HTTP_APPNAME'] . '-'.SAE_STORAGE.'.stor.sinaapp.com'.SAE_DIR;

‘.stor.sinaapp.com’替换为‘.stor.vipsinaapp.com’
保存,覆盖。
只是这样子还不行,原来的图片还是使用*.stor.sinaapp.com的地址,我们需要进去PHPMYADMIN,执行

1 UPDATE wp_posts SET post_content = replace(post_content, 'http://***.stor.sinaapp.com','http://***.stor.vipsinaapp.com')

其中:’http://***.stor.sinaapp.com’替换成你原来的Storage地址,’http://***.stor.vipsinaapp.com’替换成现在的Storage地址。
然后看看自己主题以及插件中是否调用了原来的Storage地址,修改过来即可。

收集Bing背景图片

本例是用Python Image Library(PIL)的Image模块进行图片处理,并把保存的图片设置成桌面。在此之前,当然还是要用urllib取得网站的response。
PIL 是Python下最有名的影像处理套件,由许多不同的模块所组成,并且提供了许多的处理功能,允许我们在简单的Python程序里进行影像的处理。 使用像 PIL 这样的程序库套件可以帮助我们把精力集中在影像处理的工作本身,避免迷失在底层的算法里面。由于影像处理牵涉到了大量的数学运算,因此PIL中有許多的模块是用 C 语言所写成的,以提升处理的效率。
详细参考请看这里。
当我们使用微软的Bing的时候,会发现每天背景图片都是不一样的,但每张都很漂亮。鉴于最近在学习python,就萌生了获取每日Bing图片的想法,代码取自网上,我只是做了分析。
如果想看以前的,到Bing Image Archive来看,如果想下载请使用Bing Downloader
工作步骤:
  1. 取得Bing的response,分析一下Bing主页的源代码,有var g_img={url:’/fd/hpk2/ShuBrocade_ZH-CN760216482.jpg’,id:’bgDiv’,d:200,cN:’_SS’,crN:’bIm’,hash:’648′};sc_bgL(),在这里就是需要取得背景图片的地方。因为整个源代码只有这一处,所以可以用index(‘ ‘g_img={url:‘)的方法去过滤背景图片的地址:content = urllib.urlopen(‘http://cn.bing.com/’).read()
    tempStr = content[content.index(‘g_img={url:’)+12 : len(content)]
    tempStr = tempStr[0 : tempStr.index(‘,id:’)-1]
    tempStr = tempStr.replace(”, ”)
    bgImageUrl = ‘http://cn.bing.com’+tempStr
  2. 下载图片的时候,使用urlretrieve(url, filename=None, reporthook=None, data =None)
  3. 使用win32gui.SystemParametersInfo(Action, Param, WinIni)
2025 年 8 月
 123
45678910
11121314151617
18192021222324
25262728293031

广告

分类

近期评论

标签

历史上的今天

    历史上的今天没有存档

归档