无题(废弃核心保护和对象控制(CPOC)后某某所作)

从纷乱创造简洁,一句就够了!
erase

Posted in 未分类 | Leave a comment

被废弃的CPOC(core protector & object control)

MJS中原来有个东西叫做CPOC
它是一组函数
耗费了将近2000行代码
充斥着caller、eval。
防止客户乱写属性、方法
阻止了很多操作
提高了系统稳定性
和“纯粹性”

但是,我还是删除了
因为它太慢
影响性能
更重要的是,它无视了很多用户和开发者的想法
有些修改需求,不对吗?

限制会消失的,对吧。
虽然,有些人会反对:
“那是内核啊,修改内核会出事情的”
但是,内核就不能修改了吗?

CPOC,被废弃了
垃圾收集中。

 

(注:用了很多双关,Li**Yu*(not lychees)等人可以直接理解)
(理解不了可以重新展开CPOC这个缩写,有一个是“小词”)

Posted in life[], program[] | Tagged , , | Leave a comment

这段C#与这段JS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Parabola_closure_ex { public delegate double MathFunction(double x); class Program { static MathFunction para(double a, double b, double c) { return x => a * x * x + b * x + c; } static void Main(string[] args) { MathFunction f; f = para(1, 2, 3); Console.WriteLine(f(3)); Console.ReadKey(); } } }
var para = function(a, b, c) {
    return function(x) {
        return a * x * x + b * x + c;
    }
};


//main var f = para(1, 2, 3); alert(f(3));

IL:

.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 2:0:0:0
}
.assembly Parabola_closure_ex
{
  .custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 1B 43 6F 70 79 72 69 67 68 74 20 C2 A9 20   // ...Copyright ..
                                                                                                  4D 69 63 72 6F 73 6F 66 74 20 32 30 30 39 00 00 ) // Microsoft 2009..
  .custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 13 50 61 72 61 62 6F 6C 61 5F 63 6C 6F 73   // ...Parabola_clos
                                                                                              75 72 65 5F 65 78 00 00 )                         // ure_ex..
  .custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
  .custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 )
  .custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 09 4D 69 63 72 6F 73 6F 66 74 00 00 )       // ...Microsoft..
  .custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 13 50 61 72 61 62 6F 6C 61 5F 63 6C 6F 73   // ...Parabola_clos
                                                                                                75 72 65 5F 65 78 00 00 )                         // ure_ex..
  .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 37 37 38 64 38 37 32 35 2D 36 36 64 38   // ..$778d8725-66d8
                                                                                                  2D 34 66 36 33 2D 38 39 66 39 2D 35 63 31 61 62   // -4f63-89f9-5c1ab
                                                                                                  30 31 65 66 66 66 66 00 00 )                      // 01effff..
  .custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 )
  .custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 ) 
