2017年3月

应用jQuery实现点击阅读更多功能

[scfc id=”1″ title=”标题啦啦啦”]内容是这里 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud [/scfc]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
继续阅读

游戏开发手札1

简单尝试了一下Low Poly风格的建模,搭建基础场景。

3dsmax 2012里建模、调整材质、UVW贴图展开、合并材质球。

Unity里把重复场景素材如树木等制成prefab,添加碰撞体。

待办:

  1. 目前场景里还是有很多多余的面,实际游戏里并不会探索到的区域需要减少面数,降低精度;
  2. 确定场景搭配后,将所有组件的贴图合并成单张UV贴图;
  3. 斟酌配色;
  4. 考虑第一人称VS第三人称的选择;
  5. 尝试使用Unreal、Maya、Blender、C4D等其他工具,进行横向对比

Lost Admin Privileges – Getting WordPress Admin Access Back « Tips and Tricks HQ Forum
http://www.tipsandtricks-hq.com/forum/topic/lost-admin-privileges-getting-wordpress-admin-access-back

Beginner’s Guide to Fixing Your Hacked WordPress Site
http://www.wpbeginner.com/beginners-guide/beginners-step-step-guide-fixing-hacked-wordpress-site/

How I Cleaned Up My WordPress Site After It Was Hacked and Blacklisted – WPMU DEV

How I Cleaned Up My WordPress Site After It Was Hacked and Blacklisted

What To Do When You Are Locked Out of WordPress Admin (wp-admin)
http://www.wpbeginner.com/wp-tutorials/locked-out-of-wordpress-admin/

How to Add an Admin User to the WordPress Database via MySQL
http://www.wpbeginner.com/wp-tutorials/how-to-add-an-admin-user-to-the-wordpress-database-via-mysql/

 

黑客的攻击手段

How to find a backdoor in a hacked WordPress » Otto on WordPress
http://ottopress.com/2009/hacked-wordpress-backdoors/

 

看技术博客发现了一个蛮有趣的js程序,似乎可以加到博客里,方便展示代码。

http://alexgorbatchev.com/SyntaxHighlighter/

挖个坑待续。

 

A GIMP Python plugin that auto-generates a poster with any 5 images

 

#!/usr/bin/env python

# GIMP Python
# This plugin will create a A4 size, 300dpi poster with 5 images and some texts.

import os
from gimpfu import *

def poster(file0, file1, file2, file3, file4, font1, font2, savePath, posterName):

# create an empty image
posterWidth = 2480
posterHeight = 3508
width = 1000
height = 1000
bgHeight = 960
posterImage = gimp.Image(posterWidth, posterHeight, RGB)
gimp.Display(posterImage)

# load background image and the 4 images related with theme
bg1 = pdb.file_jpeg_load(file0, file0)
image0 = pdb.file_jpeg_load(file1, file1)
image1 = pdb.file_jpeg_load(file2, file2)
image2 = pdb.file_jpeg_load(file3, file3)
image3 = pdb.file_jpeg_load(file4, file4)
image4 = image3

# resize the 4 images
pdb.gimp_image_resize(bg1, posterWidth, bgHeight, 0, 0)
pdb.gimp_image_resize(image0, width, height, 0, 0)
pdb.gimp_image_resize(image1, width, height, 0, 0)
pdb.gimp_image_resize(image2, width, height, 0, 0)
pdb.gimp_image_resize(image3, width, height, 0, 0)

# create background layer and fill it with white
layerbg = gimp.Layer(posterImage, “Layer Back”, posterWidth, posterHeight, RGB_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layerbg, 0)
gimp.set_background(255, 255, 255)
pdb.gimp_edit_fill(layerbg, BACKGROUND_FILL)
#pdb.gimp_edit_fill(layerbg, WHITE_FILL)

# make background blurred image layer for title
radius = 50.0
layerbg1 = gimp.Layer(posterImage, “Title Background”, posterWidth, posterHeight/3, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layerbg1, 0)
pdb.gimp_edit_copy(bg1.layers[0])
layerbg1.update(0, 0, posterWidth, bgHeight)
layerbg1.translate(0,-120)
layerbg1 = pdb.gimp_edit_paste(layerbg1, True)
pdb.plug_in_gauss( bg1, layerbg1, radius, radius, 1)

