This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
有时候我们可以用这样的方式交换变量 | |
var a = 3, b = 4; | |
a = a ^ b; | |
b = a ^ b; | |
a = a ^ b; | |
console.log(a + '--' + b); // 4--3 交换成功 | |
但是, 这种方法有俩点需要注意 : | |
1. a 和 b要为整数(也就是int类型, 虽然js没有int类型, 所有数字都是以64位浮点数形式储存, 但只要你写的数字是整数就OK) | |
2. a, b 不可以相同 (并不是说值不能相同, 而是说不能 a与a进行这种运算, 经常会在交换数组的俩个数值时发生这种错误) ,例如 : | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q : I can jump to code if I click in a method name and hit F12. But, | |
is there a keyboard short cut to jump back to the previous code editor location? | |
A : Ctrl + - : (that's Ctrl and Minus) will navigate back (maps to View.NavigateBackward). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.Net 视图页面要在顶部声明形如这样的一行代码 | |
<%@ Page Title="" Language="C#" MasterPageFile="" Inherits="System.Web.Mvc.ViewPage<Quanmama.Models.YouhuiQueryResult>" %> | |
否则编译器会报错. MasterPageFile可以为空 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hammer.js is a open-source library that can recognize gestures made by touch, mouse and pointerEvents. | |
It doesn't have any dependencies, and it's small, only 3.96 kB minified + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 我有一个数据表, 其中有一个字段是 XML数据, 我现在要把数据读出来并存储到 JSON格式的数据结构中返回给浏览器 | |
// 我使用的PHP原生函数 json_encode, 但是json格式依然有错误, 主要是因为 xml中有许多特殊字符 | |
// 怎么办 ? | |
// 用base64_encode 编码xml数据后再存储到 json 结构中. 形如下面这样 | |
// 客户端解析 w_desc 字段时, 先base64解码一下就好了. | |
/* | |
[{ | |
"w_val": "abampere", | |
"w_desc": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHlvZGFvZGljdD4KICA8cmV0dXJuLXBocmFzZT48IVtDREFUQVthYmFtcGVyZV1dPjwvcmV0dXJuLXBocmFzZT4KICAgICAgICAgICAgICAgIDxsYW5nPmVuZzwvbGFuZz4KICAgICAgICAgICAgICAgCSAgCiAgICAgICAgICAgICAgICA8ZGljdGNuLXNwZWFjaD48IVtDREFUQVthYmFtcGVyZV1dPjwvZGljdGNuLXNwZWFjaD4KICAgICAgIDxzcGVlY2g+PCFbQ0RBVEFbYWJhbXBlcmVdXT48L3NwZWVjaD4KICAgICAgIDx1ay1zcGVlY2g+PCFbQ0RBVEFbYWJhbXBlcmVdXT48L3VrLXNwZWVjaD4KICAgICAgIDx1cy1zcGVlY2g+PCFbQ0RBVEFbYWJhbXBlcmVdXT48L3VzLXNwZWVjaD4KICAgICAgICAgICAgICAJPHBob25ldGljLXN5bWJvbD7DpmInw6ZtcM61yZk8L3Bob25ldGljLXN5bWJvbD4KICAgICAgICAgICAgICAgICAgICAgIDx1ay1waG9uZXRpYy1zeW1ib2w+w6ZiJ8OmbXDOtcmZPC91ay1waG9uZXRpYy1zeW1ib2w+CiAgICAgICAgICAgICAgICAgICAgICA8dXMtcGhvbmV0aWMtc3ltYm9sPsOmYifDpm1wzrXJmTwvdXMtcGh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 这几天用PHP读取一个35w行的单词本, 遇到了下面这个错误 | |
// Maximum execution time of 30 seconds exceeded | |
// 原因是程序执行的时间超过了默认的最大执行时间 30 秒 | |
// 解决方法有俩种 : | |
// 1. 修改php.ini 中max_execution_time 的值(单位 : 秒), 如果为0表示不限制执行时间 | |
// 2. 我喜欢用一个函数 void set_time_limit ( int $seconds ), 参数为0表示不限制执行时间 | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 为什么要判断是否是微信打开的网页 ? | |
// 因为微信中打不开淘宝等链接, 如果判断出微信打开了该网页, 我们可以做如下事情 : | |
// 1. 将微信中不能打开的url放在iframe中显示 | |
// 2. 提示用户用浏览器打开该链接 | |
function isWeixinBrowser() { | |
var ua = navigator.userAgent.toLowerCase(); | |
return (/micromessenger/.test(ua)) ? true : false; | |
} |
NewerOlder