orz像素脸图。。。

随机对称生成的脸图【?】








orz





	

唔……

?

?

脑壳logo



	




?

某烟火(canvas)


	
		
	
	
				
	
	
		
		

bat遍历文件夹...

@echo off 
set work_path=./res
cd %work_path% 
for /R %%s in (.,*) do ( 
echo %%s 
) 

JavaScript拖拽文件作为背景图







DROP!!!!!!!!!!



ScrollView的scrollToPercentHorizontal滚动距离相关笔记

手册:

scrollToPercentHorizontal(float percent, float time, bool attenuated);//水平滚动容器内容到滚动视图宽度百分比位置上

然而这并没有什么卵用。

?

笔记:

第一个参数percent将使内部容器向左滚动(内部容器宽度 - 滚动层宽度) * percent 像素的距离

第二个参数time为滚动时间,单位为秒

第三个参数attenuated为true时使滚动过程拥有减速效果

?

所以想要使内部容器0.5s内减速向左滚动x像素可以调用

float percent = 100.0f * x / (scroll->getInnerContainerSize().width - scroll->getContentSize().width)

scroll->scrollToPercentHorizontal(percent, 0.5f, true);

?

从前的一个A*

以前的一个a*练习,搬过来凑个数……

A*算法描述见这篇博文

ruby代码:

#encoding=utf-8
MAP = [
		[0, 0, 0, 0, 0, 0, 0, 0],
		[0, 0, 0, 1, 0, 0, 0, 0],
		[0, 0, 0, 1, 0, 0, 0, 0],
		[0, 0, 0, 1, 1, 0, 1, 0],
		[0, 0, 0, 1, 0, 0, 0, 0],
		[0, 0, 0, 1, 0, 0, 0, 0],
		[0, 0, 0, 1, 0, 0, 0, 0],
		[0, 0, 0, 0, 0, 0, 0, 0],		
	  ]		
class Point
	attr_accessor		:x
	attr_accessor		:y
	attr_accessor		:g
	attr_accessor		:h
	attr_accessor		:f
	attr_accessor		:parent
	def initialize(x, y, parent)
		self.x = x
		self.y = y
		self.parent = parent
	end
	def to_s
		"#{super.to_s}, #{[self.x, self.y, self.g, self.h, self.f]}"
	end
end

$open = {}
$close = {}

def find(sx, sy, ex, ey)
	startP = Point.new(sx, sy, nil)
	startP.g = 0
	pos = startP
	while (!$open[[ex, ey]]) do
		dealAround(pos, ex, ey)	# 检查周围元素,计算f
		pos = getMinFPos
	end
	pos = $open[[ex, ey]]
	path = []
	while (pos.parent) do
		path << [pos.x, pos.y]
		pos = pos.parent
	end
	path << [pos.x, pos.y]
	for y in 0...MAP.size
		for x in 0...MAP[0].size
			print (path.include?([x, y])) ? "☆" : (MAP[y][x] == 0 ? "□" : "■")
		end
		print "\r\n"
	end
	p path
end
def getMinFPos
	return nil if $open.size < 1
	minG = $open.values[0].g
	minGPos = $open.values[0]
	$open.values.each{|pos|
		if minG > pos.g
			minG = pos.g
			minGPos = pos
		end
	}
	return minGPos
end
def dealAround(pos, endx, endy)
	# 将pos加入close列表
	$close[[pos.x, pos.y]] = pos	
	# 将pos从open列表中移出
	$open.delete([pos.x, pos.y])
	# 检查周围元素
	[[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]].each{|posOffset|
		# 跳过边界
		next if pos.x + posOffset[0] < 0 or pos.y + posOffset[1] < 0 or pos.x + posOffset[0] > MAP[0].size - 1 or pos.y + posOffset[1] > MAP.size - 1
		# 跳过不可通行的方块
		next if MAP[pos.y + posOffset[1]][pos.x + posOffset[0]] != 0
		# 跳过close列表
		next if $close[[pos.x + posOffset[0], pos.y + posOffset[1]]]
		
		newPos = Point.new(pos.x + posOffset[0], pos.y + posOffset[1], pos)
		# 计算g
		if posOffset[0].abs + posOffset[1].abs == 2 # 斜向
			newPos.g = pos.g + 14
		else
			newPos.g = pos.g + 10
		end
		# 计算h
		newPos.h = (endx - newPos.x).abs * 10 + (endy - newPos.y).abs * 10
		# 计算f
		newPos.f = newPos.g + newPos.h
		# 添加到open列表
		if $open[[newPos.x, newPos.y]] # 已存在
			thePos = $open[[newPos.x, newPos.y]]	
			tempG = ((thePos.x - pos.x).abs + (thePos.y - pos.y).abs == 2) ? (pos.g + 14) : (pos.g + 10)
			if tempG < thePos.g	# 当前节点使g更小
				thePos.g = tempG
				thePos.f = tempG + thePos.h
				thePos.parent = pos	# 修改父节点为当前节点
			end
		else	# 不存在
			$open[[newPos.x, newPos.y]] = newPos
		end
	}