# make background blurred image layer for reasons
layerbg2 = gimp.Layer(posterImage, “Reason Background”, posterWidth, posterHeight/3, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layerbg2, 0)
pdb.gimp_edit_copy(bg1.layers[0])
layerbg2.update(0, 0, posterWidth, bgHeight)
layerbg2.translate(0,posterHeight-bgHeight)
layerbg2 = pdb.gimp_edit_paste(layerbg2, True)
layerbg2 = pdb.gimp_item_transform_flip_simple (layerbg2, 1, True, 500)
layerbg2.translate(0,490)
pdb.plug_in_gauss( bg1, layerbg2, radius, radius, 1)
#layerbg2 = pdb.gimp_image_flip(layerbg2, 1.0, 500.0, 2000.0, 500.0)
#layerbg2 = pdb.gimp_item_transform_flip(layerbg2, ORIENTATION_HORIZONTAL)

# add title
font = ‘Impact’
size = 206
str1 = “WHY AUTUMN IS THE BEST”
str2 = “SEASON”
str3 = “It’s colorful. It’s a season of joy”
gimp.set_foreground((255, 255, 255)) # set color to white
layertxt1 = pdb.gimp_text_fontname(posterImage, None, 240, 240, str1, 10, True, size, PIXELS, font)
layertxt2 = pdb.gimp_text_fontname(posterImage, None, posterWidth/3+110, 480, str2, 10, True, size, PIXELS, font)
layertxt3 = pdb.gimp_text_fontname(posterImage, None, posterWidth/3-220, posterHeight-240, str3, 10, True, size/2, PIXELS, font)
# add content texts
str4 = “Blooming”
str5 = “Passionate”
str6 = “Harvest”
str7 = “Cosy”
font2 = ‘Agency FB’
gimp.set_foreground((50, 50, 50)) # set color to dark grey
layerstr4 = pdb.gimp_text_fontname(posterImage, None, 320, 2440, str4, 2, True, size/2, PIXELS, font2)
layerstr5 = pdb.gimp_text_fontname(posterImage, None, posterWidth/3-220, posterHeight-670, str5, 2, True, size/2, PIXELS, font2)
layerstr6 = pdb.gimp_text_fontname(posterImage, None, 1600, posterHeight-670, str6, 2, True, size/2, PIXELS, font2)
layerstr7 = pdb.gimp_text_fontname(posterImage, None, posterWidth-505, 2440, str7, 2, True, size/2, PIXELS, font2)

# make layer 0
gimp.set_foreground((255, 255, 255))
angle = -3.14/4
posx0, posy0 = 250, 1562
layer0 = gimp.Layer(posterImage, “Layer 0”, width, height, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layer0, 0)
pdb.gimp_edit_copy(image0.layers[0])# layers are all layers, but jpg only has one layer 0
layer0.update(0, 0, width, height)
layer0.translate(posx0,posy0)
layer0 = pdb.gimp_edit_paste(layer0, True)
layer0 = pdb.gimp_item_transform_rotate(layer0, angle, True, 0, 0)

# make layer 1
layer1 = gimp.Layer(posterImage, “Layer 1”, width, height, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layer1, 0)
pdb.gimp_edit_copy(image1.layers[0])
layer1.update(0, 0, width, height)
layer1.translate(posx0+500,posy0-500)
layer1 = pdb.gimp_edit_paste(layer1, True)
layer1 = pdb.gimp_item_transform_rotate(layer1, angle, True, 0, 0)

# make layer 2
layer2 = gimp.Layer(posterImage, “Layer 2”, width, height, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layer2, 0)
pdb.gimp_edit_copy(image2.layers[0])
layer2.update(0, 0, width, height)
layer2.translate(posx0+1000,posy0)
layer2 = pdb.gimp_edit_paste(layer2, True)
layer2 = pdb.gimp_item_transform_rotate(layer2, angle, True, 0, 0)

# make layer 3
layer3 = gimp.Layer(posterImage, “Layer 3”, width, height, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layer3, 0)
pdb.gimp_edit_copy(image3.layers[0])
layer3.update(0, 0, width, height)
layer3.translate(posx0+500,posy0+500)
layer3 = pdb.gimp_edit_paste(layer3, True)
layer3 = pdb.gimp_item_transform_rotate(layer3, angle, True, 0, 0)