// --- 下列自定义属性会自动添加,不要取消注释 ------- // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. .custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 ) // ...1.0.0.0.. .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .hash algorithm 0x00008004 .ver 1:0:0:0 } .module Parabola_closure_ex.exe // MVID: {7393789F-0AC1-4607-976B-989DAF5B969E} .imagebase 0x00400000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY // Image base: 0x0000000000890000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi sealed Parabola_closure_ex.MathFunction extends [mscorlib]System.MulticastDelegate { .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed { } // end of method MathFunction::.ctor
.method public hidebysig newslot virtual instance float64 Invoke(float64 x) runtime managed { } // end of method MathFunction::Invoke
.method public hidebysig newslot virtual instance class [mscorlib]System.IAsyncResult BeginInvoke(float64 x, class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed { } // end of method MathFunction::BeginInvoke
.method public hidebysig newslot virtual instance float64 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed { } // end of method MathFunction::EndInvoke
} // end of class Parabola_closure_ex.MathFunction
.class private auto ansi beforefieldinit Parabola_closure_ex.Program extends [mscorlib]System.Object { .class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1' extends [mscorlib]System.Object { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .field public float64 a .field public float64 b .field public float64 c .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { // 代码大小 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } // end of method '<>c__DisplayClass1'::.ctor
.method public hidebysig instance float64 ' b__0'(float64 x) cil managed { // 代码大小 31 (0x1f) .maxstack 3 .locals init ([0] float64 CS$1$0000) IL_0000: ldarg.0 IL_0001: ldfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::a IL_0006: ldarg.1 IL_0007: mul IL_0008: ldarg.1 IL_0009: mul IL_000a: ldarg.0 IL_000b: ldfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::b IL_0010: ldarg.1 IL_0011: mul IL_0012: add IL_0013: ldarg.0 IL_0014: ldfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::c IL_0019: add IL_001a: stloc.0 IL_001b: br.s IL_001d
IL_001d: ldloc.0 IL_001e: ret } // end of method '<>c__DisplayClass1'::' b__0'
} // end of class '<>c__DisplayClass1'
.method private hidebysig static class Parabola_closure_ex.MathFunction para(float64 a, float64 b, float64 c) cil managed { // 代码大小 45 (0x2d) .maxstack 3 .locals init ([0] class Parabola_closure_ex.Program/'<>c__DisplayClass1' 'CS$<>8__locals2', [1] class Parabola_closure_ex.MathFunction CS$1$0000) IL_0000: newobj instance void Parabola_closure_ex.Program/'<>c__DisplayClass1'::.ctor() IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: ldarg.0 IL_0008: stfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::a IL_000d: ldloc.0 IL_000e: ldarg.1 IL_000f: stfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::b IL_0014: ldloc.0 IL_0015: ldarg.2 IL_0016: stfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::c IL_001b: nop IL_001c: ldloc.0 IL_001d: ldftn instance float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::' b__0'(float64) IL_0023: newobj instance void Parabola_closure_ex.MathFunction::.ctor(object, native int) IL_0028: stloc.1 IL_0029: br.s IL_002b
IL_002b: ldloc.1 IL_002c: ret } // end of method Program::para
.method private hidebysig static void Main(string[] args) cil managed { .entrypoint // 代码大小 62 (0x3e) .maxstack 3 .locals init ([0] class Parabola_closure_ex.MathFunction f) IL_0000: nop IL_0001: ldc.r8 1. IL_000a: ldc.r8 2. IL_0013: ldc.r8 3. IL_001c: call class Parabola_closure_ex.MathFunction Parabola_closure_ex.Program::para(float64, float64, float64) IL_0021: stloc.0 IL_0022: ldloc.0 IL_0023: ldc.r8 3. IL_002c: callvirt instance float64 Parabola_closure_ex.MathFunction::Invoke(float64) IL_0031: call void [mscorlib]System.Console::WriteLine(float64) IL_0036: nop IL_0037: call valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey() IL_003c: pop IL_003d: ret } // end of method Program::Main
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed { // 代码大小 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } // end of method Program::.ctor
} // end of class Parabola_closure_ex.Program

请注意那个“<>c__DisplayClass1”,闭包就这样看到啦!

Posted in program[], web[] | Tagged , , | Leave a comment

【原创】语义优化的CSS Tab(算是完美了吧……)

    <ol class="tab">
        <li><a class="tabItem" href="#"><span>111111</span><a><div class="tabPage">content 1</div></li>
        <li><a class="tabItem" href="#"><span>222222</span></a><div class="tabPage">content 2</div></li>
        <li class="current"><a class="tabItem" href="#"><span>333333333333333333333</span><a><div class="tabPage">
                <p>...... </p>
            </div>
        </li>
    </ol>

preview Continue reading

Posted in program[], web[] | Tagged , , | Leave a comment

script type="contextual"

<script type="text/javascript:contextual">
    page.output.print(context.tag());
</script>

只是给type加了一点东西。

$init(function() {
    var request = world.assembly.getXHR(); //请求对象


// Load
var load = function(name, compose) { try { if (request.overrideMimeType) request.overrideMimeType('text/javascript'); request.open('GET', name, false); request.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT"); request.send(null); if (request.status == 200 || request.status == 204 || request.status == 0) { var t = request.responseText; return (t); }; } catch (e) { return '' } };


var i = 0, script, scripts = document.getElementsByTagName('script'); while ((script = scripts[i++])) { if (/:contextual$/.test(script.type)) { if (script.src) { (new Function("script,context", load(script.src))).call($(script.parentNode), $(script), $(script.parentNode)); } else { (new Function("script,context", script.innerHTML)).call($(script.parentNode), $(script), $(script.parentNode)); } } } });

好玩的在这里。(今天晚上svn,dandy里面就可以看到啦~)

最早的想法来自:http://james.padolsey.com/javascript/contextual-script-tags/

Posted in program[], web[], ~MJS~ | Tagged , , | Leave a comment

实现canvas的silverlight xap

出处:http://blogs.msdn.com/delay/archive/2009/08/24/using-one-platform-to-build-another-html-5-s-canvas-tag-implemented-using-silverlight.aspx

下载:Html5Canvas.xap

使用方法和原生的canvas一样,getContext,接着画图。非IE也可以使用(速度和原生的一样快……晕哦……)。需要silverlight 3环境。

Posted in program[], web[] | Tagged , , , , | Leave a comment

IE9前瞻:终于支持圆角了?

Dean_PDC_4[1]

这是微软放出的图,边框终于有圆角了,还带反锯齿(顺便BS一下Chrome,没有反锯齿……)

还有这张图:

Dean_PDC_5[1]

574/578,可以预见,我们终于可以用querySelectorAll代替$()。

这里有个视频介绍IE9新的js引擎,看样子似乎用了预编译。不过E文……听不懂的说。

还有流言称IE9会使用显卡加速,不过用显卡的似乎他不是第一个,我带开safari 4后GTX295就叫……

minasan~~~ 期待吧。

 

连接:

http://blogs.msdn.com/ie/archive/2009/11/18/an-early-look-at-ie9-for-developers.aspx
http://blog.csdn.net/WinGeek/archive/2009/11/19/4832467.aspx
http://www.neowin.net/news/live/09/11/18/microsoft-demos-internet-explorer-9
http://www.css3.info/microsoft-announces-css3-support-for-internet-explorer-9-ie9/

 

看到连接1博文回复有这个“问卷”:

  1. ECMAScript EventHandling - in or out?
  2. Canvas - in or out?
  3. SVG - in or out?
  4. HTML5 Audio/Video - in or out?
  5. VBScript - out?
  6. VML - out?
  7. XHTML - in or out?
  8. MathML - in or out?
  9. @font-face - in or out?
  10. base64 - in or out?
  11. GeoLocation - in or out?
  12. Accelerometer - in or out?
  13. Web Workers - in or out?
  14. new HTML5 input types - in or out?
  15. fully public (respectable) bug tracking - in or out?
  16. WinXP support - in or out?

拭目以待吧!(诸位可以先猜猜,不过我猜VBS应该不会out——毕竟IE设计的DOM是通用跨语言接口。当然全部重写DOM模型除外。VML out概率甚高,而<canvas>嘛……可能会in,毕竟用的是DX,说不定来个增强搞搞<sence>,从此扔掉Unity 3D……)

Posted in program[], web[] | Tagged , , , , | 2 Comments

传说中的C#娘出世了?

003[1]

请恕我孤陋寡闻,拟人化风潮终于吹到了程序界……

似乎人设是一个.NET程序员。

还有其他人设:

rough01[2]

VB娘

rough01[4]

接下来才是好戏——

win7[1]

Posted in a[]∪c[]∪g[], program[] | Tagged , , | 1 Comment

称球问题的解?

交互式题目:x是一个数组,下标从1到n,其中只有一个数不同于其它。给你函数compare(a,b) a,b:Array of [1..n],比较x[a[1]]+x[a[2]]+……和x[b[1]]+x[b[2]]+……的结果,返回-1,0或1。现在请编写程序在最少的compare调用次数内找出x中那个独一无二的数的下标。(你只能使用compare,x是私有属性)

这就是经典的称球问题。对于n=12且已知“异常”数大于标准数的情况,可以写出下面的算法:

var get4 = function(a, b, c, d) {
    return (compare([a, b], [c, d]) > 0) ? (compare([a], [b]) > 0 ? a : b) : (compare([c], [d]) > 0 ? c : d);
};
var getItem = function() {
    switch (compare([1, 2, 3, 4], [5, 6, 7, 8])) {
        case 0: get4(9, 10, 11, 12);
        case 1: get4(1, 2, 3, 4);
        case -1: get4(5, 6, 7, 8);
    }
};

这里有详细算法。(不过他的和我的要求还不太一样——他在球放在天平上之后又向上加球,而我的要求相当于球放上天平以后,看到天平倾斜/平衡后必须立即拿走。)

这里有一些简化/加强版本,诸君可以一试:

  • 直接提供sum(i1,i2,i3…)返回x[i1]+x[i2]+x[i3]……(相当于用分析天平、电子称)
  • 提供x[0]=标准值(相当于额外给你一个标准球)
  • 有两个是异常值(当然,n>=5)
  • 有两个是异常值且不相等
Posted in 未分类 | Leave a comment

猜猜这段代码写的是什么?

var delegator = me.meetingPerson;
me.acceptWishRequest(delegator,function(ea){
    var w = ea.wish;
    RGO.acceptWishRequest({
        content:w,
        acceptor:me,
        delegator:delegator
    },function(ea){
        if(ea.status === 200){
            me.addImplementTask(delegator,w);
        }
    });
});

提示:某个作品开始时的场景。me为一主角。

Posted in a[]∪c[]∪g[], life[], program[], web[] | 1 Comment