end

find(0, 0, 7, 7)

?

实、实验报告......

TAT以下是折腾docker折腾quick-server0.4.0的经历,而非过程
?
?
查看镜像:
docker@boot2docker:~$ docker images
?
运行镜像并进到bash模式,映射8080端口到宿主50002端口:
docker@boot2docker:~$ docker run -t -i -p 50002:8080 chukong/quick-server:0.4.0
?
关闭镜像并保存:
记下当前id: |root@ID| ←
|root@ID| exit
docker@boot2docker:~$ docker commit ID chukong/quick-server:0.4.0
?
开启ssh后台运行镜像:
docker@boot2docker:~$ docker run -d -p 50003:22 chukong/quick-server:0.4.0 /usr/sbin/sshd -D
?
创建用户sure52:
|root@ID| useradd sure52
|root@ID| passwd sure52
?
建立git仓库:
|root@ID| cd /home/sure52
|root@ID| mkdir qs_code
|root@ID| chmod o+w -R qs_code
|root@ID| cd qs_code
|root@ID| git init
|root@ID| vim README.md
|root@ID| git add "."
|root@ID| git commit -m "base version"

|root@ID| git remote add origin ssh://sure52@127.0.0.1/home/sure52/qs_code/.git
|root@ID| git push origin
|root@ID| git remote show origin
?
测试git仓库
E:\> git clone ssh://sure52@192.168.59.103:50003/home/sure52/qs_code/.git
?
push 无写权限remote: fatal: failed to write object解决:
|root@ID| chmod -R 777 .git
?
push master -> master (branch is currently checked out)出错解决:
|root@ID| cd .git
|root@ID| vi config
? ? 添加: ? ?
? ? ? ?[receive]
? ? ? ?denyCurrentBranch = ignore
?
Quick-Server取session_id:
curl "http://192.168.59.103:50002/_server/user/session/?id=sure52"
?
提交usercode:
? ? 本地路径结构:
? ??module1/actions/SayHello.lua
? ??提交至
? ??/home/sure52/qs_code/module1/actions/Sayhello.lua
? ??实际运行时
? ??/opt/qs/openresty/server/user_codes/module1/actions/SayHello.lua
? ??config.lua配置:
userDefinedCodes = {
	luaRepoPrefix = "server.user_codes",
	localRepo  = "/home/sure52/qs_code/",
	localDest  = "/opt/qs/openresty/server/user_codes",
	--localRepo = "/home/cheeray/work/user_codes",
	--localDest = "/home/cheeray/work/quick-server/src/server/user_codes",
	uriPrefix  = {
		module1 = "http_test1",
		module2 = "http_test2",
	},
},
? ? 运行命令:
curl "http://192.168.59.103:50002/_Server/user/uploadcodes?commit=f54ab5e0ddd0d93b55ae4f9169c25caf52a88392&session_id=f56b3cb7fc96dfb25e501c56e8f9b057"
?
sayHello:
curl "http://192.168.59.103:50002/http_test1/Say/SayHello?session_id=f56b3cb7fc96dfb25e501c56e8f9b057&name=a_name"
?
因为用的是坑爹windows……
让本机localhost:8088能直接连到容器内:(windows 127.0.0.1:8088->docker虚拟机192.168.59.103:50002->容器内x.x.x.x:8088)
? ? 在virtual box中做本机端口映射
? ??? ??VM -> 设置 -> 网络 -> 网卡1 -> 端口转发 添加
? ??? ??名称任意 协议:TCP 主机IP:127.0.0.1 主机端口:8088 子系统IP不填 子系统端口:50002
?
参考:
? ??http://www.cnblogs.com/bjfuouyang/p/3798421.html
?
?

