这二天用c#开发ActiveX时,发现不管怎么弄,c#就是没办法生成ocx的纯正activeX控件,而且还要强迫用户安装巨大的.net framework(我只是想做一个简单截屏功能的activeX整合到silverlight聊天室中),于是想起了曾经用过一年的delphi,虽然时过境迁,现在早以是.net的天下,但是不可否认,delphi仍是win32原生程序最佳的开发工具之一。 关于Delphi的语法学习,可以参见这个chm文档,基本上一天就能看完 http://d.namipan.com/d/d02
例 3.1.3(null和undefined的==和===的比较) <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> //马克-to-win:声明变量x /* if a value is not set, its typeof is undefined, its value is undefined, if a value= null, its typeof is object, its value is null,but when you use == to test, they are the same, but when to use === to test, they are not the same,== means as long as value is the same, ok, but === means type also must be equal. */ var x; var z1 = "d"; var y = null; // document.writeln("z1 is"+z1); /*if you cancel commenting out the following statement, it will give the blank page, which means it has error.*/ // document.writeln(zyx); document.writeln(x + " is x"); document.writeln(typeof(x) + " is typeof(x)"); document.writeln(y + " is y"); document.writeln(typeof(y) + " is typeof(y)"); var z = undefined; document.writeln(z + " is z"); document.writeln(typeof(z) + " is typeof(z)"); if (y == undefined) { document.writeln('null and undefined is interchangable'); } if (z1 != null) { document.writeln('z1 != null'); } if (y === undefined) { document.writeln('null and undefined is exactly the same'); } if (x == undefined) { document.writeln('声明变量后默认值为undefined'); } if (x === undefined) { document.writeln('声明变量后默认值为exactly the same as undefined'); } if (x == null) { document.writeln('声明变量后默认值为null'); }
3101: N皇后 Time Limit: 10 Sec Memory Limit: 128 MBSec Special Judge Submit: 88 Solved: 41 [Submit][Status][Discuss] Description n*n的棋盘,在上面摆下n个皇后,使其两两间不能相互攻击… Input 一个数n Output 第i行表示在第i行第几列放置皇后 Sample Input 4 Sample Output 2 4 1 3 HINT 100%
6)静态方法和prototype(难) 例 3.6.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> /*note that 马克-to-win: static variable's value has nothing to do with instance's variable's value.instance 名称 can not 直接access static member like in java. This is different from Java,比如下面例子中,Student.number=2,但是d1.number就为undefined.This is different from Java,但在实例方法中(比如d1.info)可以访问Student.number。这是和java中一样的。或者说function外或任何地方都可以访问Student.number。反过来,d1.age也可以在静态方法中访问,就像在function外一样,任何地方都能访问d1.age。String.prototype.abcd,这是给所有的实例加属性而不是静态属性。*/ function Student(number, agev) { this.age = agev; /*static variable's value can not be accessed by instance */ Student.number = number; /*lb is local variable, but not a member variable because it is not modified by this. from outside it can not be accessed. refer to noblockScope.html */ var lb = 0; } var d1 = new Student(1, 3); document.writeln("this的age属性为means window.age" + this.age + ""); document.writeln("d1的age属性为" + d1.age + ""); document.writeln("d1的number属性为" + d1.number + ""); document.writeln("通过Student访问静态number属性为" + Student.number + ""); document.writeln("d1的lb属性为" + d1.lb + ""); d1.qixy = "abc";/*以随意为实例加属性或方法*/ document.writeln("可以随意为实例加属性或方法see following,d1的qixy属性为" + d1.qixy + ""); document.writeln("是否有静态变量qixy" + Student.qixy + ""); d1.info = function()/*此方法仅为d1对象所用*/ { document.writeln("对象的qixy属性:" + this.qixy); document.writeln("对象的age属性:" + this.age); /*下列话是合法的, 因为不是this.number, 而是Student.number*/ document.writeln("static method is " + Student.number); }; Student.prototype.infop = function()/*此方法可以为所有Student对象所用*/ { document.writeln("对象的qixy属性p:" + this.qixy); document.writeln("对象的age属性p:" + this.age);
hasOwnProperty()函数用于指示一个对象自身(不包括原型链)是否具有指定名称的属性。如果有,返回true,否则返回false。
8)arguments 例 3.8.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> /* when there are n functions with the same function name, only the last one is used. */ function test() { document.writeln("no argument constructor."); } function test(person) { document.writeln("马克-to-win2"); /*Function.arguments[] (Collection) The values passed to the function when it is called. 马克-to-win: inside function,we can directly use arguments. */ var n = arguments.length; document.writeln("n is " + n); for (var i = 0; i < n; i++) { document.writeln("马克-to-win3"); document.writeln(arguments[i]) } document.writeln(person); document.writeln(typeof(person) + "is typeof"); } /*when no param, undefined is passed in. no overloaded function concept.*/ test(); /*when there is no this function, program stops here.*/ change(); document.writeln("finally"); </script>
程序开发中,编程人员经常要面对的是如何编写代码来响应错误事件的发生,即例外处理(exception handlers)。如果例外处理代码设计得周全,那么最终呈现给用户的就将是一个友好的界面。否则,就会让访问者对莫名的现象感到真正的“意外”。 一、什么是例外处理 当JavaScript程序在运行中发生了诸如数组索引越界、类型不匹配或者语法错误时,JavaScript解释器就会引发例外处理。ECMAScript定义了六种类型的错误,除此之外,我们可以使用Error对象和throw语句来创建并引发自定义的
2)局部变量和全局变量 浏览器里面 window 就是 global,通常可以省。 nodejs 里没有 window,但是有个叫 global 的。 例 3.2.1 <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> /* 有var无var, 在function外是一样的,都是全局的,在function里面时,var是局部的,而无var时是代表全局的*/ var testVar = "全量"; document.writeln("window.testVar is" + window.testVar+testVar); var testqVar = "全量q"; /*如不屏蔽下句话,程序直接停在这了,因为出错了,不认识testGlobal,得把下一句和下下句换一下位置,就ok了 */ // document.writeln("testGlobal is" + testGlobal); testGlobal = "全量global"; document.writeln("abc is" + abc); var abc; testGlobalInVar = "全量globalInVar"; function testSco() { var lll = "qqq"; var testVar = "局量"; //此testVar非外面的testVar testqVar = "全量qchange"; //此testqVar就是外面的testqVar testGlobal = "全量globalchange"; var testGlobalInVar = "局量global";//此testGlobalInVar非外面的testGlobalInVar /*local variable is stronger than global variable.so "testVar" in the following statement means local variable.*/ document.writeln(testVar); document.writeln(testqVar); document.writeln("testGlobalInVar is " + testGlobalInVar); } testSco(); document.writeln("second test is " + testVar); document.writeln("second testqVar is " + testqVar); document.writeln("testGlobal is " + testGlobal); document.writeln("testGlobalInVar is " + testGlobalInVar); </script>
10)json 例 3.10.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> var student = { name : 'mark', age : 3 , classes : ['小' , '中' , "大"], /* 马克-to-win:class is an array of string, also parents is also an array of json object. */ parents :[ { name : 'father', age : 42, salary : 'low' } , { name : 'mother', age : 37, salary : 'high' } ] }; document.writeln(student.name); document.writeln(""); document.writeln(student.age); document.writeln(""); document.writeln(student.classes[1]); document.writeln(""); document.writeln(student.parents[1].name); </script>
查阅了splice方法的示例文档,如下: (不想看论述的,可以直接跳到下面看总结!)
一个客户想通过编程实现验证程序自身的数字签名来确保程序的完整性,防范病毒感染以及防止一些无聊人士的修改(通过十六进制编辑器替换一些版权、网址、LOGO..); 为此我做了一个数字签名验证的小例子,其中也有获取签名者信息的方法,以满足“自验证”的需求。
以上方法,对于有其他OO语言经验的开发人员去看,比较容易理解,但是性能上并不推荐。因为每次创建新的实例都需要进行一次判断,哪怕这次的性能损耗是极小的,但毕竟也是有损耗。
5)构造函数的用法: 例 3.5.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> function Student(name, age) { /* 马克-to-win:later on we can use it in var doc = new ActiveXObject( "Microsoft.XMLDOM" ); doc.async="false"; doc.load(str); when a property has a this, means that this property is a member property. */ this.name = name; this.age = age; this.parti = function() { document.writeln("名字是:" + this.name + ""); document.writeln("年纪是:" + this.age + ""); }; } var p = new Student('jeri', 3); document.writeln("typeof p is " + typeof(p)); //typeof(p) is object p.parti(); p.age = 4; p.parti(); /*the following two methods can also access some properties.*/ document.writeln("" + p["age"]); document.writeln("" + p["a" + "ge"]); if (p instanceof Student) document.writeln("p是Student的实例"); /*javascript 中的对象全部是Object 的子类 Because this object is the topmost parent object in the prototype inheritance hierarchy, all other object classes inherit its methods and properties. It's a close enough call that JavaScript 2.0 may well move it into the class-based object-oriented category at which time the prototype inheritance would be replaced with super-class/sub-class mechanisms and the arguments become null and void. */ /*When the Global object is created, it always has at least the following properties: Object object Function object Array object String object Boolean object Number object Date object Math object Value properties */ if (p instanceof Object) document.writeln("p是Object的实例"); </script>
任何一门语言,只要具备了"封装,继承,多态"这三项基本能力,不管其实现方式是直接或曲折、复杂或简洁,就可以称之为“面向对象”的语言。 Delphi当年的迅速走红,是以其RAD快速开发吸引程序员的目光。这无疑是它最吸引人的优势,但同时也让人误以为delphi只是vb的高级版本,从而忽视了其面向对象的特性。 其实Pacscal发展到Delphi,已经完全具备了面向对象的所有特点:允许自定义类,类可以继承(单继承),允许方法重载/覆写,可以定义接口,类可以实现接口,允许定义静态方法(即class方法),虚方法,抽
1.typeof操作符 typeof操作符用来检测变量的数据类型 2.数据类型 2.1Undefined类型,只有一个值undefined(在使用var声明变量没有初始化的时候,这个变量数据类型的值就是undefined) 注意:没有初始化和没有声明的变量是不一样(虽然typeof返回的值都是undefined,但是没有声明的会报错的) 2.2Null类型,只有一个值null,typeof操作符检测null返回object(这样就可把将来要保存对象的变量初始化为null) 注意:underfined和nul
模版 模版是Nim语言中的抽象语法树,它是一种简单的替换机制,在编译期被处理 这个特性使Nim语言可以和C语言很好的运行在一起 像调用一个方法一样调用一个模版 请看如下代码: template `!=` (a, b: expr): expr = # this definition exists in the System module not (a == b) assert(5 != 6) # the compiler rewrites that to: assert(not (5 == 6))
9)Object 例 3.9.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> /*马克-to-win:When the Global object is created, it always has at least the following properties: Object object Function object Array object String object Boolean object Number object Date object Math object Value properties */ var oi = new Object(); oi.name = 'mark'; oi.height = 4; function xxx() { document.writeln("对象的name属性:" + this.name); document.writeln(""); document.writeln("对象的height属性:" + this.height); } oi.list = xxx; oi.list(); document.writeln(oi["name"] + oi["height"]); </script>
1.检查是否触屏设备 //此方法在chrome模拟手机的模式中似乎无效,但是在iphone中是有效的,在安卓中待测试 function isTouchDevice() { return ('ontouchstart' in document.documentElement); } 2.检测更多的设备和浏览器信息,靠的是ua信息 var browser={ versions:function(){ var u = navigator.userAgent, app = n
这个嘛是本人专门为了NOI上面对拍程序写的对拍程序,已经经历了NOI2015的考验;更重要的是——纯Pascal的哦(HansBug:其实是我不会写.sh脚本TT,谁叫用惯了windows的我只会写bat呢)。。。(本人实测复杂度约为 \( {10}^{5} \) 的程序在windows下每秒钟约可以拍20次左右,linux下可以最高达到600次每秒哦,上次我开动程序后当我反应过来之后次数已经是四位数了么么哒,当然了如果你程序本身就复杂度过高的话那么还是没有办法,毕竟受到程序运行速度的制约)。。。 需要的可
如果能自己读懂System.out.println(),就真正了解了Java面向对象编程的含义,面向对象编程即创建了对象,所有的事情让对象帮亲力亲为(即对象调用方法)
HTML+CSS CSS pixels与Device pixels有何区别? 2016.07.25~2016.07.29 核心概念 CSS pixels、Device pixels 问题解析 CSS pixels: 浏览器使用的抽象单位, 主要用来在网页上绘制内容 Device pixels: 显示屏幕的的最小物理单位,每个dp包含自己的颜色、亮度 等值的 CSS pixels在手机屏幕上占多大的位置,这不是固定的,这取决于很多属性。经过分析和总结,我们可以得出这么一条公式: 1 CSS pixels =
通过使用collecions,进行排序。collections是一个python的内建模块。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
从“挂马”这个词中就知道,它和“木马”脱离不了关系,的确,挂马的目的就是将木马传播出去。
1)类型转换,typeof的用法 例 3.1.1 <HTML> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <BODY> <SCRIPT LANGUAGE="JavaScript">
npm install -g grunt-cli //全局安装grunt npm init -y //初始化package.json npm install grunt --save-dev //在项目中安装grunt grunt --help //查看更多信息 grunt 安装完毕
1067: [SCOI2007]降雨量 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 2148 Solved: 554 [Submit][Status] Description 我们常常会说这样的话:“X年是自Y年以来降雨量最多的”。它的含义是X年的降雨量不超过Y年,且对于任意Y<Z<X,Z年的降雨量严格小于X年。例如2002,2003,2004和2005年的降雨量分别为4920,5901,2832和3890,则可以说“2005年是自2003年以来最多的”
——老子
当数字直接出现在程序中时,被称为数值直接量。在 JavaScript 程序中,直接输入的任何数字都被视为数值直接量。 示例1 数值直接量可以细分为整型直接量和浮点型直接量。浮点数就是带有小数点的数值,而整数是不带小数点的数值。
3)html当中如何引用js文件 如果需要javascript工程师和html美工各干各的工作,需要分开写文件。 例 1.2 <html> <head> <script src="Hello.js"></script> <title></title> </head> <body> </body> </html> Hello.js(如果你用notepad建立一个txt之后你再改为js,一定在存时,要存成utf-8或unicode格式): var a ; /*before you set value, a' type can not be defined.*/ document.writeln(typeof(a) + "他们"); a = true; document.writeln(typeof(a) + ""); /*下面的console.log只有安装了firebug的firebox不报错*/ console.log("This is the 1 message 马克-to-win write in %s", a); document.writeln(a);
导语: 跨端开发中,经常会遇到插件,接口管理上的问题。了解完本文,你将会了解Flutter是如何通过Pigeon去解决plugin中多端开发难以管理的问题。 demo源码地址 https://github.com/linpenghui958/flutterPigeonDemo warning:目前Pigeon还是prerelease版本,所以可能会有breaking change。下文以0.1.7版本为例。 为何需要Pigeon 在hybird开发中,前端需要native能力,需要native双端开发
HTML5+CSS3+JavaScript从入门到精通 作者:王征,李晓波 第十二章 Javascript编程的初步知 案例 12-01 JavaScript的数值常量 <!DOCTYPE html>
初遇 Java语言包含两种内在的同步机制:同步块(或方法)和 volatile 变量。这两种机制的提出都是为了实现代码线程的安全性。其中 Volatile 变量的同步性较差(但有时它更简单并且开销更低),而且其使用也更容易出错。 synchronized同步块 Java中的同步块用synchronized标记。同步块在Java中是同步在某个对象上。所有同步在一个对象上的同步块在同时只能被一个线程进入并执行操作。所有其他等待进入该同步块的线程将被阻塞,直到执行该同步块中的线程退出。 有四种不同的同步块:
prototype 见上一节,马克-to-win:prototype作用就是给某个类增加一个实例方法。 例 3.6.2 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> /*When the Global object is created, it always has at least the following properties: Object object Function object Array object String object Boolean object Number object Date object Math object Value properties */ Array.prototype.mymethod = function(number) { var result = -1; /*注意mymethod功能是找出某数在数组中出现的位置。作为Array的一个function,可以访问Array的属性this.length, 参见上一个prototype的例子, Student.prototype.infop = function()/*此方法可以为所有Student对象所用*/ { document.writeln("对象的qixy属性p:" + this.qixy); document.writeln("对象的age属性p:" + this.age); /*下列话是合法的, 因为不是this.number, 而是Student.number*/ document.writeln("static method is " + Student.number); }; */ for (var i = 0; i < this.length; i ++) { if (this[i] == number) { result = i; break; } } return result; }
说道并查集,大家一定对于以多叉树状结构为基础的并查集并不陌生,最常见的两种写法如下 1 function getfat(x:longint):longint; 2 begin 3 while x<>c[x] do x:=c[x]; 4 exit(x); 5 end; 1 function getfat(x:longint):longint; 2 begin 3 if x<>c[x] then exit(getfat(c[x])) els
2822 爱在心中 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description “每个人都拥有一个梦,即使彼此不相同,能够与你分享,无论失败成功都会感动。爱因为在心中,平凡而不平庸,世界就像迷宫,却又让我们此刻相逢Our Home。” 在爱的国度里有N个人,在他们的心中都有着一个爱的名单,上面记载着他所爱的人(不会出现自爱的情况)。爱是具有传递性的,即如果A爱B,B爱C,则A也爱C。 如果有这样一部分人,他们彼此都相爱,则他们就超越了一
很多人都建议jquery使用cdn加速的方式引入。当然,我不反对这么做。但是以我自己做项目的便利性,我还是习惯把jq放在本地使用。原因有以下几点:
Java synchronized块将方法或代码块标记为已同步。Java synchronized块可用于避免竞争条件。
工作中有个需求需要发送邮件,因为使用的delphi6,所以自然就选择了indy组件,想想这事挺简单的。实现的过程倒是简单,看着Indy的demo很快就完了,毕竟也不是很复杂的功能。 功能要求: 1、压缩日志文件并作为邮件的附件 2、邮件正文带上一些客户端信息 组件介绍 TIdSmtp:与服务器的连接及数据发送,基于smtp协议 TIdMessage:自然就是报文的信息了,包含收件人、发件人、主题、正文,以及附件。 代码展示: function TfrmMailSend.SendMail: Boolean;
1610: [Usaco2008 Feb]Line连线游戏 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1396 Solved: 615 [Submit][Status] Description Farmer John最近发明了一个游戏,来考验自命不凡的贝茜。游戏开始的时 候,FJ会给贝茜一块画着N (2 <= N <= 200)个不重合的点的木板,其中第i个点 的横、纵坐标分别为X_i和Y_i (-1,000 <= X_i <=1,000; -1,0
文档地址:guzzle文档地址(https://guzzle-cn.readthedocs.io/zh_CN/latest/quickstart.html)
在IE中iframe或者frame的contentWindow属性可以省略,但在Firefox中如果要对iframe对象进行编辑则
📷 1. 创建自定义指令 2. 指令的参数、选项 1. 创建自定义指令 ---- 一、第一步: 创建自定义命令类文件 命令格式 php think make:command 自定义命令类 命令名 使用示例 php think make:command Hello hello php think make:command index@Hello hello 自定义命令类方法示例 configure() 方法用于指令的配置: 命令名、参数、选项、描述 execute() 方法在命令行执行指令时会执行 prot
实现功能:求出二维平面内一对散点的凸包(详见Codevs 1298) 很神奇的算法——先将各个点按坐标排序,然后像我们所知的那样一路左转,求出半边的凸包,然后反过来求另一半的凸包 我以前正是因为总抱着想一步到位的想法,所以每次都跪得很惨(HansBug:事实上这次是我这辈子第一次A掉凸包题) 然后别的没了,就是凸包的基本思想 (顺便输出凸包周长C和面积S) 1 type arr=array[0..100005] of longint; 2 var 3 i,j,k,l,m,n,m1,m2:long
1)设计更复杂 虽然有一些多线程应用程序比单线程的应用程序要简单,但其他的一般都更复杂。在多线程访问共享数据的时候,这部分代码需要特别的注意。线程之间的交互往往非常复杂。不正确的线程同步产生的错误非常难以被发现,并且重现以修复。
在自己的项目中嵌入过广告的朋友们可能都用过百度联盟, 只需要嵌入如下一段js代码片段, 就可以在自己的项目中嵌入广告, 来获得收益. <script type=“text javascript”>
实现功能——操作1:将两个数字合并到一个集合内;操作2:判断两个数字是否在一起 第6行是亮点,这个优化能快出不少,真的 1 var 2 i,j,k,l,m,n:longint; 3 c:array[0..100000] of longint; 4 function getfat(x:longint):longint;inline; 5 begin 6 if c[x]<>x then c[x]:=getfat(c[x]); //亮点在这
1627: [Usaco2007 Dec]穿越泥地 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 504 Solved: 325 [Submit][Status] Description 清早6:00,Farmer John就离开了他的屋子,开始了他的例行工作:为贝茜挤奶。前一天晚上,整个农场刚经受过一场瓢泼大雨的洗礼,于是不难想见,FJ 现在面对的是一大片泥泞的土地。FJ的屋子在平面坐标(0, 0)的位置,贝茜所在的牛棚则位于坐标(X,Y) (-500 <
领取专属 10元无门槛券
手把手带您无忧上云