# make layer 3 clone
layer4 = gimp.Layer(posterImage, “Layer 4”, posterWidth, posterHeight, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layer4, 0)
pdb.gimp_edit_copy(image4.layers[0])
layer4.update(0, 0, width, height)
layer4.translate(posx0,posy0)
pdb.gimp_edit_paste(layer4, True)
#layer4 = pdb.gimp_item_transform_rotate(layer3, angle, True, 0, 0)

# draw two crossing lines
length = 2545
pdb.gimp_selection_none(posterImage) # de-select all
gimp.set_foreground((90, 90, 90))# set foreground color dark grey
layerline1 = gimp.Layer(posterImage, “Layer Cross Line 1”, posterWidth+1000, posterHeight, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layerline1, 0)
layerline1.update(0, 0, 2*posterWidth, 2*posterHeight)
pdb.gimp_image_select_rectangle(posterImage, 2, posx0, posy0, length, 9)# OPERATION=2 means CHANNEL-OP-REPLACE
pdb.gimp_edit_fill(layerline1, 0) # Fill selected area of drawable with foreground

# adjust crossing lines to center
layerline1 = pdb.gimp_item_transform_rotate(layerline1, 3.14/4, False, posterWidth/2, posy0)
layerline1.translate(62,550)

layerline2 = pdb.gimp_layer_copy(layerline1, True)
posterImage.add_layer(layerline2, 0)
layerline2.translate(-280,-280)

layerline3 = pdb.gimp_layer_copy(layerline1, True)
posterImage.add_layer(layerline3, 0)
layerline3 = pdb.gimp_item_transform_flip_simple (layerline3, 1, False, 2062)

layerline4 = pdb.gimp_layer_copy(layerline2, True)
posterImage.add_layer(layerline4, 0)
layerline4 = pdb.gimp_item_transform_flip_simple (layerline4, 1, False, 2062)

# create thin lines for title
titlew, titleh = 640, 20
gimp.set_foreground((255, 255, 255))
layerline3 = gimp.Layer(posterImage, “Layer Title Line 1”, posterWidth, titleh, RGBA_IMAGE, 100, NORMAL_MODE)
posterImage.add_layer(layerline3, 0)
layerline3.update(0, 0, posterWidth, 10)
#pdb.gimp_image_select_rectangle(posterImage, 0, 240, 500, titlew, titleh)# OPERATION=0 means CHANNEL-OP-ADD
#pdb.gimp_image_select_rectangle(posterImage, 0, 240+posterWidth/2, 500, titlew, titleh)
pdb.gimp_image_select_rectangle(posterImage, 0, 0, 0, titlew, titleh)# OPERATION=0 means CHANNEL-OP-ADD
pdb.gimp_image_select_rectangle(posterImage, 0, 110+posterWidth/2, 0, titlew, titleh)
pdb.gimp_edit_fill(layerline3, 0) # Fill selected area of drawable with foreground
layerline3.translate(270,600)
pdb.gimp_selection_none(posterImage) # de-select all

# clear layer4
pdb.gimp_edit_clear(layer4)
theDrawable = posterImage.active_drawable
posterXcfName = posterName + ‘.xcf’
filename = os.path.join(savePath, posterXcfName)
pdb.gimp_xcf_save(1, posterImage, theDrawable, filename, filename)

posterJpgName = posterName + ‘.jpeg’
jpgName= os.path.join(savePath, posterJpgName)
#pdb.file_jpeg_save(1, posterImage, theDrawable, jpgposterName, jpgposterName, 0.8, 0.5, 1, 0, ‘Poster designed by BAIXUAN WANG’, 3, 1, 0, 0)

# save as jpeg file
pdb.gimp_edit_copy_visible(posterImage)
new_img = pdb.gimp_edit_paste_as_new()
pdb.file_jpeg_save(new_img, new_img.layers[0], jpgName, jpgName, 0.8, 0.5, 1, 0, “Poster designed by BAIXUAN WANG with gimp python”, 3, 1, 0, 0)
pdb.gimp_image_delete(new_img)

