百度首页 | 百度空间
 
文章列表
 
2008-10-06 00:37
我的一个同学喜欢压片 有两个电脑 经常要在一台下 一台压
不过传输是个大问题 用我的u盘去copy 好慢
我当时就在想 如果是内存copy到内存的话 岂不是速度跟飞一样呢
内存的特点是速度超级块 至于读写方式则和flash是差不多的
内存的缺点是需要维持供电,我想这个不是难题,如果能发明一种内存可以使用电池来供电 这不就行了么
用7号或者手机的电池 可以直接充电 以内存的高速读写特点 相信能赢得不少粉丝
类别:短平快 | 评论(3) | 浏览()
 
2008-10-05 19:18
RT
类别:短平快 | 评论(0) | 浏览()
 
2008-09-17 22:06
i often chat in irc room,on linux ,most distro have a im-tool support for irc while win32 do not ,so i wrote this simple irc client
this use a murgaLua 0.6.9
and the code is here

cfg.ini

Code:
cfg={
   ["host"]="irc.freenode.net",
   ["port"]=6667,
   ["user"]="yman8",
   ["nick"]="murgalua1",
   ["pwd"]="",
   ["chanel"]="#bottest",
   ["debug"]="on"
}




ircclient.lua
[code]



[/code-----------------------------------------------------------------------------------
dofile("cfg.ini")

bl=-25
isjoin=nil
------------------------Draw GUI begin--------------------------------------------
ww,wh,wt=600,477,"Simple IRC Client - Powered by jyf1987"

w= fltk:Fl_Window(ww,wh,wt)
w:callback(function()
if fltk.fl_choice("Are you sure you want to EXIT ?", "No", "Yes", nil) >= 1 then
w:hide()
os.exit()
end
end)

msgout= fltk:Fl_Browser(5, 5, ww-10, wh-40)

msgin= fltk:Fl_Input(5, wh-30, ww-10, 25)
msgin:callback(
function()
iput(rd,msgin:value())
print("< "..cfg.nick.." > :"..msgin:value())
msgout:bottomline(msgout:size())
msgin:value("")
end
)
msgin:when(fltk.FL_WHEN_ENTER_KEY_ALWAYS)
w:show()
Fl:flush()
Fl:check()
Fl:wait(1)
w:make_current()
------------------------Draw GUI end-----------------------------------------------

------------------------------Utils------------------------------------------------
split=function(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end

print=function(str)
msgout:add(str)
msgout:bottomline(msgout:size())
bl=bl+1
if (bl>0) then
msgout:remove(1)
bl=bl-1
Fl:redraw()
end
end
------------------------------Irc func---------------------------------------------
function iput(skt,msg)
skt:send("PRIVMSG "..cfg.chanel.." :"..msg.."\n")
end

function ipong(skt)
skt:send('PONG 123456')
end

function iquit(skt)
skt:send('QUIT')
skt:close()
end

function onjoin(skt,hstr)
local usr=string.match(hstr[1],":(.*)!")
if ((isjoin==nil) and cfg.debug) then
cfg.debug=nil
end
print(usr.." JOIN "..cfg.chanel)
end

function onquit(skt,hstr)
local usr=string.match(hstr[1],":(.*)!")
print(usr.." QUIT "..cfg.chanel)
end

function onmsg(skt,hstr)
local hstr=hstr
local usr=string.match(hstr[1],":(.*)!")
--print(usr)
table.remove(hstr,1)
table.remove(hstr,1)
table.remove(hstr,1)
local msg=table.concat(hstr,"\032")
print("< "..usr.." > "..msg)
end
-----------------------------------------------------------------------------------
rd=socket.connect(cfg.host,cfg.port)
rd:settimeout(0.03)

rd:send("USER "..cfg.user.." hi.baidu.com/jyf1987 "..cfg.host.." :"..cfg.user.."\n")

rd:send("NICK "..cfg.nick.."\n")

if (cfg.pwd and cfg.pwd~="") then
rd:send("PRIVMSG /msg nickserv identify "..cfg.pwd.."\n")
end
rd:send("JOIN "..cfg.chanel.."\n")

s=rd:receive('*l')

while 1 do

if s then
if (string.find(s,"PING"))==1 then
print(s)
ipong(rd)
s=rd:receive('*l')
end

local debug=(cfg.debug=="on") and print("Debug: "..s)
local hstr=split(s,"%s")
--print(#hstr[2])
---------------------hook event-----------------------------------

if hstr[2]=="JOIN" then
onjoin(rd,hstr)
elseif hstr[2]=="PRIVMSG" then
onmsg(rd,hstr)
elseif hstr[2]=="PART" then
onquit(rd,hstr)
end

------------------------------------------------------------------
end
s=rd:receive('*l')
Fl:check()

Fl:wait(0.01)
--murgaLua.sleep(10)
end

find a dowload link from this page

http://sites.google.com/site/yunfan/simple-irc-client

类别:我的代码 | 评论(1) | 浏览()
 
2008-09-10 22:35
前几天宿舍里的在看f1的赛事直播,突发奇想,为何不能设置一些第一人称的视角在各个赛车上 让观众可以自由切换视角 感受赛事的刺激
其实这个也不难 本来就有第一人称的视角 只是直播的时候偶尔出现个一两次 而且还不能由观众自主切换 我想如果赛车上 可以像赛车游戏上的那样 弄四个角度的摄像头 然后联网到赛事节目的服务器上 让观众可以通过专用的客户端来收看节目 这大概能大大掉起观众的胃口
至于传输方式嘛 不用说是p2p
而且还可以借此收费 就跟数字电视那样 话说数字电视应该也可以实现类似功能啊
类别:短平快 | 评论(1) | 浏览()
 
2008-09-06 16:14
   这个博客是从编程爱好者迁移过来的
原因是 那个是个人站点 随时有关闭的风险 这个依托百度 应该要好点 况且在国内浏览速度要比谷歌快好多

不过 郁闷的是 由于这个博客系统似乎会使用一些手段来防止机器自动发文
这个措施无论是站在一般用户还是运营商的运营商的立场上 我都是深表赞成的
然而 由于本人博客的特殊用途 其实本人是十分希望这个博客可以开放一些机器人可访问的接口的

这个主要是因为有一些想法 特别是短平快的 我希望能通过手机来发送   另外一些东西 比如只有一两句话的想法 我希望在自己桌面上写个widget 类型的程序 一有想法 可以快速发表

另外 :这个博客也荒废好长时间了 主要就是这个原因 我懒得上web页面来更新
但是我决定开一个短平快的栏目 可以把闲言碎语的想法 包括一两句的发布到这里来
同时用手机短信发到海内的迷你博客上 当然我会定期去那里把记录转移过来的

however, 真的没有人研究用程序来发布文章么?我尝试过用perl 登录都没问题 只是最后这一步卡在发表文章这里了 真心希望有研究的朋友一起探讨
类别:短平快 | 评论(1) | 浏览()
 
2008-08-24 06:08

昨晚的雷把路由劈了 一天都没得网上 憋坏了 没奈何 只好上网吧来通宵玩

可是通宵玩游戏是绝对会睡的 所以就想到个东西 一直想写的一个小应用

其实就是个hash db只不过是基于http的

而且是基于url 呵呵

用lua编写的,用到了luasocket和copas库

所以最好用murgaLua去运行 因为库都内置了

murgaLua的地址   http://www.murga-projects.com/ 很好的东西 我再次强烈推荐

废话无多,代码如下:

-------------------------------------------------------------------

local server={}
local page={}


server["name"]="yunfan's webserver"
server["host"]="*"
server["port"]=8040

-------------------------myutils-----------------------------------


string.split=function(str, pat)
   local t = {} -- NOTE: use {n = 0} in Lua-5.0
   local fpat = "(.-)" .. pat
   local last_end = 1
   local s, e, cap = str:find(fpat, 1)
   while s do
      if s ~= 1 or cap ~= "" then
table.insert(t,cap)
      end
      last_end = e+1
      s, e, cap = str:find(fpat, last_end)
   end
   if last_end <= #str then
      cap = str:sub(last_end)
      table.insert(t, cap)
   end
   return t
end


-------------------------myprocess--------------------------------
--this my process code lib

function callecho(skt,msg)
local response=msg
local length=string.len(response)
local res="HTTP/1.1 200 OK\nServer: "..server["name"].."\nContent-Length: "..length.."\nContent-Type: text/html\n\n"..response
copas.send(skt,res)
end

function callprocess(skt,query)
if string.match(query,"^/[^=]+$") then
    print("calll showindex")
    callshowindex(skt,query)
elseif string.match(query,"==") then
    callecho(skt,"Sorry,you have put a strange query that we can not process! ==> "..query)
elseif query=="/" then
    print("call showindex")
    callshowindex(skt)
else
    print("call createpage")
    callcreatepage(skt,query)
end
end


function callshowindex(skt)
local tmp={}
for k in pairs(page) do
    local value="<a href=\""..k.."\">"..k.."</a><br/>"
    table.insert(tmp,value)
end
local msg=table.concat(tmp)
callecho(skt,msg)
end

function callshowpage(skt,query)
if page[query] then
    callecho(skt,page[query])
else
    local res="HTTP/1.1 404 Not Found\n\n"
    copas.send(skt,res)
end
end


function callcreatepage(skt,query)
local argmt=string.split(query,"=")
if page[argmt[1]] then
    local res="HTTP/1.1 301 Moved Permanently\nLocation: "..argmt[1].."\n\n"
    copas.send(skt,res)
else
    page[argmt[1]]=argmt[2]
    local res="HTTP/1.1 302 Found\nLocation: "..argmt[1].."\n\n"
    copas.send(skt,res)
end
end

-------------------------------------------------------------------------

function handle(skt)
local req=string.split(copas.receive(skt),"%s")
--local header=string.split(req[1],"\r\n")
--local request=string.split(header[1],"%s+?")
if (not(req[1]=="GET")) then
   callecho(skt,"bad request header!!")
   print("req1: "..req[1])
else
   print(req[2])
   callprocess(skt,req[2])
end
end

-------------------------------------------------------------------------


socket.trybind=socket.protect(function(host,port)
      local s=socket.try(socket.bind(host,port))
      return s
end)

local svr=socket.trybind(server["host"],server["port"])

if not svr then
print("Sorry,something may cause a error\nAnd so the server has not run successed!!\n")
os.exit()
end

copas.addserver(svr,handle)
copas.loop()

写得有点乱

其实一开始是弄得很好的 但是lua的局部变量访问全局变量似乎和别的不一致

我的分开的代码里的函数没办法访问全局配置的那个变量 所以压到一个文件里了

效果见:

http://pep525.vicp.net:8080/

多谢pep525给我提供了这么个linux主机来折腾 呵呵

类别:我的代码 | 评论(1) | 浏览()
 
2008-08-18 09:17
主要就是利用了 解压炸弹的原理
解压炸弹是什么 可以百度一下 不过要看avast网站给出的解释 百度知道上那个是扯淡

由于存在着这种解压炸弹
而http传输中又有个小漏洞 既服务器可以在浏览器允许的前提下发送gzip过的数据给浏览器 以减少带宽消耗
这是个好东西 可惜没有避免解压炸弹啊,因为主流的浏览器都默认支持gzip的 而且我还不知道如何关闭这个支持呢 呵呵 也许火狐的自定义http标头可以关闭 但是ie实在是找不到什么办法

我自己用lua程序自制了两个文件 一个100mb 一个1gb
都是填充一样的数据的 慢文件都是fffff
然后用gzip压缩
最后得到两个压缩后的文件 体积分别为 100kb 1mb
然后我找个了个支持php的空间
把这两个文件上传了上去
再写了两个php程序
主要就三句话
第一句 用file_get_contents读入整个文件的内容到字符串里
第二句 给浏览器发送一个header 告诉他接下来的内容是gzip过的
第三句 输出那个字符串的内容
这个字符串也不大 小则100k 多则1m
然后浏览器这边可就惨了
100k的内容解压以后是100mb
我测试过 我的火狐一打开 内存占用猛增300mb
ie似乎也是如此 基于这个结果 那个解压后会1g的文件我没测试 呵呵

测试地址在

http://tinybb.ekedns.com/test/1k.php

http://tinybb.ekedns.com/test/1m.php


第一个地址经实测会吃你300m的内存
第二个地址理论上会吃你3g的内存 所以 只好留给用于探索或者是最近装机的 拥有4g内存的人了

这个东西我觉得稍为改进下 修改下输出的mime 可以冒充图像文件 放到你的个人签名里 或者其他可以显示图片的地方 然后去你憎恶的论坛发贴 每个地方都去跟跟帖 当然要以你的评论还在第一页为准 那么其他访客就会都被赶走的
而你呢 可以事先设置浏览器不显示图片 这个是ie和ff都可以自由设定的 呵呵

祝好运
类别:杂项文章 | 评论(0) | 浏览()
 
2008-08-04 18:20

形式: SNS类型

可能的消费人群: 大学生与都市青年

应用: 给用户更多空间展示自我,包括照片,声音,视频

对手的缺点: 对手为校内网

1,当前的缺点是缺乏吸引人的应用,最初的涂鸦板已经没有多少吸引力
2,缺乏经常性的活动来推动社区互动,登录以后似乎就没有好玩的了
3,默认的隐私设置策略不对,其实大多数人不在乎页面被人看到的

针对于此的对策

1,提供更自由的页面编辑功能,这个可以吸引一大批对校内网涂鸦板不满的人
2,要经常性的推出选秀活动,满足用户展示自我的需求。
3,默认的隐私设置为公开,但应该让用户可以很容易的关闭陌生人的访问

特色栏目: 应该让每个人都有个视频展示的板块
类别:文档类 | 评论(2) | 浏览()
 
2008-06-10 21:20
上次发布了个perl版的更新3322动态域名的程序 不过由于那个用到了lwp库 依赖太p烦了
所以只好打包成exe格式 但是exe格式嘛 文件体积就大了 不符合原意了

这次用lua重新实现了 用的是lua5.1+socket库
由于lua的依赖很简单 寻址也智能 所以可以绿色使用 因此发布的是源代码
体积很小 基本的socket和 mime的dll 和解释器 以及我的代码 加起来不过只有188k
里头带了luasocket库 这个库实现了socket http ftp smtp等 顺便我还放了个json库 呵呵
里头有个copas库 多线程也可以搞定(原理上说是假的 但我无所谓 我只追求效果上 呵呵)

总而言之是小之又小 好之又好
全部的环境和代码我已经打包了 可以去这里下载
http://webdisk.cech.com.cn/download/file_share_10986261.html

很显然 如前面所说 这里面其实包含了一个比较有用的lua环境和一些库
事实上我还用这个写了个irc bot 当然 还在完善中
如果感兴趣的 可以利用这个小环境学习lua 写程序 我觉得带socket和http库 对于写一些校内工具是足够了 无需担心跨平台问题 事实证明 我的irc bot在一个centos的环境中运行情况与win中无二

如果只想看看代码 可以看这里

我的代码如下

package.cpath = "./lib/?.so;./lib/?.dll;./lib/?.dylib;"

local http = require"socket.http"
local mime = require"mime"


function getip()
local ip=http.request("http://www.3322.org/dyndns/getip")
return string.gsub(ip, "%s", "")
end

function setdyn(u,p,n,ip)
local t={}
r,c=http.request{
          url="http://www.3322.org/dyndns/update?system=dyndns&hostname="..n.."&myip="..ip,
          user = u,
          password = p,
          sink=ltn12.sink.table(t),
          redirect=false
          }
if not(r) then
    return "ERORR: the data has not send correctly!"
end
if c~="200" then
    return "SUCCESS! Your Dynamic name "..n.." has been set to "..ip
else
    return "ERORR: an unexpectant value has been got\n"..c
end
end

user,pwd,name=arg[1],arg[2],arg[3]
if not(user and pwd and name) then
print("you don't put the right arguments\npress ENTER to quit")
io.read()
os.exit()
end

print("This script is powered by jyf1987 ( http://hi.baidu.com/jyf1987 )")
print("and public under bsd lisence,so you can do anythings to it as you wish\n\n")
print("now getting your public ip...")
local ip=getip()
print("got it!\nupdating your dynamic name...\n\n")
print(setdyn(user,pwd,name,ip).."\npress ENTER to quit")
io.read('*l')
类别:杂项文章 | 评论(0) | 浏览()
 
2008-05-17 15:55
ff2一直用着 就是ui很诟病 速度也有问题
这不 ff3改进了 ui很好了 我一直不喜欢ff2那种看着觉得很厚很圆的界面 看起来很笨重 加上ff那很慢的启动速度
那就更加重了心理上的负面印象 但是 我是programmer 所以还是用着ff2
但是现在好了 ff3 ui好 速度快 我现在只等几个我喜欢用的插件升级到ff3支持
不过目前还是rc1版 相信正式版会更爽
类别:观察评论 | 评论(0) | 浏览()
 
     
 
 
文章分类
 
     
 
文章存档
 
 
 
 
 
 
 
 
 
 
 
 
     
 
最新文章评论
   
 
 

如果俩U盘互相copy 速度虽然是飞,但你资源从哪来呢。。哈哈
 

Chinglish !~ hoho
 
 
     


©2008 Baidu