【未完成】Window_Message(雾。。。

= =唔

?

--[[
local labelEx = require("ui.ui_label_ex"):create(300) -- width
l:addChild(labelEx, 100)
labelEx:setPosition(100, self.visibleSize.height)
labelEx:setString("普通文字$C<3>颜色$C<1>普通颜色$S<36>大小$S<0>普通大小$I<101>←图片$B

?

还没完成就是了。。。

?

切切切...

require 'sdl'
require "rexml/document"  
include REXML  
SDL.init(SDL::INIT_VIDEO)

row = 4
col = 4

filename = "citizen-1.png"
image = SDL::Surface.load(filename)
w, h = image.w, image.h
if filename[/^(.*)?\.(png|jpg|bmp)?/i]
	p $1, $2
end

picname = $1
ext = $2


doc = Document.new("")
doc << XMLDecl.new(1.0, "utf-8")
root_node = doc.add_element("plist")
root_node.attributes["version"] = "1.0"
root_dict = root_node.add_element("dict") 

# frames
frame_key = root_dict.add_element("key")
frame_key.text = "frames"
frame_dict =  root_dict.add_element("dict")

for i in 0...row
	for j in 0...col
		key = Element.new("key")
		key.text = "#{picname}_#{i * col + j}.#{ext}"
		dict = Element.new("dict")
		# dict
		ek = []
		ev = []
		
		ek[0] = Element.new("key")
		ek[0].text = "width"
		ev[0] = Element.new("integer")
		ev[0].text = (w / col).to_s
		
		ek[1] = Element.new("key")
		ek[1].text = "height"
		ev[1] = Element.new("integer")
		ev[1].text = (h / row).to_s
		
		ek[2] = Element.new("key")
		ek[2].text = "originalWidth"
		ev[2] = Element.new("integer")
		ev[2].text = (w / col).to_s
		
		ek[3] = Element.new("key")
		ek[3].text = "originalHeight"
		ev[3] = Element.new("integer")
		ev[3].text = (h / row).to_s
		
		ek[4] = Element.new("key")
		ek[4].text = "x"
		ev[4] = Element.new("integer")
		ev[4].text = (j * w / row).to_s
		
		ek[5] = Element.new("key")
		ek[5].text = "y"
		ev[5] = Element.new("integer")
		ev[5].text = (i * h / col).to_s
		
		ek[6] = Element.new("key")
		ek[6].text = "offsetX"
		ev[6] = Element.new("real")
		ev[6].text = "0"
		
		ek[7] = Element.new("key")
		ek[7].text = "offsetY"
		ev[7] = Element.new("real")
		ev[7].text = "0"
		
		for t in 0...ek.size
			dict.elements << ek[t]
			dict.elements << ev[t]
		end
		
		frame_dict.elements << key
		frame_dict.elements << dict
		
		# end dict
	end
end
# end frames
	
# metadata
metadata_key = root_dict.add_element("key")
metadata_key.text = "metadata"
metadatat_dict =  root_dict.add_element("dict")

ek = []
ev = []

ek[0] = Element.new("key")
ek[0].text = "format"
ev[0] = Element.new("integer")
ev[0].text = "2"	

ek[1] = Element.new("key")
ek[1].text = "textureFileName"
ev[1] = Element.new("string")
ev[1].text = filename

ek[2] = Element.new("key")
ek[2].text = "realTextureFileName"
ev[2] = Element.new("string")
ev[2].text = filename

ek[3] = Element.new("key")
ek[3].text = "size"
ev[3] = Element.new("string")
ev[3].text = "{#{w},#{h}}"

for t in 0...ek.size
	metadatat_dict.elements << ek[t]
	metadatat_dict.elements << ev[t]
end
#end metadata

# texture
texture_key = root_dict.add_element("key")
texture_key.text = "texture"
texture_dict =  root_dict.add_element("dict")

ek = []
ev = []

ek[0] = Element.new("key")
ek[0].text = "width"
ev[0] = Element.new("integer")
ev[0].text = "#{w}"	

ek[1] = Element.new("key")
ek[1].text = "height"
ev[1] = Element.new("integer")
ev[1].text = "#{h}"

for t in 0...ek.size
	texture_dict.elements << ek[t]
	texture_dict.elements << ev[t]
end
# end texture

file = File.open("#{picname}.plist", "w")
doc.write(file, 4, false, true)
file.close

p doc.xml_decl()

bug啥的慢慢修。