register(
“python_fu_poster_bw”,
“BW Poster Maker”,
“This plugin createds a poster with 5 images and texts”,
“Baixuan Wang”,
“Copyright@BaixuanWang”,
“2016”,
“BW Poster Maker”,
“”,
[
# add imput parameter for the function arguments
(PF_FILE, “file0”, “Choose Background”, “”),
(PF_FILE, “file1”, “Choose Image 1”, “”),
(PF_FILE, “file2”, “Choose Image 2”, “”),
(PF_FILE, “file3”, “Choose Image 3”, “”),
(PF_FILE, “file4”, “Choose Image 4”, “”),
(PF_FONT, “font”, “Title Font”, “Impact”),
(PF_FONT, “font”, “Content Font”, “Agency FB”),
(PF_DIRNAME, “savePath”, “Directory to save image”, “C:/”),
(PF_STRING, “posterName”, “Poster Base Name”, ‘poster’),
],
[],
poster, menu=”<Image>/Filters”
)

main()

GDC2017相关资讯

AR

Designing for AR: A Postmortem on the Development of ‘Woorld’ – YouTube
这款游戏借助了Google Tango的室内空间扫描+虚拟重建模型技术,探戈的名字取得蛮有趣的。开发者有Unity API/JAVA/C三个选项可以入手,不过相应的,支持这一技术的安卓手机有限,官网推荐了联想的Phab 2 Pro作为第一款率先支持Tango的手机作为开发机。

Funomena是旧金山的一个游戏工作室,这次演讲的嘉宾Vu Ha分享了蛮多AR设计、游戏内互动、引导玩家在开放的AR世界里找到游戏设计好的内容相关经验。

 

 

unity的character controller方法修改

[搬运2014年旧笔记]

物体方向控制方法

  1. function Update(){
  2.       if(Input.GetKey(KeyCode.W){
  3.            transform.Translate(Vector3.forward*Time.deltaTime*2);
  4.       }else if(Input.GetKey(KeyCode.S){
  5.            transform.Translate(Vector3.forward*Time.deltaTime*-2);
  6.       }else if(Input.GetKey(KeyCode.A){
  7.            transform.Translate(Vector3.up*Time.deltaTime*-20);
  8.       }else if(Input.GetKey(KeyCode.A){
  9.            transform.Translate(Vector3.up*Time.deltaTime*20);
  10.       }
  11.  }
修改unity自带character controller代码,实现鼠标右键按下后再旋转视角的功能。(可查阅MouseLook.cs)
  1. if (Input.GetMouseButton (1)) {
  2.     if (axes == RotationAxes.MouseXAndY) {//鼠标右键按下后再旋转视角
  3.         float rotationX = transform.localEulerAngles.y + Input.GetAxis (“Mouse X”) * sensitivityX;
  4.         rotationY += Input.GetAxis (“Mouse Y”) * sensitivityY;
  5.         rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
  6.         transform.localEulerAngles = new Vector3 (-rotationY, rotationX, 0);
  7.         } else if (axes == RotationAxes.MouseX) {
  8.             transform.Rotate (0, Input.GetAxis (“Mouse X”) * sensitivityX, 0);
  9.         } else {
  10.             rotationY += Input.GetAxis (“Mouse Y”) * sensitivityY;
  11.             rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
  12.             transform.localEulerAngles = new Vector3 (-rotationY, transform.localEulerAngles.y, 0);
  13.             }

XAMPP虚拟主机VirtualHost配置随笔

[搬运2015年旧笔记]

本文列举了配置XAMPP虚拟主机VirtualHost可能遇到的错误。

错误表现为:

Apache Access forbidden! Error 403

No Object Found 404

涉及到的文件:

1、mac系统相关

/private/etc/apache2/httpd.conf(默认配置)

/private/etc/apache2/extra/httpd-vhosts.conf(默认配置)

/private/etc/hosts(增加虚拟主机的配置 127.0.0.1  example.com)

2、xampp相关

/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf(重要配置步骤)

需要设置两个虚拟主机,一个是给默认的localhost,一个是给自己的example.com

给默认localhost的:

<VirtualHost *:80>
ServerName localhost
DocumentRoot “/Applications/XAMPP/htdocs”
<Directory “/Applications/XAMPP/htdocs”>
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>

给自己的(可以增加数量):

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot “/Applications/XAMPP/xamppfiles/htdocs/dummy”
ServerName dummy.com
ServerAlias www.dummy.com
<Directory “/Applications/XAMPP/xamppfiles/htdocs/dummy”>
Require all granted
</Directory>
ErrorLog “/private/var/log/apache2/dummy-error_log”
CustomLog “/private/var/log/apache2/dummy-access_log” common
</VirtualHost>

/Applications/XAMPP/xamppfiles/etc/extra/httpd-xampp.conf(不确定需不需要改)

<Directory “/Applications/XAMPP/htdocs”>
Options All
AllowOverride All
Require all granted
</Directory>

/Applications/XAMPP/xamppfiles/etc/httpd.conf(需要开启vhost,去除注释,以及更改权限)

以下修改

<Directory />
#AllowOverride none
#Require all denied
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

以下几行取消注释

Include etc/extra/httpd-xampp.conf
Include /Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf

# Virtual hosts
Include /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
Include etc/extra/httpd-vhosts.conf

最后,如果cakephp工程包是从别的地方搬迁过来的,需要注意!!!!!

.htaccess等隐藏文件会被遗忘,rewrite设置会被忽略掉的,.gitignore也被忽略了,都要手动搬迁。

如何用WordPress搭建多站点博客

去年购买了域名,创建了英文站点,最近有一些想法很希望写到中文的博客中,虽然之前已经有了CSDN和网易LOFTER,想想既然有自己的域名干脆就在这边建立一个二级域名吧。

这次设立二级域名主要是为了分离不同的语言,建立多语言站点有两种做法:

1、希望内容为中英文两个版本对照出现,适用于机构、商业性站点,需要保持信息的即时、同步,可以求助于WordPress强大的插件库:

WPGlobus, Polylang, qTranslate 或 xili-language 都是可在单一 WordPress 网站副本中安装的插件。对于多站点 WordPress (即每个语言一个站点),你需要尝试 Multisite Language Switcher, Zanto 或 Multilingual Press, 也可以选择购买 WPML. ——摘自WP支持页面

不过我这次并没有这种需求,所以选择了第二个方案:
2、利用WordPress3.0以后出现的Site Network功能,修改根目录下的wp-config.php和.htacess,创建一个超级管理员身份,就可以创建二级域名(subdomain)了。

根据网上的攻略,可以在public_html根目录下直接添加一个cn文件夹,然后将wordpress相关的文件(除wp-config.php以外)复制到cn目录下,之后就可以访问baixuanwang.com/cn进行配置,生成wp-config.php,如图:

 

但这种方案要求我拥有数据库用户名和密码,尴尬的我当初购买域名时使用的是ReclaimHosting的服务,所以第一个数据库直接扔给他们自动配置了,一时之间想不起来密码,只能作罢。

于是我开始研究官方说法里的multisite,首先第一步备份,第二步让服务器支持wildcard subdomain,否则这边就算配置好了也无法解析。

子域名必须和“通配符子域名”搭配工作,配置需要两步:

  1. Apache 必须设置为支持通配符。
    1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
    2. 添加此行:
      ServerAlias *.example.com
  2. 在DNS解析中添加一行带有通配符的子域名解析记录:
    A *.example.com

如果你的服务器使用CPanel管理面板,用*.baixuanwang.com新建一个子域名,给wordpress创建的子域名解析权限,不要在CPanel里直接把想要的名字创建了,会造成冲突。

如果这一步无法操作,就需要联系服务器提供商,比如我就给ReclaimHosting发了封邮件表示要申请wildcard subdomain,co-founder Tim Owens很快就回复解答了这个问题,帮我加了wp所需的wildcard配置。

做好准备工作后,首先在public_html/wp-config.php的/* That’s all, stop editing! Happy blogging. */一行之前插入:

define('WP_ALLOW_MULTISITE', true);

刷新站点,重新登录,进入管理面板-Tool-Network Setup,输入你的站点名称和邮箱,该邮箱即为超级管理员。

保存设置后,wp将会提示你两步操作:

A. 更改public_html/wp-config.php,插入上图选中部分到/* That’s all, stop editing! Happy blogging. */一行之前

B. 打开public_html/.htacess(隐藏文件,如果找不到的话,试试更改文件夹权限)

备份文件后,将全部的内容替换为红色箭头所指的文本

完工!

之后就可以用一个账号管理多个站点,两边写的内容也是互不影响的。